Skip to content

Commit

Permalink
DAS-2180: Adds matrix of library tests to CI
Browse files Browse the repository at this point in the history
renames run_tests -> run_service_tests
Adds run_lib_tests and runs the unit tests against a python matrix.
  • Loading branch information
flamingbear committed Jul 19, 2024
1 parent 489d852 commit f27bcea
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 16 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will run when changes are detected in the `main` branch, which
# must include an update to the `docker/service_version.txt` file. The workflow
# can also be manually triggered by a repository maintainer. This workflow will
# first trigger the reusable workflow in `.github/workflows/run_tests.yml`,
# first trigger the reusable workflow in `.github/workflows/run_service_tests.yml`,
# which runs the `unittest` suite. If that workflow is successful, the latest
# version of the service Docker image is pushed to ghcr.io, a library package
# is built and published to PyPI, a tag is added to the latest git commit, and
Expand All @@ -20,11 +20,14 @@ env:
REGISTRY: ghcr.io

jobs:
run_tests:
uses: ./.github/workflows/run_tests.yml
run_service_tests:
uses: ./.github/workflows/run_service_tests.yml

run_lib_tests:
uses: ./.github/workflows/run_lib_tests.yml

build_and_publish:
needs: run_tests
needs: [run_service_tests, run_lib_tests]
runs-on: ubuntu-latest
environment: release
permissions:
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/run_lib_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# This workflow will run the appropriate library tests across a python matrix of versions.
name: Run Python library tests

on:
workflow_call

jobs:
build_and_test_lib:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.10', '3.11']

steps:
- name: Checkout harmony-browse-image-generator repository
uses: actions/checkout@v4
with:
lfs: true

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install GDAL
run: |
# Install packaged version of GDAL.
sudo apt-get update
sudo apt-get install -y libgdal-dev
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install -r pip_requirements.txt
# Use the gdal version that was installed
pip install GDAL==$(gdal-config --version)
pip install -r tests/pip_test_requirements.txt
- name: Run tests without the adapters.
run: |
pytest $(find tests -name "test_*.py" ! -name "*adapter*")
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
# test results and code coverage as artefacts. It will be called by the
# workflow that run tests against new PRs and as a first step in the workflow
# that publishes new Docker images.
name: Run Python unit tests
name: Run Python tests

on:
workflow_call

jobs:
build_and_test:
build_and_test_service:
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/run_tests_on_pull_requests.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This workflow will run when a PR is opened against the `main` branch. It will
# trigger the reusable workflow in `.github/workflows/run_tests.yml`, which
# trigger the reusable workflow in `.github/workflows/run_service_tests.yml`, which
# builds the service and test Docker images, and runs the `unittest` suite in a
# Docker container built from the test image.
name: Run Python unit tests for pull requests against main
Expand All @@ -9,5 +9,8 @@ on:
branches: [ main ]

jobs:
build_and_test:
uses: ./.github/workflows/run_tests.yml
build_and_test_service:
uses: ./.github/workflows/run_service_tests.yml

run_lib_tests:
uses: ./.github/workflows/run_lib_tests.yml
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,15 +364,16 @@ When publishing a new release, two files must be updated:
The CI/CD for HyBIG is contained in GitHub workflows in the
`.github/workflows` directory:
* `run_tests.yml` - A reusable workflow that builds the service and test Docker
images, then runs the Python unit test suite in an instance of the test
Docker container.
* `run_lib_tests.yml` - A reusable workflow that tests the library functions
against the supported python versions.
* `run_service_tests.yml` - A reusable workflow that builds the service and
test Docker images, then runs the Python unit test suite in an instance of
the test Docker container.
* `run_tests_on_pull_requests.yml` - Triggered for all PRs against the `main`
branch. It runs the workflow in `run_tests.yml` to ensure all tests pass for
the new code.
branch. It runs the workflow in `run_service_tests.yml` and
`run_lib_tests.yml` to ensure all tests pass for the new code.
* `publish_docker_image.yml` - Triggered either manually or for commits to the
`main` branch that contain changes to the `docker/service_version.txt` file.
* `publish_to_pypi.yml` - Triggered either manually or for commits to the
`main` branch that contain changes to the `docker/service_version.txt`file.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ maintainers = [
description = "Python package designed to produce browse imagery compatible with NASA's Global Image Browse Services (GIBS)."

readme = "README.md"
requires-python = ">=3.9"
requires-python = ">=3.10"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Apache Software License",
Expand Down

0 comments on commit f27bcea

Please sign in to comment.