Repository navigation
69 lines (62 loc) · 2.93 KB
/
Copy pathpython-package.yml
File metadata and controls
69 lines (62 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python package
# `dev` is included deliberately. With main-only triggers the 3.10/3.11/3.12 matrix ran for
# the first time at the release gate, so a version incompatibility introduced on a dev PR was
# discovered with a whole release to bisect instead of a single commit. The cost is three jobs
# per dev PR; the alternative is finding out later, on a bigger diff.
on:
push:
branches: ["main", "dev"]
pull_request:
branches: ["main", "dev"]
# Cancel a superseded PR run so it stops competing for runners; never cancel a run on
# main/dev, where `github.event.pull_request.number` is unset and the group key falls
# back to the ref (#432).
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
# lint + test only; no write scopes needed
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install "ruff>=0.16,<0.17" pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with ruff
run: |
# stop the build if there are Python syntax errors or undefined names
ruff check . --select=E9,F63,F7,F82 --output-format=full
# formatting is enforced too: fails if `ruff format .` would change any file
ruff format --check .
# exit-zero treats all errors as warnings; --preview restores the pycodestyle
# whitespace rules ruff keeps behind preview; selection/width/complexity come
# from pyproject.toml
ruff check . --exit-zero --statistics --preview
- name: Test with pytest
run: |
# --require-round-trips fails the run if a @pytest.mark.round_trip(...) test
# (every non-hail-backed dataset's round trip runs in this default selection)
# ends skipped or xfailed, which a static check cannot see (#432).
pytest --require-round-trips
- name: Build docs (strict)
# The Deploy-docs workflow runs only on push to main and without
# --strict, so nothing checked the docs on a pull request. This does,
# and it is where a broken anchor or dead internal link surfaces.
run: |
python -m pip install mkdocs-material
mkdocs build --strict --site-dir /tmp/site-check