[WIP] Sydneyimaging t1 preproc #3
Workflow file for this run
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 workflows will upload a Python Package using Twine when a release is created | |
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries | |
name: CI/CD | |
on: | |
push: | |
branches: [ main, develop ] | |
tags: [ '*' ] | |
pull_request: | |
branches: [ main, develop ] | |
release: | |
types: [published] | |
workflow_dispatch: # Allow manual triggering by a user with write access to this repo | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
test-python: | |
strategy: | |
matrix: | |
os: [macos-latest, ubuntu-latest, windows-latest] | |
python-version: ["3.8", "3.12"] | |
fail-fast: false | |
runs-on: ${{ matrix.os }} | |
defaults: | |
run: | |
shell: bash -l {0} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Unset header | |
# checkout@v2 adds a header that makes branch protection report errors | |
# because the Github action bot is not a collaborator on the repo | |
run: git config --local --unset http.https://github.com/.extraheader | |
- name: Fetch tags | |
run: git fetch --prune --unshallow | |
- name: Disable etelemetry | |
run: echo "NO_ET=TRUE" >> $GITHUB_ENV | |
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Update build tools | |
run: python3 -m pip install --upgrade pip | |
- name: Install Package | |
run: python3 -m pip install -e ./src[test] | |
- name: Pytest | |
run: pytest -vvs --cov australianimagingservice_community --cov-config .coveragerc --cov-report xml . | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v2 | |
with: | |
fail_ci_if_error: true | |
token: ${{ secrets.CODECOV_TOKEN }} | |
build-python: | |
needs: [test-python] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
fetch-depth: 0 | |
- name: Unset header | |
# checkout@v2 adds a header that makes branch protection report errors | |
# because the Github action bot is not a collaborator on the repo | |
run: git config --local --unset http.https://github.com/.extraheader | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12' | |
- name: Install build tools | |
run: python3 -m pip install build twine | |
- name: Build source and wheel distributions | |
run: python3 -m build ./src | |
- name: Check distributions | |
run: twine check ./dist/* | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: built-python | |
path: ./dist | |
build-docs: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
with: | |
submodules: recursive # Fetch Hugo themes (true OR recursive) | |
fetch-depth: 1 # Fetch all history for .GitInfo and .Lastmod | |
# TODO: Need a unique key we can pass, but as we're targeting | |
# arcana@master, this is not trivial. | |
# | |
# - name: Cache dependencies | |
# uses: actions/cache@v1 | |
# with: | |
# path: ~/.local/lib | |
# key: ${{ runner.os }}-python-${{ hashFiles('**/package-lock.json') }} | |
# restore-keys: | | |
# ${{ runner.os }}-python- | |
- name: Setup Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.11' # Version range or exact version of a Python version to use, using SemVer' | |
- name: Install python dependencies | |
run: pip install -r ./requirements.txt | |
- name: Generate pipeline docs | |
run: arcana deploy make-docs specs/australian-imaging-service-community docs/pipelines --flatten --default-data-space arcana.common:Clinical | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: built-docs | |
path: docs/build/html | |
deploy-python: | |
needs: [build-python, build-docs] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download build | |
uses: actions/download-artifact@v3 | |
with: | |
name: built-main | |
path: dist | |
- name: Check for PyPI token on tag | |
id: deployable | |
if: github.event_name == 'release' | |
env: | |
PYPI_API_TOKEN: "${{ secrets.PYPI_API_TOKEN }}" | |
run: if [ -n "$PYPI_API_TOKEN" ]; then echo "DEPLOY=true" >> $GITHUB_OUTPUT; fi | |
- name: Upload to PyPI | |
if: steps.deployable.outputs.DEPLOY | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
build-deploy-pipelines: | |
needs: [deploy-python] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Remove unnecessary tools to free space | |
run: | | |
sudo rm -rf /usr/share/dotnet | |
sudo rm -rf "$AGENT_TOOLSDIRECTORY" | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Get release tag | |
run: | | |
git fetch --prune --unshallow | |
echo "RELEASE=`echo $(git describe --tags --abbrev=0)`" >> $GITHUB_ENV | |
- name: Unset header | |
# checkout@v2 adds a header that makes branch protection report errors | |
# because the Github action bot is not a collaborator on the repo | |
run: git config --local --unset http.https://github.com/.extraheader | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.11' | |
- name: Update build tools | |
run: python -m pip install --upgrade pip | |
- name: Install dependencies | |
run: pip install -r requirements.txt | |
- uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} # - must be in GitHub Secrets! | |
- name: Check for tagged release | |
id: deployable | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
run: echo "PUSH=--push" >> $GITHUB_ENV | |
- name: Build and push container images | |
run: > | |
arcana deploy make-app specs/australian-imaging-service-community xnat:XnatApp | |
--registry ghcr.io --check-registry --clean-up --tag-latest --loglevel info | |
--release pipelines-community-metapackage $RELEASE $PUSH | |
deploy-docs: | |
needs: [build-docs, build-deploy-pipelines] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download built docs | |
uses: actions/download-artifact@v3 | |
with: | |
name: built-docs | |
path: docs/build/html | |
- name: Remove /docs/pipelines/ from .gitignore | |
run: sed -i 's%^/docs/pipelines/\*$%%' .gitignore | |
- name: Check for GHPAGES_DEPLOY_KEY token on tag | |
id: deployable | |
if: github.event_name == 'release' | |
env: | |
GHPAGES_DEPLOY_KEY: "${{ secrets.GHPAGES_DEPLOY_KEY }}" | |
run: if [ -n "$GHPAGES_DEPLOY_KEY" ]; then echo "DEPLOY=true" >> $GITHUB_OUTPUT; fi | |
- name: Deploy docs | |
uses: peaceiris/actions-gh-pages@v3 | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: . | |
publish_branch: docs | |
enable_jekyll: true # This branch isn't actually fed to GH pages | |
# It's possible, likely even, that we'll trigger unnecessary docs | |
# rebuilds with this. Running this properly as a separate workflow | |
# only when real docs changes occur would require using a PAT. | |
- name: Trigger rebuild of docs | |
uses: peter-evans/repository-dispatch@v1 | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
with: | |
token: ${{ secrets.GITHUBPAGES_KEY }} | |
repository: Australian-Imaging-Service/Australian-Imaging-Service.github.io | |
event-type: Rebuild docs |