Debian Codegraph @

.github/workflows/tests.yaml

raw symbols SCIP
1 # Regular tests
2 #
3 # Use this to ensure your tests are passing on every push and PR (skipped on
4 # pushes which only affect documentation).
5 #
6 # You should make sure you run jobs on at least the *oldest* and the *newest*
7 # versions of python that your codebase is intended to support.
8
9 name: tests
10
11 on:
12 push:
13 branches:
14 - main
15 pull_request:
16
17 jobs:
18 test:
19 timeout-minutes: 45
20 defaults:
21 run:
22 shell: bash
23 runs-on: ${{ matrix.os }}
24 strategy:
25 fail-fast: false
26 matrix:
27 os: [ubuntu-latest, ubuntu-24.04-arm, macos-15, windows-latest]
28 python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
29 env:
30 OS: ${{ matrix.os }}
31 PYTHON: ${{ matrix.python-version }}
32
33 steps:
34 - name: Set OS Environment Variables (Windows)
35 if: runner.os == 'Windows'
36 run: |
37 echo 'ACTIVATE_PYTHON_VENV=.venv/scripts/activate' >> $GITHUB_ENV
38
39 - name: Set OS Environment Variables (not Windows)
40 if: runner.os != 'Windows'
41 run: |
42 echo 'ACTIVATE_PYTHON_VENV=.venv/bin/activate' >> $GITHUB_ENV
43
44 - name: Install zsh and fish (Linux)
45 if: runner.os == 'Linux'
46 run: sudo apt-get update && sudo apt-get install -y zsh fish
47
48 - name: Install fish (macOS)
49 if: runner.os == 'macOS'
50 run: brew install fish
51
52 - name: Check out repository
53 uses: actions/checkout@v4
54 with:
55 fetch-depth: 0 # Needed for hatch-vcs to get version from git tags
56
57 - name: Install uv
58 uses: astral-sh/setup-uv@v5
59 with:
60 enable-cache: true
61
62 - name: Set up python ${{ matrix.python-version }}
63 id: setup-python
64 run: uv python install ${{ matrix.python-version }}
65
66 - name: Install library
67 run: uv sync --all-extras
68
69 - name: Cache pre-commit
70 uses: actions/cache@v4
71 with:
72 path: ~/.cache/pre-commit/
73 key: pre-commit-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('.pre-commit-config.yaml') }}
74
75 - name: Pre-commit run
76 run: uv run pre-commit run --show-diff-on-failure --color=always --all-files
77
78 - name: Check tests folder existence
79 id: check_test_files
80 uses: andstor/file-existence-action@v3
81 with:
82 files: "tests"
83
84 - name: Run tests
85 if: steps.check_test_files.outputs.files_exists == 'true'
86 run: |
87 uv run pytest --run-slow --cov=cyclopts --cov-config=pyproject.toml --cov-report term --cov-report xml --junitxml=testresults.xml
88 uv run coverage report
89
90 - name: Upload coverage to Codecov
91 if: steps.check_test_files.outputs.files_exists == 'true'
92 uses: codecov/codecov-action@v4
93 with:
94 token: ${{ secrets.CODECOV_TOKEN }}
95 flags: unittests
96 env_vars: OS,PYTHON
97 name: Python ${{ matrix.python-version }} on ${{ runner.os }}
98
99 #----------------------------------------------
100 # make sure docs build
101 #----------------------------------------------
102 - name: Build HTML docs
103 run: uv run sphinx-build -b html -W docs/source/ docs/build/html