Skip to content

Calculate wind vector speed and direction from U and V compts #3226

Calculate wind vector speed and direction from U and V compts

Calculate wind vector speed and direction from U and V compts #3226

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: {}
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
persist-credentials: false
- name: Cache conda environment
id: conda-env-cache
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae
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'
env:
py_ver: ${{ matrix.py-ver }}
run: |
# Check cache hasn't pulled a partial key match.
test ! -e "${HOME}/conda-env"
conda create --prefix="${HOME}/conda-env" --file=requirements/locks/${py_ver}-lock-linux-64.txt
- name: Add conda environment to PATH
run: echo "${HOME}/conda-env/bin" >> $GITHUB_PATH
- 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
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
persist-credentials: false
- name: Setup python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
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: |
# This links to a hosted version of 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."
else
echo "Report hosted at $report_url"
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})" >> cov-report.md
# 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
fi
- 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@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
with:
python-version: "3.x"
- name: Restore pre-commit cache
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
persist-credentials: false
- name: Cache conda environment
id: conda-env-cache
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae
with:
key: conda|${{runner.os}}-${{runner.arch}}|${{hashFiles('requirements/locks/latest')}}
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/latest
- name: Add conda environment to PATH
run: echo "${HOME}/conda-env/bin" >> $GITHUB_PATH
- name: Install package so it can be imported during docs generation
run: pip install --no-deps .
- name: Build documentation with Sphinx
run: sphinx-build -b html --color "docs/source" "docs/build/html"
- 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