|
| 1 | +name: Checks |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + |
| 11 | +# Limit token permissions for security |
| 12 | +permissions: read-all |
| 13 | + |
| 14 | +jobs: |
| 15 | + check-python: |
| 16 | + # Permissions needed for pushing to the coverage branch. |
| 17 | + permissions: |
| 18 | + contents: write |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - name: Harden the runner (Audit all outbound calls) |
| 22 | + uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3 |
| 23 | + with: |
| 24 | + egress-policy: audit |
| 25 | + |
| 26 | + - name: Checkout repository |
| 27 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 28 | + |
| 29 | + - name: Install uv |
| 30 | + uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 |
| 31 | + with: |
| 32 | + enable-cache: true |
| 33 | + |
| 34 | + - name: Install justfile |
| 35 | + run: sudo apt-get install -y just |
| 36 | + |
| 37 | + - name: Install Python |
| 38 | + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 |
| 39 | + with: |
| 40 | + python-version-file: "pyproject.toml" |
| 41 | + |
| 42 | + - name: Install the project and it's dependencies |
| 43 | + run: just install-deps |
| 44 | + |
| 45 | + - name: Check Python style |
| 46 | + run: just check-python |
| 47 | + |
| 48 | + - name: Run tests and coverage |
| 49 | + run: just test-python |
| 50 | + |
| 51 | + - name: Prepare repo for coverage report |
| 52 | + run: | |
| 53 | + # So that folder can be committed |
| 54 | + rm htmlcov/.gitignore |
| 55 | +
|
| 56 | + - name: Push coverage report and badge to branch |
| 57 | + uses: JamesIves/github-pages-deploy-action@d92aa235d04922e8f08b40ce78cc5442fcfbfa2f # v4.8.0 |
| 58 | + with: |
| 59 | + branch: coverage |
| 60 | + folder: htmlcov |
| 61 | + # Keep a simple Git history |
| 62 | + single-commit: true |
| 63 | + |
| 64 | + - name: Run security checks |
| 65 | + run: just check-security |
| 66 | + |
| 67 | + - name: Run unused code checker |
| 68 | + run: just check-unused |
| 69 | + |
| 70 | + check-typos: |
| 71 | + runs-on: ubuntu-latest |
| 72 | + steps: |
| 73 | + # This is a useful security step to check for unexpected outbound calls from the runner, |
| 74 | + # which could indicate a compromised token or runner. |
| 75 | + - name: Harden the runner (Audit all outbound calls) |
| 76 | + uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 |
| 77 | + with: |
| 78 | + egress-policy: audit |
| 79 | + |
| 80 | + - name: Checkout repository |
| 81 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 82 | + |
| 83 | + - name: Spell check repo |
| 84 | + uses: crate-ci/typos@cf5f1c29a8ac336af8568821ec41919923b05a83 # v1.45.1 |
| 85 | + |
| 86 | + check-website-build: |
| 87 | + runs-on: ubuntu-latest |
| 88 | + env: |
| 89 | + QUARTO_PYTHON: ".venv/bin/python3" |
| 90 | + steps: |
| 91 | + # This is a useful security step to check for unexpected outbound calls from the runner, |
| 92 | + # which could indicate a compromised token or runner. |
| 93 | + - name: Harden the runner (Audit all outbound calls) |
| 94 | + uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3 |
| 95 | + with: |
| 96 | + egress-policy: audit |
| 97 | + |
| 98 | + - name: Check out repository |
| 99 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 100 | + |
| 101 | + - name: Install uv |
| 102 | + uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 |
| 103 | + with: |
| 104 | + # To have a faster CI time, enable cache between runs. |
| 105 | + enable-cache: true |
| 106 | + # Reset the cache if the lock file changes. |
| 107 | + cache-dependency-glob: "uv.lock" |
| 108 | + |
| 109 | + - name: "Set up Python" |
| 110 | + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 |
| 111 | + with: |
| 112 | + python-version-file: "pyproject.toml" |
| 113 | + |
| 114 | + - name: Install the project and it's dependencies |
| 115 | + run: | |
| 116 | + uv sync --all-extras --dev |
| 117 | + echo "$PWD/.venv/bin" >> "$GITHUB_PATH" |
| 118 | +
|
| 119 | + - name: Set up Quarto |
| 120 | + uses: quarto-dev/quarto-actions/setup@8a96df13519ee81fd526f2dfca5962811136661b # v2.2.0 |
| 121 | + |
| 122 | + - name: Build function reference docs |
| 123 | + run: uv run quartodoc build |
| 124 | + |
| 125 | + - name: Build function reference docs |
| 126 | + run: uvx quartodoc build |
| 127 | + |
| 128 | + # Check that the website builds, but don't publish it |
| 129 | + - name: Render Quarto Project |
| 130 | + uses: quarto-dev/quarto-actions/render@8a96df13519ee81fd526f2dfca5962811136661b # v2.2.0 |
| 131 | + |
| 132 | + # Dependency Review Action |
| 133 | + # |
| 134 | + # This Action will scan dependency manifest files that change as part of a Pull Request, |
| 135 | + # surfacing known-vulnerable versions of the packages declared or updated in the PR. |
| 136 | + # Once installed, if the workflow run is marked as required, |
| 137 | + # PRs introducing known-vulnerable packages will be blocked from merging. |
| 138 | + # |
| 139 | + # Source repository: https://github.com/actions/dependency-review-action |
| 140 | + check-dependencies: |
| 141 | + runs-on: ubuntu-latest |
| 142 | + steps: |
| 143 | + - name: Harden the runner (Audit all outbound calls) |
| 144 | + uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 |
| 145 | + with: |
| 146 | + egress-policy: audit |
| 147 | + |
| 148 | + - name: "Checkout Repository" |
| 149 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 150 | + |
| 151 | + - name: "Dependency Review" |
| 152 | + uses: actions/dependency-review-action@3c4e3dcb1aa7874d2c16be7d79418e9b7efd6261 # v4.8.2 |
0 commit comments