Add age of air diagnostic functionality #1730
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
name: Pull request checks | |
on: | |
pull_request: | |
push: | |
branches: | |
- "main" | |
workflow_dispatch: | |
# Cancel running pull request checks if another commit is pushed. | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
tests: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
py-ver: ["py310", "py311", "py312", "py313"] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | |
- name: Cache conda environment | |
id: conda-env-cache | |
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a | |
with: | |
key: conda|${{runner.os}}-${{runner.arch}}|${{ hashFiles(format('requirements/locks/{0}-lock-linux-64.txt', matrix.py-ver)) }} | |
path: | | |
~/conda-env | |
~/.local/share/cartopy | |
- name: Create conda environment | |
if: steps.conda-env-cache.outputs.cache-hit != 'true' | |
run: | | |
# Check cache hasn't pulled a partial key match. | |
test ! -e "${HOME}/conda-env" | |
conda create --prefix="${HOME}/conda-env" --file=requirements/locks/${{ matrix.py-ver }}-lock-linux-64.txt | |
- name: Add conda environment to PATH | |
run: echo "${HOME}/conda-env/bin" >> $GITHUB_PATH | |
- name: Run tests | |
env: | |
PY_COLORS: "1" | |
run: | | |
# Install package and run pytest. | |
echo '::group::Installing local package' | |
python3 -m pip install -e . | |
echo '::endgroup::' | |
pytest --verbose --cov --cov-append --cov-config=pyproject.toml | |
mv .coverage ".coverage.${{ matrix.py-ver }}" | |
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 | |
with: | |
name: coverage-data-${{ matrix.py-ver }} | |
path: .coverage.* | |
retention-days: 1 | |
include-hidden-files: true | |
coverage-report: | |
if: github.event_name == 'pull_request' | |
runs-on: ubuntu-latest | |
needs: tests | |
permissions: | |
contents: read | |
pull-requests: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | |
- name: Setup python | |
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b | |
with: | |
python-version: "3.x" | |
- name: Install coverage | |
run: python3 -m pip install coverage | |
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 | |
with: | |
pattern: coverage-data-* | |
merge-multiple: true | |
- name: Generate coverage report | |
run: | | |
coverage combine | |
coverage html | |
- name: Add report to PR | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
# This links to a hosted version of the HTML report. | |
tar -czf coverage-report.tar.gz htmlcov/ | |
report_url="$(curl -sSf --data-binary @coverage-report.tar.gz https://tmpweb.net)" | |
badge_options="$(coverage json --fail-under=0 -qo - | jq -r .totals.percent_covered_display)%25-blue?style=for-the-badge" | |
echo "[![Coverage](https://img.shields.io/badge/coverage-${badge_options})](${report_url})" >> ${{ runner.temp }}/cov-report.md | |
# Edit last comment if it exists, else create new one. | |
if ! gh pr comment --edit-last ${{ github.head_ref }} --body-file ${{ runner.temp }}/cov-report.md ; then | |
gh pr comment ${{ github.head_ref }} --body-file ${{ runner.temp }}/cov-report.md | |
fi | |
- name: Check 95% minimum coverage | |
run: coverage report --fail-under=95 | |
pre-commit: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | |
- name: Set up Python | |
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b | |
with: | |
python-version: "3.x" | |
- uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a | |
with: | |
key: pre-commit|${{runner.os}}-${{runner.arch}}|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} | |
path: ~/.cache/pre-commit | |
- name: Set up pre-commit | |
run: python3 -m pip install pre-commit | |
- name: Run pre-commit | |
env: | |
RUFF_OUTPUT_FORMAT: github | |
run: pre-commit run --show-diff-on-failure --color=always --all-files | |
build-docs: | |
if: github.event_name == 'pull_request' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | |
- name: Cache conda environment | |
id: conda-env-cache | |
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a | |
with: | |
key: conda|${{runner.os}}-${{runner.arch}}|${{hashFiles('requirements/locks/py312-lock-linux-64.txt')}} | |
path: | | |
~/conda-env | |
~/.local/share/cartopy | |
- name: Create conda environment | |
if: steps.conda-env-cache.outputs.cache-hit != 'true' | |
run: | | |
# Check cache hasn't pulled a partial key match. | |
test ! -e "${HOME}/conda-env" | |
conda create --prefix="${HOME}/conda-env" --file=requirements/locks/py312-lock-linux-64.txt | |
- name: Add conda environment to PATH | |
run: echo "${HOME}/conda-env/bin" >> $GITHUB_PATH | |
- name: Build documentation with Sphinx | |
run: | | |
# Install module so it can be imported during docs generation. | |
echo '::group::Installing local package' | |
python3 -m pip install . | |
echo '::endgroup::' | |
# Generate the documentation | |
echo '::group::Building the documentation' | |
sphinx-build -b html --color -W --keep-going "docs/source" "docs/build/html" | |
echo '::endgroup::' | |
- name: Upload documentation artifact | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 | |
with: | |
name: html-docs | |
path: docs/build/html/ | |
retention-days: 10 | |
if-no-files-found: error |