-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DAS-2267: Add CI config for testing and reporting. (#4)
- Loading branch information
1 parent
e532406
commit 17f2797
Showing
9 changed files
with
245 additions
and
79 deletions.
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,89 @@ | ||
# This workflow will build and publish Docker image to ghcr.io | ||
|
||
# This workflow runs when changes are detected in the `main` branch, which | ||
# include an update to the `docker/service_version.txt` file. The workflow can | ||
# also be manually triggered by a repository maintainer. | ||
|
||
# IF all pre-requisite tests pass, this workflow will build the docker images, | ||
# push them to ghcr.io and publish a GitHub release. | ||
name: Publish SMAP L2 Gridding Service | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
paths: docker/service_version.txt | ||
workflow_dispatch: | ||
|
||
env: | ||
IMAGE_NAME: ${{ github.repository }} | ||
REGISTRY: ghcr.io | ||
|
||
jobs: | ||
run_service_tests: | ||
uses: ./.github/workflows/run_service_tests.yml | ||
|
||
run_lib_tests: | ||
uses: ./.github/workflows/run_lib_tests.yml | ||
|
||
mypy: | ||
uses: ./.github/workflows/mypy.yml | ||
|
||
build_and_publish: | ||
needs: [run_service_tests, run_lib_tests, mypy] | ||
runs-on: ubuntu-latest | ||
environment: release | ||
permissions: | ||
# write permission is required to create a GitHub release | ||
contents: write | ||
id-token: write | ||
packages: write | ||
strategy: | ||
fail-fast: false | ||
|
||
steps: | ||
- name: Checkout smap-l2-gridder repository | ||
uses: actions/checkout@v4 | ||
with: | ||
lfs: true | ||
|
||
- name: Extract semantic version number | ||
run: echo "semantic_version=$(cat docker/service_version.txt)" >> $GITHUB_ENV | ||
|
||
- name: Extract release version notes | ||
run: | | ||
version_release_notes=$(./bin/extract-release-notes.sh) | ||
echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV | ||
echo "${version_release_notes}" >> $GITHUB_ENV | ||
echo "EOF" >> $GITHUB_ENV | ||
- name: Log-in to ghcr.io registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Add tags to the Docker image | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
tags: | | ||
type=semver,pattern={{version}},value=${{ env.semantic_version }} | ||
- name: Push Docker image | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
file: docker/service.Dockerfile | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
- name: Publish GitHub release | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
body: ${{ env.RELEASE_NOTES }} | ||
commit: main | ||
name: Version ${{ env.semantic_version }} | ||
tag: ${{ env.semantic_version }} |
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,34 @@ | ||
# 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', '3.12'] | ||
|
||
steps: | ||
- name: Checkout smap-l2-gridder 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 dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pytest | ||
pip install -r pip_requirements.txt -r tests/pip_test_requirements.txt | ||
- name: Run science tests while excluding the service tests. | ||
run: | | ||
pytest tests --ignore tests/test_service |
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,37 @@ | ||
# This workflow will build the service and test Docker images for smap-l2-gridder, | ||
# then run the `pytest` suite within a test Docker container, reporting | ||
# 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 Service Tests | ||
|
||
on: | ||
workflow_call | ||
|
||
jobs: | ||
build_and_test_service: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
|
||
steps: | ||
- name: Checkout smap-l2-gridder repository | ||
uses: actions/checkout@v4 | ||
with: | ||
lfs: true | ||
|
||
- name: Build service image | ||
run: ./bin/build-image | ||
|
||
- name: Build test image | ||
run: ./bin/build-test | ||
|
||
- name: Run test image | ||
run: ./bin/run-test | ||
|
||
- name: Archive test results and coverage | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: reports | ||
path: reports/**/* |
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
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,26 @@ | ||
#!/bin/bash | ||
############################################################################### | ||
# | ||
# A bash script to extract only the notes related to the most recent version of | ||
# SMAP L2 Gridding Service from CHANGELOG.md | ||
# | ||
############################################################################### | ||
|
||
CHANGELOG_FILE="CHANGELOG.md" | ||
|
||
## captures versions | ||
## >## v1.0.0 | ||
## >## [v1.0.0] | ||
VERSION_PATTERN="^## [\[]v" | ||
|
||
## captures url links | ||
## [unreleased]:https://github.com/nasa/harmony-browse-image-generator/compare/1.2.0..HEAD | ||
## [v1.2.0]: https://github.com/nasa/harmony-browse-image-generator/compare/1.1.0..1.2.0 | ||
LINK_PATTERN="^\[.*\].*\.\..*" | ||
|
||
# Read the file and extract text between the first two occurrences of the | ||
# VERSION_PATTERN | ||
result=$(awk "/$VERSION_PATTERN/{c++; if(c==2) exit;} c==1" "$CHANGELOG_FILE") | ||
|
||
# Print the result | ||
echo "$result" | grep -v "$VERSION_PATTERN" | grep -v "$LINK_PATTERN" |
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 |
---|---|---|
@@ -1 +1 @@ | ||
0.0.0 | ||
0.0.1 |
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