| 1 |
# This workflow runs our usual CI jobs: testing with pytest, profiling, |
| 2 |
# and coverage checks for PST |
| 3 |
# IMPORTANT: if you make changes to this workflow, you will need to open a follow-up |
| 4 |
# PR after merge to update the action SHA in the publish workflow |
| 5 |
|
| 6 |
name: continuous-integration |
| 7 |
|
| 8 |
# Concurrency group that uses the workflow name and PR number if available |
| 9 |
# or commit SHA as a fallback. If a new build is triggered under that |
| 10 |
# concurrency group while a previous build is running it will be canceled. |
| 11 |
# Repeated pushes to a PR will cancel all previous builds, while multiple |
| 12 |
# merges to main will not cancel. |
| 13 |
concurrency: |
| 14 |
group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} |
| 15 |
cancel-in-progress: true |
| 16 |
|
| 17 |
env: |
| 18 |
FORCE_COLOR: "1" # Make tools pretty |
| 19 |
DEFAULT_PYTHON_VERSION: "3.14" # keep in sync with tox.ini |
| 20 |
PIP_DISABLE_PIP_VERSION_CHECK: "1" # Don't check for pip updates |
| 21 |
|
| 22 |
permissions: {} |
| 23 |
|
| 24 |
on: |
| 25 |
push: |
| 26 |
branches: |
| 27 |
- main |
| 28 |
pull_request: |
| 29 |
branches: |
| 30 |
- "*" |
| 31 |
# allows this to be used as a composite action in other workflows |
| 32 |
workflow_call: |
| 33 |
# allow manual triggering of the workflow, while debugging |
| 34 |
workflow_dispatch: |
| 35 |
|
| 36 |
jobs: |
| 37 |
# Run our test suite on various combinations of OS & Python versions |
| 38 |
run-pytest: |
| 39 |
strategy: |
| 40 |
fail-fast: true |
| 41 |
matrix: |
| 42 |
# https://github.com/actions/runner-images |
| 43 |
# macos-14==latest |
| 44 |
# ubuntu-24.04==latest |
| 45 |
# windows-2022==latest |
| 46 |
os: ["ubuntu-latest", "ubuntu-22.04", "macos-14", "windows-latest"] |
| 47 |
python-version: ["3.10", "3.14"] |
| 48 |
sphinx-version: [""] |
| 49 |
include: |
| 50 |
# oldest Python version with the oldest Sphinx version |
| 51 |
- os: ubuntu-latest |
| 52 |
python-version: "3.10" |
| 53 |
sphinx-version: "7.0" |
| 54 |
# newest Python version with the newest Sphinx version |
| 55 |
- os: ubuntu-latest |
| 56 |
python-version: "3.14" |
| 57 |
# Sphinx HEAD |
| 58 |
sphinx-version: "dev" |
| 59 |
exclude: |
| 60 |
# Python 3.10 is not supported on arm64 darwin - https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json |
| 61 |
- os: macos-14 |
| 62 |
python-version: "3.10" |
| 63 |
# do not need all the tests so will limit to the latest versions of Python |
| 64 |
- os: ubuntu-24.04 |
| 65 |
python-version: "3.10" |
| 66 |
- os: ubuntu-24.04 |
| 67 |
python-version: "3.10" |
| 68 |
runs-on: ${{ matrix.os }} |
| 69 |
steps: |
| 70 |
- name: "Checkout repository 🛎" |
| 71 |
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd |
| 72 |
with: |
| 73 |
persist-credentials: false |
| 74 |
|
| 75 |
- name: "Setup CI environment 🛠" |
| 76 |
# Important: make sure to update the SHA after making any changes to the set-dev-env action |
| 77 |
uses: pydata/pydata-sphinx-theme/.github/actions/set-dev-env@e8db643b990df73812cf9397bc0f8cfa1164e4d3 |
| 78 |
with: |
| 79 |
python-version: ${{ matrix.python-version }} |
| 80 |
pandoc: true |
| 81 |
|
| 82 |
- name: "Cache Playwright browsers 🎭" |
| 83 |
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 |
| 84 |
with: |
| 85 |
path: | |
| 86 |
~/.cache/ms-playwright |
| 87 |
~/Library/Caches/ms-playwright |
| 88 |
~\AppData\Local\ms-playwright |
| 89 |
key: playwright-${{ runner.os }}-${{ hashFiles('pyproject.toml') }} |
| 90 |
|
| 91 |
- name: "Run tests" |
| 92 |
shell: bash |
| 93 |
run: | |
| 94 |
# this will compile the assets and translations then run the tests |
| 95 |
# check if there is a specific Sphinx version to test with |
| 96 |
# example substitution: tox run -e compile-assets,i18n-compile,py310-sphinx61-tests |
| 97 |
if [ -n "${{matrix.sphinx-version}}" ]; then |
| 98 |
python -Im tox run -e compile-assets,i18n-compile,py$(echo ${{ matrix.python-version }} | tr -d .)-sphinx$(echo ${{ matrix.sphinx-version }} | tr -d .)-tests |
| 99 |
# if not we use the default version |
| 100 |
# example substitution: tox run -e compile-assets,i18n-compile,py310-tests |
| 101 |
else |
| 102 |
python -Im tox run -e compile-assets,i18n-compile,py$(echo ${{ matrix.python-version }} | tr -d .)-tests |
| 103 |
fi |
| 104 |
|
| 105 |
- name: "Upload coverage data to GH artifacts 📤" |
| 106 |
if: matrix.python-version == '3.14' && matrix.os == 'ubuntu-latest' && matrix.sphinx-version == 'dev' |
| 107 |
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f |
| 108 |
with: |
| 109 |
name: coverage-data-${{ matrix.python-version }} |
| 110 |
path: .coverage |
| 111 |
if-no-files-found: ignore |
| 112 |
include-hidden-files: true |
| 113 |
|
| 114 |
- name: "Upload Playwright traces, if any 🐾" |
| 115 |
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v4.7.0.0 |
| 116 |
if: ${{ failure() }} |
| 117 |
with: |
| 118 |
name: playwright-traces-${{ matrix.os }}-${{ matrix.python-version }} |
| 119 |
path: test-results/ |
| 120 |
|
| 121 |
coverage: |
| 122 |
name: "check coverage" |
| 123 |
needs: run-pytest |
| 124 |
runs-on: ubuntu-latest |
| 125 |
# avoid running this on schedule, releases, workflow_call, or workflow_dispatch |
| 126 |
if: github.event_name != 'schedule' && github.event_name != 'release' && github.event_name != 'workflow_call' && github.event_name != 'workflow_dispatch' |
| 127 |
permissions: |
| 128 |
contents: write |
| 129 |
pull-requests: write |
| 130 |
steps: |
| 131 |
- name: "Checkout repository 🛎" |
| 132 |
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd |
| 133 |
with: |
| 134 |
persist-credentials: false |
| 135 |
|
| 136 |
- name: "Setup CI environment 🛠" |
| 137 |
uses: pydata/pydata-sphinx-theme/.github/actions/set-dev-env@e8db643b990df73812cf9397bc0f8cfa1164e4d3 |
| 138 |
with: |
| 139 |
python-version: ${{ env.DEFAULT_PYTHON_VERSION }} |
| 140 |
|
| 141 |
- run: python -Im pip install --upgrade coverage[toml] |
| 142 |
|
| 143 |
- name: "Download coverage data 📥" |
| 144 |
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c |
| 145 |
with: |
| 146 |
pattern: coverage-data-* |
| 147 |
merge-multiple: true |
| 148 |
|
| 149 |
- name: "Get coverage data & fail if it's <80%" |
| 150 |
run: | |
| 151 |
# if we decide to check cov across versions and combine |
| 152 |
# python -Im coverage combine |
| 153 |
python -Im coverage html --skip-covered --skip-empty |
| 154 |
|
| 155 |
# report and write to summary. |
| 156 |
python -Im coverage report --format=markdown >> $GITHUB_STEP_SUMMARY |
| 157 |
|
| 158 |
# report again and fail if under 80%. |
| 159 |
python -Im coverage report --fail-under=80 |
| 160 |
|
| 161 |
- name: "Upload HTML report if check failed 📤" |
| 162 |
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f |
| 163 |
with: |
| 164 |
name: html-report |
| 165 |
path: htmlcov |
| 166 |
if: ${{ failure() }} |
| 167 |
|
| 168 |
# seems we need to call this from the main CI workflow first |
| 169 |
- name: "Coverage comment 💬" |
| 170 |
uses: py-cov-action/python-coverage-comment-action@7188638f871f721a365d644f505d1ff3df20d683 # 3.38.0 |
| 171 |
id: coverage_comment |
| 172 |
with: |
| 173 |
GITHUB_TOKEN: ${{ github.token }} |
| 174 |
|
| 175 |
- name: "Store Pull Request comment to be posted 📤" |
| 176 |
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f |
| 177 |
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true' |
| 178 |
with: |
| 179 |
# leave default names |
| 180 |
name: python-coverage-comment-action |
| 181 |
path: python-coverage-comment-action.txt |
| 182 |
|
| 183 |
profiling: |
| 184 |
needs: [run-pytest] |
| 185 |
runs-on: ubuntu-latest |
| 186 |
steps: |
| 187 |
- name: "Checkout repository 🛎" |
| 188 |
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd |
| 189 |
with: |
| 190 |
persist-credentials: false |
| 191 |
|
| 192 |
- name: "Setup CI environment 🛠" |
| 193 |
uses: pydata/pydata-sphinx-theme/.github/actions/set-dev-env@e8db643b990df73812cf9397bc0f8cfa1164e4d3 |
| 194 |
with: |
| 195 |
# 3.14 is not supported by py-spy yet |
| 196 |
python-version: "3.13" |
| 197 |
|
| 198 |
- name: "Run profiling with py-spy 🕵️♂️" |
| 199 |
# profiling needs to be run as sudo |
| 200 |
run: python -m tox run -e py313-profile-docs -- -o docbuild_profile.svg |
| 201 |
continue-on-error: true |
| 202 |
|
| 203 |
- name: "Upload profiling data to GH artifacts 📤" |
| 204 |
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f |
| 205 |
with: |
| 206 |
name: profile-results |
| 207 |
path: docbuild_profile.svg |
| 208 |
if-no-files-found: ignore |
| 209 |
|
| 210 |
# Calling the coverage-comment action from the main CI workflow |
| 211 |
# we might want to pin the SHA once merged |
| 212 |
coverage-comment: |
| 213 |
# Important: make sure to update the SHA after making any changes to the coverage workflow |
| 214 |
# removing pin to test changes |
| 215 |
uses: ./.github/workflows/coverage.yml |
| 216 |
needs: [coverage] |
| 217 |
# ensures this runs even if the coverage step does not continue - e.g. the |
| 218 |
# default coverage action will fail at first for external PRs, this is a workaround |
| 219 |
# to ensure the comment is posted |
| 220 |
if: ${{ github.event.name == 'pull_request'}} |
| 221 |
with: |
| 222 |
# this is the workflow run ID of the `CI.yml` workflow |
| 223 |
workflow_run_id: ${{ github.event.workflow_run.id }} |
| 224 |
permissions: |
| 225 |
contents: write |
| 226 |
pull-requests: write |
| 227 |
actions: read |