Skip to content

Commit

Permalink
DAS-2180 extract lib (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
flamingbear authored Jul 31, 2024
1 parent d7359d8 commit 3d14e70
Show file tree
Hide file tree
Showing 33 changed files with 755 additions and 273 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# 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 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
# 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
# a GitHub release is created with the release notes from the latest version of
# HyBIG.
name: Publish Harmony Browse Image Generator (HyBIG)

on:
push:
Expand All @@ -19,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

build_and_publish_image:
needs: run_tests
run_lib_tests:
uses: ./.github/workflows/run_lib_tests.yml

build_and_publish:
needs: [run_service_tests, run_lib_tests]
runs-on: ubuntu-latest
environment: release
permissions:
Expand All @@ -36,7 +40,7 @@ jobs:

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

Expand Down Expand Up @@ -74,6 +78,17 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Build hybig-py package
run: python -m build

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

- name: Publish GitHub release
uses: ncipollo/release-action@v1
with:
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/run_lib_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# 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 in the previous step. This
# is not the same GDAL as installed in the docker images but in the
# end we're only using osgeo's ColorPalette
pip install GDAL==$(gdal-config --version)
pip install -r tests/pip_test_requirements.txt
- name: Run science tests while excluding the service tests.
run: |
pytest tests --ignore tests/test_service
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
# 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

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

Expand All @@ -30,13 +30,13 @@ jobs:
run: ./bin/run-test

- name: Archive test results
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Test results
path: test-reports/

- name: Archive coverage report
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Coverage report
path: coverage/*
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: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ HyBIG follows semantic versioning. All notable changes to this project will be
documented in this file. The format is based on [Keep a
Changelog](http://keepachangelog.com/en/1.0.0/).

## [v2.0.0] - 2024-07-19

**DAS-2180** - Adds pip installable library.

This release is a refactor that extracts browse image generation logic from the
harmony service code. There are no user visible changes to the existing
functionality. The new library,
[hybig-py](https://pypi.org/project/hybig-py/), provides the `create_browse`
function to generate browse images, see the README.md for details.

## [v1.2.2] - 2024-06-18

### Changed
Expand Down Expand Up @@ -52,7 +62,8 @@ outlined by the NASA open-source guidelines.
For more information on internal releases prior to NASA open-source approval,
see legacy-CHANGELOG.md.

[unreleased]:https://github.com/nasa/harmony-browse-image-generator/compare/1.2.2..HEAD
[unreleased]:https://github.com/nasa/harmony-browse-image-generator/compare/2.0.0..HEAD
[v2.0.0]:https://github.com/nasa/harmony-browse-image-generator/compare/1.2.2..2.0.0
[v1.2.2]: https://github.com/nasa/harmony-browse-image-generator/compare/1.2.1..1.2.2
[v1.2.1]: https://github.com/nasa/harmony-browse-image-generator/compare/1.2.0..1.2.1
[v1.2.0]: https://github.com/nasa/harmony-browse-image-generator/compare/1.1.0..1.2.0
Expand Down
Loading

0 comments on commit 3d14e70

Please sign in to comment.