-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DAS-2070 - Implement GitHub workflows CI/CD.
- Loading branch information
1 parent
27e33a2
commit 04c6ea0
Showing
16 changed files
with
297 additions
and
27 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,17 @@ | ||
## Description | ||
|
||
A short description of the changes in this PR. | ||
|
||
## Jira Issue ID | ||
|
||
[DAS-XXXX](https://bugs.earthdata.nasa.gov/browse/DAS-XXXX) | ||
|
||
## Local Test Steps | ||
|
||
|
||
## PR Acceptance Checklist | ||
* [ ] Jira ticket acceptance criteria met. | ||
* [ ] `CHANGELOG.md` updated to include high level summary of PR changes. | ||
* [ ] `docker/service_version.txt` updated if publishing a release. | ||
* [ ] Tests added/updated and passing. | ||
* [ ] Documentation updated (if needed). |
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,83 @@ | ||
# 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`, | ||
# which runs the `unittest` suite. If that workflow is successful, the latest | ||
# version of the service Docker image is pushed to ghcr.io, a tag is added to | ||
# the latest git commit, and a GitHub release is created with the release notes | ||
# from the latest version of HyBIG. | ||
name: Publish Harmony Browse Image Generator (HyBIG) Docker image | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
paths: docker/service_version.txt | ||
workflow_dispatch: | ||
|
||
env: | ||
IMAGE_NAME: ${{ github.repository }} | ||
REGISTRY: ghcr.io | ||
|
||
jobs: | ||
run_tests: | ||
uses: ./.github/workflows/run_tests.yml | ||
|
||
build_and_publish_image: | ||
needs: run_tests | ||
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 harmony-browse-image-generator repository | ||
uses: actions/checkout@v3 | ||
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,42 @@ | ||
# This workflow will build the service and test Docker images for HyBIG, then | ||
# run the Python `unittest` 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 unit tests | ||
|
||
on: | ||
workflow_call | ||
|
||
jobs: | ||
build_and_test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
|
||
steps: | ||
- name: Checkout harmony-browse-image-generator repository | ||
uses: actions/checkout@v3 | ||
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 | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: Test results | ||
path: test-reports/ | ||
|
||
- name: Archive coverage report | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: Coverage report | ||
path: coverage/* |
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,13 @@ | ||
# 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 | ||
# 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 | ||
|
||
on: | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build_and_test: | ||
uses: ./.github/workflows/run_tests.yml |
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,47 @@ | ||
# Contributing to HyBIG | ||
|
||
Thanks for contributing! | ||
|
||
## Making Changes | ||
|
||
To allow us to incorporate your changes, please use the | ||
[Fork-and-Pull](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/getting-started/about-collaborative-development-models#fork-and-pull-model) | ||
development model: | ||
|
||
1. Fork this repository to your personal account. | ||
2. Create a branch and make your changes. | ||
3. Test the changes locally/in your personal fork. | ||
4. Submit a pull request to open a discussion about your proposed changes. | ||
5. The maintainers will talk with you about it and decide to merge or request | ||
additional changes. | ||
|
||
For larger items, consider contacting the maintainers first to coordinate | ||
development efforts. | ||
|
||
## Commits | ||
|
||
Our ticketing and CI/CD tools are configured to sync statuses amongst each | ||
other. Commits play an important role in this process. Please start all commits | ||
with the Jira ticket number associated with your feature, task, or bug. All | ||
commit messages should follow the format | ||
"[Jira Project]-XXXX - [Your commit message here]" | ||
|
||
## General coding practices: | ||
|
||
This repository adheres to Python coding style recommendations from | ||
[PEP8](https://peps.python.org/pep-0008/). Additionally, type hints are | ||
encouraged in all function signatures. | ||
|
||
When adding or updating functionality, please ensure unit tests are added to | ||
the existing `unittest` suite in the `tests` directory, which cover each branch | ||
of the code. | ||
|
||
## Disclaimer | ||
|
||
HyBIG maintainers will review all pull requests submitted. Only requests that | ||
meet the standard of quality set forth by existing code, following the patterns | ||
set forth by existing code, and adhering to existing design patterns will be | ||
considered and/or accepted. | ||
|
||
For general tips on open source contributions, see | ||
[Contributing to Open Source on GitHub](https://guides.github.com/activities/contributing-to-open-source/). |
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
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,22 @@ | ||
#!/bin/bash | ||
############################################################################### | ||
# | ||
# A bash script to extract only the notes related to the most recent version of | ||
# HyBIG from CHANGELOG.md | ||
# | ||
# 2023-06-16: Created. | ||
# 2023-10-10: Copied from earthdata-varinfo repository to HOSS. | ||
# 2024-01-03: Copied from HOSS repository to the Swath Projector. | ||
# 2024-01-23: Copied and modified from Swath Projector repository to HyBIG. | ||
# | ||
############################################################################### | ||
|
||
CHANGELOG_FILE="CHANGELOG.md" | ||
VERSION_PATTERN="^## v" | ||
|
||
# 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 "^#" |
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
Oops, something went wrong.