Merge pull request #2427 from MetOffice/2426-add-global-lat-lon-cutou… #4291
This file contains hidden or 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 | |
| # Minimise default GITHUB_TOKEN permissions. | |
| permissions: {} | |
| defaults: | |
| run: | |
| # Use a login shell to pickup conda/micromamba initialisation. | |
| shell: bash -leo pipefail {0} | |
| jobs: | |
| tests: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| permissions: | |
| contents: read | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| py-ver: ["py312", "py313", "py314"] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 | |
| with: | |
| persist-credentials: false | |
| - name: Setup conda environment | |
| uses: mamba-org/setup-micromamba@ce51e99f4bb8a82ab7158c4dc59ef4634c59c4f9 | |
| with: | |
| environment-name: cset-dev | |
| environment-file: requirements/locks/${{ matrix.py-ver }}-lock-linux-64.txt | |
| cache-environment: true | |
| - name: Cache downloaded cartopy shapefiles | |
| uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 | |
| with: | |
| key: cartopy-shapefiles | |
| path: ~/.local/share/cartopy | |
| - name: Install local package | |
| run: pip install --no-deps . | |
| - name: Run fast tests | |
| env: | |
| PY_COLORS: "1" | |
| py_ver: ${{ matrix.py-ver }} | |
| run: | | |
| make test-fast | |
| mv .coverage ".coverage.${py_ver}" | |
| - name: Upload coverage data as artifact | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a | |
| with: | |
| name: coverage-data-${{ matrix.py-ver }} | |
| path: .coverage.* | |
| retention-days: 1 | |
| include-hidden-files: true | |
| test-workflow: | |
| name: Test cylc workflow | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 | |
| with: | |
| persist-credentials: false | |
| - name: Setup conda environment | |
| uses: mamba-org/setup-micromamba@ce51e99f4bb8a82ab7158c4dc59ef4634c59c4f9 | |
| with: | |
| environment-name: cset-dev | |
| environment-file: requirements/locks/latest | |
| cache-environment: true | |
| - name: Cache downloaded cartopy shapefiles | |
| uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 | |
| with: | |
| key: cartopy-shapefiles | |
| path: ~/.local/share/cartopy | |
| - name: Install local package | |
| run: pip install --no-deps . | |
| - name: Setup rose and cylc | |
| uses: cylc/setup-cylc@813acd1873cef608f14e354cec57e2de5a7eb3bf | |
| with: | |
| cylc_rose: true | |
| - name: Run workflow tests | |
| env: | |
| PY_COLORS: "1" | |
| run: make test-workflow | |
| coverage-report: | |
| if: github.event_name == 'pull_request' | |
| name: Produce coverage report | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| needs: tests | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 | |
| with: | |
| persist-credentials: false | |
| - name: Setup python | |
| uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 | |
| with: | |
| python-version: "3.x" | |
| - name: Install coverage | |
| run: pip install coverage | |
| - name: Download coverage artifact | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c | |
| 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 }} | |
| tmpweb_api_key: ${{ secrets.TMPWEB_API_KEY }} | |
| repository: ${{ github.repository }} | |
| head_ref: ${{ github.head_ref }} | |
| run: | | |
| # Host the HTML report. | |
| tar -czf coverage-report.tar.gz htmlcov/ | |
| report_url="$(curl -sSf --user "token:${tmpweb_api_key}" --data-binary @coverage-report.tar.gz https://tmpweb.net || true)" | |
| if [[ -z "${report_url}" ]] ; then | |
| echo "Could not upload report." | |
| report_html="" | |
| else | |
| echo "Report hosted at ${report_url}" | |
| report_html="(<a href=\"${report_url}\">HTML report</a>)" | |
| fi | |
| percent_coverage="$(coverage json --fail-under=0 -qo - | jq -r .totals.percent_covered_display)" | |
| # Write coverage report. | |
| cat <<- EOF > cov-report.md | |
| <details> | |
| <summary> | |
| Total coverage: <strong>${percent_coverage}%</strong> | |
| ${report_html} | |
| </summary> | |
| <pre> | |
| $(coverage report) | |
| </pre> | |
| </details> | |
| EOF | |
| # Edit last comment if it exists, else create new one. | |
| if ! gh pr comment --repo "${repository}" --edit-last --create-if-none "${head_ref}" --body-file cov-report.md ; then | |
| echo "Failed to post comment. This is likely due to this being a PR from a fork." | |
| fi | |
| # Add report as job summary. | |
| cat cov-report.md > "${GITHUB_STEP_SUMMARY}" | |
| - name: Check 90% minimum coverage | |
| run: coverage report --fail-under=90 | |
| pre-commit: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 | |
| with: | |
| persist-credentials: false | |
| - name: Set up Python | |
| uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 | |
| with: | |
| python-version: "3.x" | |
| - name: Restore pre-commit cache | |
| uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 | |
| 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: 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: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 | |
| with: | |
| persist-credentials: false | |
| - name: Setup conda environment | |
| uses: mamba-org/setup-micromamba@ce51e99f4bb8a82ab7158c4dc59ef4634c59c4f9 | |
| with: | |
| environment-name: cset-dev | |
| environment-file: requirements/locks/latest | |
| cache-environment: true | |
| - name: Install local package | |
| run: pip install --no-deps . | |
| - name: Build documentation with Sphinx | |
| run: make docs | |
| - name: Upload documentation artifact | |
| uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 | |
| with: | |
| path: docs/build/html/ | |
| retention-days: 1 | |
| pages-deploy: | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| name: Deploy documentation to GitHub Pages | |
| permissions: | |
| pages: write | |
| id-token: write | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-slim | |
| timeout-minutes: 5 | |
| needs: build-docs | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 |