|
6 | 6 | branches: '*'
|
7 | 7 | tags: 'v[0-9]+.*' # only trigger on 'release' tags for PyPi
|
8 | 8 | # Ideally I would put this in the pypi job... but github syntax doesn't allow for regexes there :shrug:
|
9 |
| - pull_request: # needed to trigger on others' PRs |
| 9 | + |
| 10 | + # Needed to trigger on others' PRs. |
10 | 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".
|
11 |
| - workflow_dispatch: # needed to trigger workflows manually |
12 |
| - # todo cron? |
| 12 | + pull_request: |
| 13 | + |
| 14 | + # Needed to trigger workflows manually. |
| 15 | + workflow_dispatch: |
13 | 16 | inputs:
|
14 | 17 | debug_enabled:
|
15 | 18 | type: boolean
|
16 | 19 | description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
|
17 | 20 | required: false
|
18 | 21 | default: false
|
19 | 22 |
|
| 23 | + schedule: |
| 24 | + - cron: '31 18 * * 5' # run every Friday |
| 25 | + |
20 | 26 |
|
21 | 27 | jobs:
|
22 | 28 | build:
|
23 | 29 | strategy:
|
24 | 30 | fail-fast: false
|
25 | 31 | matrix:
|
26 |
| - platform: [ubuntu-latest, macos-latest] # todo windows-latest] |
| 32 | + platform: [ubuntu-latest, macos-latest, windows-latest] |
27 | 33 | python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
|
28 | 34 | # vvv just an example of excluding stuff from matrix
|
29 | 35 | # exclude: [{platform: macos-latest, python-version: '3.6'}]
|
@@ -55,44 +61,57 @@ jobs:
|
55 | 61 |
|
56 | 62 | # explicit bash command is necessary for Windows CI runner, otherwise it thinks it's cmd...
|
57 | 63 | - run: bash .ci/run
|
| 64 | + env: |
| 65 | + # only compute lxml coverage on ubuntu; it crashes on windows |
| 66 | + CI_MYPY_COVERAGE: ${{ matrix.platform == 'ubuntu-latest' && '--cobertura-xml-report .coverage.mypy' || '' }} |
58 | 67 |
|
59 | 68 | - if: matrix.platform == 'ubuntu-latest' # no need to compute coverage for other platforms
|
60 |
| - uses: actions/upload-artifact@v4 |
| 69 | + uses: codecov/codecov-action@v5 |
61 | 70 | with:
|
62 |
| - include-hidden-files: true |
63 |
| - name: .coverage.mypy_${{ matrix.platform }}_${{ matrix.python-version }} |
64 |
| - path: .coverage.mypy/ |
| 71 | + fail_ci_if_error: true # default false |
| 72 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 73 | + flags: mypy-${{ matrix.python-version }} |
| 74 | + files: .coverage.mypy/cobertura.xml |
65 | 75 |
|
66 | 76 |
|
67 | 77 | pypi:
|
68 |
| - runs-on: ubuntu-latest |
| 78 | + # Do not run it for PRs/cron schedule etc. |
| 79 | + # NOTE: release tags are guarded by on: push: tags on the top. |
| 80 | + if: github.event_name == 'push' && (startsWith(github.event.ref, 'refs/tags/') || (github.event.ref == format('refs/heads/{0}', github.event.repository.master_branch))) |
| 81 | + # Ugh, I tried using matrix or something to explicitly generate only test pypi or prod pypi pipelines. |
| 82 | + # 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. |
| 83 | + |
69 | 84 | needs: [build] # add all other jobs here
|
| 85 | + |
| 86 | + runs-on: ubuntu-latest |
| 87 | + |
70 | 88 | permissions:
|
71 | 89 | # necessary for Trusted Publishing
|
72 | 90 | id-token: write
|
| 91 | + |
73 | 92 | steps:
|
74 | 93 | # ugh https://github.com/actions/toolkit/blob/main/docs/commands.md#path-manipulation
|
75 | 94 | - run: echo "$HOME/.local/bin" >> $GITHUB_PATH
|
76 | 95 |
|
77 | 96 | - uses: actions/checkout@v4
|
78 | 97 | with:
|
79 | 98 | submodules: recursive
|
| 99 | + fetch-depth: 0 # pull all commits to correctly infer vcs version |
80 | 100 |
|
81 | 101 | - uses: actions/setup-python@v5
|
82 | 102 | with:
|
83 |
| - python-version: '3.10' |
| 103 | + python-version: '3.12' |
84 | 104 |
|
85 | 105 | - uses: astral-sh/setup-uv@v5
|
86 | 106 | with:
|
87 | 107 | enable-cache: false # we don't have lock files, so can't use them as cache key
|
88 | 108 |
|
89 | 109 | - name: 'release to test pypi'
|
90 | 110 | # always deploy merged master to test pypi
|
91 |
| - if: github.event_name != 'pull_request' && github.event.ref == 'refs/heads/master' |
| 111 | + if: github.event.ref == format('refs/heads/{0}', github.event.repository.master_branch) |
92 | 112 | run: .ci/release-uv --use-test-pypi
|
93 | 113 |
|
94 |
| - - name: 'release to pypi' |
| 114 | + - name: 'release to prod pypi' |
95 | 115 | # always deploy tags to release pypi
|
96 |
| - # NOTE: release tags are guarded by on: push: tags on the top |
97 |
| - if: github.event_name != 'pull_request' && startsWith(github.event.ref, 'refs/tags') |
| 116 | + if: startsWith(github.event.ref, 'refs/tags/') |
98 | 117 | run: .ci/release-uv
|
0 commit comments