1- # TODO: check formatting
21# TODO: lock files on all platforms
32# TODO: test with all supported python versions
43name : CI
1514 type : boolean
1615 default : false
1716
17+ # Cancel superseded runs only for PR pushes (rapid commits to the same branch).
18+ # Never cancel push/tag/merge_group runs — a tag push drives the PyPI publish
19+ # steps below and a merge_group run backs a required check in the merge queue;
20+ # either could be silently aborted by an unrelated event sharing the ref.
21+ concurrency :
22+ group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
23+ cancel-in-progress : ${{ github.event_name == 'pull_request' }}
24+
1825defaults :
1926 run :
2027 shell : bash
2734jobs :
2835 build :
2936 runs-on : ${{ matrix.os }}
37+ timeout-minutes : 40
3038 strategy :
3139 fail-fast : false
32- max-parallel : 1
3340 matrix :
3441 os : [ubuntu-24.04, macos-15, windows-2022]
3542 include :
3643 - os : ubuntu-24.04
3744 name : Linux
45+ venv_bin : bin
3846 - os : macos-15
3947 name : macOS
48+ venv_bin : bin
4049 - os : windows-2022
4150 name : Windows
51+ venv_bin : Scripts
4252
4353 steps :
4454 - uses : actions/checkout@v5
@@ -53,32 +63,62 @@ jobs:
5363 with :
5464 python-version : ${{ env.DEV_WORKSPACE_PYTHON_VERSION }}
5565
66+ # Every package in the monorepo has its own .venvs/ (root dev_workspace plus one
67+ # per project for envs created by `prepare-envs`, e.g. dev_no_runtime, runtime).
68+ # Exact-match only (no restore-keys): setup-dev-workspace.sh and prepare-envs
69+ # skip reinstalling whenever a restored venv already looks valid, so a stale
70+ # partial-match restore could mask a dependency that was added since the cache
71+ # was written.
72+ - name : Cache all venvs
73+ uses : actions/cache@v4
74+ with :
75+ path : |
76+ .venvs
77+ **/.venvs
78+ key : ${{ runner.os }}-venvs-${{ hashFiles('**/pyproject.toml', '**/preset.toml') }}
79+
5680 - name : Install dependencies
5781 run : |
58- pipx run finecode bootstrap
59- source .venvs/dev_workspace/bin/activate
82+ # CI must exercise this branch's local source, so finecode and its sibling
83+ # packages need an editable install, not a released version from PyPI — see
84+ # docs/guides/developing-finecode.md#continuous-integration.
85+ sh scripts/setup-dev-workspace.sh
86+ source .venvs/dev_workspace/${{ matrix.venv_bin }}/activate
87+ shell : bash
88+
89+ - name : Inspect code
90+ if : ${{ !cancelled() }}
91+ run : |
92+ source .venvs/dev_workspace/${{ matrix.venv_bin }}/activate
93+ python -m finecode run inspect_code
94+ shell : bash
6095
61- python -m finecode prepare-envs
96+ - name : Audit code
97+ if : ${{ !cancelled() }}
98+ run : |
99+ source .venvs/dev_workspace/${{ matrix.venv_bin }}/activate
100+ python -m finecode run audit_code
62101 shell : bash
63102
64- - name : Lint
103+ - name : Check formatting
104+ if : ${{ !cancelled() }}
65105 run : |
66- source .venvs/dev_workspace/bin /activate
67- python -m finecode run lint
106+ source .venvs/dev_workspace/${{ matrix.venv_bin }} /activate
107+ python -m finecode run check_formatting
68108 shell : bash
69109
70110 - name : Build artifacts
71111 id : build
72- if : runner.os == 'Linux'
112+ if : runner.os == 'Linux' && !cancelled()
73113 run : |
74- source .venvs/dev_workspace/bin /activate
114+ source .venvs/dev_workspace/${{ matrix.venv_bin }} /activate
75115 python -m finecode run build_artifact
76116 shell : bash
77117
78118 - name : Run unit tests
79119 if : ${{ !cancelled() }}
80120 run : |
81- source .venvs/dev_workspace/bin /activate
121+ source .venvs/dev_workspace/${{ matrix.venv_bin }} /activate
82122 # TODO: test with all supported python versions
83123 python -m finecode run run_tests
84124 shell : bash
89129 FINECODE_CONFIG_PUBLISH_AND_VERIFY_ARTIFACT__INIT_REPOSITORY_PROVIDER__REPOSITORIES : ' [{"name": "testpypi", "url": "https://test.pypi.org/"}]'
90130 FINECODE_CONFIG_PUBLISH_AND_VERIFY_ARTIFACT__INIT_REPOSITORY_PROVIDER__CREDENTIALS_BY_REPOSITORY : ' {"testpypi": {"username": "${{ secrets.TESTPYPI_USERNAME }}", "password": "${{ secrets.TESTPYPI_PASSWORD }}"}}'
91131 run : |
92- source .venvs/dev_workspace/bin /activate
132+ source .venvs/dev_workspace/${{ matrix.venv_bin }} /activate
93133 python -m finecode run \
94134 --map-payload-fields="src-artifact-def-path,dist-artifact-paths" \
95135 publish_and_verify_artifact \
@@ -104,7 +144,7 @@ jobs:
104144 FINECODE_CONFIG_PUBLISH_AND_VERIFY_ARTIFACT__INIT_REPOSITORY_PROVIDER__CREDENTIALS_BY_REPOSITORY : ' {"pypi": {"username": "${{ secrets.PYPI_USERNAME }}", "password": "${{ secrets.PYPI_PASSWORD }}"}}'
105145 run : |
106146 # TODO: make sure git tag exists (for manual trigger)
107- source .venvs/dev_workspace/bin /activate
147+ source .venvs/dev_workspace/${{ matrix.venv_bin }} /activate
108148 python -m finecode run \
109149 --map-payload-fields="src-artifact-def-path,dist-artifact-paths" \
110150 publish_and_verify_artifact \
@@ -115,7 +155,7 @@ jobs:
115155
116156 # TODO: try to replace by finecode action
117157 - name : Store the distribution packages
118- uses : actions/upload-artifact@v4
158+ uses : actions/upload-artifact@v5
119159 if : runner.os == 'Linux'
120160 with :
121161 name : python-package-distributions
0 commit comments