Debian Codegraph @

.github/workflows/main.yml

raw symbols SCIP
1 # see https://github.com/karlicoss/pymplate for up-to-date reference
2
3 name: CI
4 on:
5 push:
6 branches: '*'
7 tags: 'v[0-9]+.*' # only trigger on 'release' tags for PyPi
8 # Ideally I would put this in the pypi job... but github syntax doesn't allow for regexes there :shrug:
9
10 # Needed to trigger on others' PRs.
11 # Note that people who fork it need to go to "Actions" tab on their fork and click "I understand my workflows, go ahead and enable them".
12 pull_request:
13
14 # Needed to trigger workflows manually.
15 workflow_dispatch:
16 inputs:
17 debug_enabled:
18 type: boolean
19 description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
20 required: false
21 default: false
22
23
24 jobs:
25 build:
26 strategy:
27 fail-fast: false
28 matrix:
29 platform: [ubuntu-latest, macos-latest, windows-latest]
30 python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
31 # vvv just an example of excluding stuff from matrix
32 # exclude: [{platform: macos-latest, python-version: '3.6'}]
33
34 runs-on: ${{ matrix.platform }}
35
36 # useful for 'optional' pipelines
37 # continue-on-error: ${{ matrix.platform == 'windows-latest' }}
38
39 steps:
40 # ugh https://github.com/actions/toolkit/blob/main/docs/commands.md#path-manipulation
41 - run: echo "$HOME/.local/bin" >> $GITHUB_PATH
42
43 - uses: actions/checkout@v5
44 with:
45 submodules: recursive
46 fetch-depth: 0 # nicer to have all git history when debugging/for tests
47
48 - uses: actions/setup-python@v6
49 with:
50 python-version: ${{ matrix.python-version }}
51
52 - uses: astral-sh/setup-uv@v7
53 with:
54 enable-cache: false # we don't have lock files, so can't use them as cache key
55
56 - uses: mxschmitt/action-tmate@v3
57 if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
58
59 # explicit bash command is necessary for Windows CI runner, otherwise it thinks it's cmd...
60 - run: bash .ci/run
61 env:
62 # only compute lxml coverage on ubuntu; it crashes on windows
63 CI_MYPY_COVERAGE: ${{ matrix.platform == 'ubuntu-latest' && '--cobertura-xml-report .coverage.mypy' || '' }}
64
65 - if: matrix.platform == 'ubuntu-latest' # no need to compute coverage for other platforms
66 uses: codecov/codecov-action@v5
67 with:
68 fail_ci_if_error: true # default false
69 token: ${{ secrets.CODECOV_TOKEN }}
70 flags: mypy-${{ matrix.python-version }}
71 files: .coverage.mypy/cobertura.xml
72
73
74 pypi:
75 # Do not run it for PRs/cron schedule etc.
76 # NOTE: release tags are guarded by on: push: tags on the top.
77 if: github.event_name == 'push' && (startsWith(github.event.ref, 'refs/tags/') || (github.event.ref == format('refs/heads/{0}', github.event.repository.master_branch)))
78 # Ugh, I tried using matrix or something to explicitly generate only test pypi or prod pypi pipelines.
79 # But github actions is so shit, it's impossible to do any logic at all, e.g. doesn't support conditional matrix, if/else statements for variables etc.
80
81 needs: [build] # add all other jobs here
82
83 runs-on: ubuntu-latest
84
85 permissions:
86 # necessary for Trusted Publishing
87 id-token: write
88
89 steps:
90 # ugh https://github.com/actions/toolkit/blob/main/docs/commands.md#path-manipulation
91 - run: echo "$HOME/.local/bin" >> $GITHUB_PATH
92
93 - uses: actions/checkout@v5
94 with:
95 submodules: recursive
96 fetch-depth: 0 # pull all commits to correctly infer vcs version
97
98 - uses: actions/setup-python@v6
99 with:
100 python-version: '3.10'
101
102 - uses: astral-sh/setup-uv@v7
103 with:
104 enable-cache: false # we don't have lock files, so can't use them as cache key
105
106 - name: 'release to test pypi'
107 # always deploy merged master to test pypi
108 if: github.event.ref == format('refs/heads/{0}', github.event.repository.master_branch)
109 run: .ci/release-uv --use-test-pypi
110
111 - name: 'release to prod pypi'
112 # always deploy tags to release pypi
113 if: startsWith(github.event.ref, 'refs/tags/')
114 run: .ci/release-uv