-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a docker/dagger-based testing workflow, adopt PEP 517/621 #300
Open
Zeitsperre
wants to merge
39
commits into
master
Choose a base branch
from
docker-testing
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 19 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
4ab74a3
add some more linting checks
Zeitsperre 1d618c9
try a docker-based testing approach using dagger-io
Zeitsperre 025218c
update sphinx-rtd-theme package name
Zeitsperre 3ba5ea2
Change LICENSE to BSD-3-Clause, move license to top-level, rename rel…
Zeitsperre 05578ed
adopt PEP517 and PEP 621, add more metadata, add pre-commit hooks for…
Zeitsperre 57dae29
try a different approach using a Dockerfile and build arguments
Zeitsperre 65ceb12
Tryo to build docker image in GitHub
Zeitsperre 60cd527
use python3.8
Zeitsperre 949e9c1
make dagger config local and CI compatible
Zeitsperre f47cd20
add run-cancelling action
Zeitsperre cdd8d45
install dagger in running kernel
Zeitsperre 73e6e34
fix python versions and metadata
Zeitsperre bbeaad0
fix version number
Zeitsperre 251b1c0
fix triggering
Zeitsperre 6566b9c
fix dagger package name
Zeitsperre ca1a85b
try a different approach, typo fix
Zeitsperre c1049c0
fix approach
Zeitsperre 646587c
cleanup
Zeitsperre 343cc53
better information
Zeitsperre 0b0e945
implement workflow_dispatch with inputs, do not modify base image
Zeitsperre 1485340
debugging
Zeitsperre f39f2a9
fix double env-var setting
Zeitsperre 0b88ef1
re-enable notebook tests
Zeitsperre 2fd7a0a
better organization
Zeitsperre 5313a10
typo fix
Zeitsperre 2ea3cac
cleaner
Zeitsperre 44448e5
more typos
Zeitsperre fd9dc13
remove Dockerfile
Zeitsperre 2a12d9d
give jenkins rights to the folder
Zeitsperre 2176210
place kwargs in proper context
Zeitsperre b9c964b
fix arguments
Zeitsperre de8b004
fix PAVICS_HOST env var
Zeitsperre a08eb64
add a conftest.py, use pytest_collectstart to ignore widget and javas…
Zeitsperre f1f580c
try a different approach
Zeitsperre 09774b9
re-add testing dirs to cli calls
Zeitsperre 929530b
BASE_IMAGE_TAG must always be supplied to dagger-pipeline.py
Zeitsperre e0cc4d4
deal with changing API
Zeitsperre a83e283
Merge branch 'master' into docker-testing
Zeitsperre 30d6a52
Merge branch 'master' into docker-testing
Zeitsperre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Dagger/Docker Testing Suite | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
workflow_dispatch: | ||
inputs: | ||
image_tag: | ||
description: 'Image tag to use for the Docker image' | ||
required: true | ||
default: 'latest' | ||
|
||
jobs: | ||
lint: | ||
name: Linting | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Cancel previous runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.8 | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install pre-commit | ||
pre-commit install | ||
- name: Run pre-commit | ||
run: | | ||
pre-commit run --all-files --show-diff-on-failure | ||
|
||
integration: | ||
name: Integration Tests | ||
needs: lint | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: bash -l {0} | ||
strategy: | ||
matrix: | ||
python-version: ["3.10"] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Dagger testing | ||
run: | | ||
export BASE_IMAGE_TAG=${{ github.event.inputs.image_tag }} | ||
pip install .[dagger] | ||
python ./ci/dagger-pipeline.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
|
||
rules: | ||
document-start: disable | ||
line-length: | ||
max: 120 | ||
level: warning | ||
truthy: disable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# vim:set ft=dockerfile: | ||
ARG BASE_IMAGE_TAG | ||
FROM pavics/workflow-tests:${BASE_IMAGE_TAG:-latest} | ||
ARG DEBIAN_FRONTEND=noninteractive | ||
ENV PIP_ROOT_USER_ACTION=ignore | ||
LABEL org.opencontainers.image.authors="https://github.com/ouranosinc/pavics-sdi" | ||
LABEL Description="PAVICS-SDI-TESTING-IMAGE" Vendor="Birdhouse" Version="1.3.0" | ||
|
||
# root-level commands | ||
USER root | ||
|
||
# Install build tools | ||
RUN apt-get install --yes build-essential \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Switch to /code directory | ||
WORKDIR /code | ||
|
||
# Build finch environment | ||
COPY environment-dev.yml /code | ||
RUN mamba install -n birdy python=3.8 --yes \ | ||
Zeitsperre marked this conversation as resolved.
Show resolved
Hide resolved
|
||
&& mamba env update -n birdy -f environment-dev.yml \ | ||
&& mamba clean --all --yes | ||
|
||
# Add the finch conda environment to the path | ||
ENV PATH /opt/conda/envs/birdy/bin:$PATH | ||
Zeitsperre marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Copy finch source code | ||
Zeitsperre marked this conversation as resolved.
Show resolved
Hide resolved
|
||
COPY . /code | ||
|
||
# Build the documentation | ||
CMD ["make", "--directory=/code/docs", "html"] | ||
Zeitsperre marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
BSD 3-Clause License | ||
Zeitsperre marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Copyright (c) 2017, Ouranos, CRIM | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
"""Build the documentation within a docker pipeline to test integration and notebooks.""" | ||
|
||
import os | ||
import sys | ||
from pathlib import Path | ||
|
||
try: | ||
import anyio | ||
import dagger | ||
from dagger import BuildArg | ||
from dagger.engine._version import CLI_VERSION as __dagger_version__ # noqa | ||
except ImportError: | ||
raise ImportError( | ||
"Dagger is not installed. Please install it with `pip install dagger-io` first." | ||
) | ||
|
||
|
||
async def main(): | ||
async with dagger.Connection(dagger.Config(log_output=sys.stderr)) as client: | ||
top_level_dir = client.host().directory(Path(__file__).parent.parent.as_posix()) | ||
|
||
# build container | ||
sources = await top_level_dir.docker_build( | ||
build_args=BuildArg("BASE_IMAGE_TAG", os.getenv("BASE_IMAGE_TAG")) | ||
if os.getenv("BASE_IMAGE_TAG") | ||
else None, | ||
) | ||
|
||
# smoke tests | ||
python_version = sources.with_exec(["python", "-V"]) | ||
username = sources.with_exec(["whoami"]) | ||
|
||
# build docs | ||
docs = sources.with_exec(["make", "--directory=/code/docs", "html"]) | ||
Zeitsperre marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# execute | ||
user = await username.stdout() | ||
version = await python_version.stdout() | ||
docs_built = await docs.stdout() | ||
|
||
print("\n") | ||
print( | ||
f"Hello from Dagger {__dagger_version__} and {'.'.join([str(v) for v in sys.version_info[0:3]])}\n" | ||
) | ||
print(f"Running commands as `{user.strip()}` user in {version.strip()}.\n") | ||
print(docs_built) | ||
|
||
|
||
anyio.run(main) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"""PAVICS SDI package.""" | ||
|
||
|
||
__version__ = "1.3.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
[build-system] | ||
requires = ["flit_core >=3.8,<4"] | ||
build-backend = "flit_core.buildapi" | ||
|
||
[project] | ||
name = "pavics_sdi" | ||
requires-python = ">=3.8" | ||
authors = [ | ||
{name = "CRIM/Ouranos", email = "[email protected]"} | ||
] | ||
maintainers = [ | ||
{name = "Tuan Long Vu", email = "[email protected]"}, | ||
{name = "David Huard", email = "[email protected]"}, | ||
{name = "Trevor James Smith", email = "[email protected]"}, | ||
{name = "Francis Charette-Migneault", email = "[email protected]"} | ||
] | ||
readme = {file = "README.rst", content-type = "text/x-rst"} | ||
description = "Scientific gateway for climate data analytics." | ||
license = {file = "LICENSE"} | ||
classifiers = [ | ||
"Intended Audience :: Science/Research", | ||
"License :: OSI Approved :: BSD License", | ||
"Operating System :: OS Independent", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Topic :: Scientific/Engineering :: Atmospheric Science" | ||
] | ||
dynamic = ["version"] | ||
dependencies = [] | ||
|
||
[project.optional-dependencies] | ||
docs = [ | ||
"jinja2", | ||
"jupyter", | ||
"jupytext", | ||
"myst-nb", | ||
"requests", | ||
"sphinx-intl", | ||
"sphinx-jsonschema", | ||
"sphinx-rtd-theme>=1.0", | ||
"sphinx>=1.4" | ||
] | ||
dagger = [ | ||
"anyio", | ||
"dagger-io" | ||
] | ||
|
||
[project.urls] | ||
"Homepage" = "https://pavics-sdi.readthedocs.io" | ||
"Source" = "https://github.com/Ouranosinc/pavics-sdi/" | ||
"Changelog" = "https://pavics-sdi.readthedocs.io/en/latest/release_notes.html" | ||
"Issue tracker" = "https://github.com/Ouranosinc/pavics-sdi/issues" | ||
"About CRIM" = "https://www.crim.ca/en/" | ||
"About Ouranos" = "https://www.ouranos.ca/en/" |
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
latest
is whenever someone push something tomaster
, which is never tested ! The current version in production is230601
, this one should be the default. Hum, how to keep this one up-to-date without additional manual commit on each Jupyter env release ...