Recipe parametrisation #709
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
name: Pull request checks | |
on: | |
pull_request: | |
push: | |
branches: | |
- "main" | |
workflow_dispatch: | |
jobs: | |
tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.x" | |
- name: Get week number | |
id: week | |
run: echo "week=$(date '+W%V')" >> $GITHUB_OUTPUT | |
- uses: actions/cache@v3 | |
with: | |
key: tests|${{ runner.os }}-${{ runner.arch}}|${{ steps.week.outputs.week }}|${{ hashFiles('requirements/locks/*') }} | |
path: | | |
.tox | |
~/.cache/pip | |
- name: Install dependencies | |
run: python3 -m pip install tox tox-conda | |
- name: Run tests | |
env: | |
PY_COLORS: "1" | |
TOX_PARALLEL_NO_SPINNER: "1" | |
run: tox -e py39-linux-tests,py310-linux-tests,py311-linux-tests,py312-linux-tests | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-data | |
path: .coverage | |
retention-days: 1 | |
coverage-report: | |
if: github.event_name == 'pull_request' | |
runs-on: ubuntu-latest | |
needs: tests | |
permissions: | |
contents: read | |
pull-requests: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.x" | |
- name: Install dependencies | |
run: python3 -m pip install coverage | |
- uses: actions/download-artifact@v4 | |
with: | |
name: coverage-data | |
- name: Generate coverage report | |
run: 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 --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: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.x" | |
- name: Get week number | |
id: week | |
run: echo "week=$(date '+W%V')" >> $GITHUB_OUTPUT | |
- uses: actions/cache@v3 | |
with: | |
key: pre-commit|${{ env.pythonLocation }}|${{ steps.week.outputs.week }}|${{ hashFiles('.pre-commit-config.yaml') }} | |
path: | | |
~/.cache/pip | |
~/.cache/pre-commit | |
- name: Set up pre-commit | |
run: python3 -m pip install pre-commit | |
- name: Run pre-commit | |
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: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.x" | |
- name: Get week number | |
id: week | |
run: echo "week=$(date '+W%V')" >> $GITHUB_OUTPUT | |
- uses: actions/cache@v3 | |
with: | |
key: docs|${{ runner.os }}-${{ runner.arch}}|${{ steps.week.outputs.week }}|${{ hashFiles('requirements/locks/*') }} | |
path: | | |
.tox | |
~/.cache/pip | |
- name: Install dependencies | |
run: python3 -m pip install tox tox-conda | |
- name: Build documentation | |
run: tox -e py312-linux-docs | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: html-docs | |
path: docs/build/html/ | |
retention-days: 10 | |
if-no-files-found: error |