-
Notifications
You must be signed in to change notification settings - Fork 7
336 lines (289 loc) · 11.8 KB
/
Copy pathpython_build.yaml
File metadata and controls
336 lines (289 loc) · 11.8 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
name: Develop Branch Action
on:
pull_request_target:
types:
- opened
- synchronize
- reopened
branches:
- dev
paths:
- 'unoplat-code-confluence-commons/**'
- 'unoplat-code-confluence-ingestion/**'
- 'unoplat-code-confluence-query-engine/**'
- 'unoplat-code-confluence-cli/**'
concurrency:
group: develop-branch-action-${{ github.event.pull_request.head.repo.full_name || github.repository }}-${{ github.event.pull_request.head.ref || github.ref }}
cancel-in-progress: true
jobs:
detect-changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
commons: ${{ steps.filter.outputs.commons }}
flow-bridge: ${{ steps.filter.outputs.flow-bridge }}
query-engine: ${{ steps.filter.outputs.query-engine }}
cli: ${{ steps.filter.outputs.cli }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 100
- name: Detect changed files
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
commons:
- 'unoplat-code-confluence-commons/**'
flow-bridge:
- 'unoplat-code-confluence-ingestion/code-confluence-flow-bridge/**'
query-engine:
- 'unoplat-code-confluence-query-engine/**'
cli:
- 'unoplat-code-confluence-cli/**'
refresh-release-pr-lockfiles:
needs: detect-changes
if: ${{ (needs.detect-changes.outputs.flow-bridge == 'true' || needs.detect-changes.outputs.query-engine == 'true' || needs.detect-changes.outputs.cli == 'true') && github.event.pull_request.head.repo.full_name == github.repository }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout PR branch
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.PAT }}
persist-credentials: true
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Refresh flow-bridge lockfile
if: needs.detect-changes.outputs.flow-bridge == 'true'
working-directory: unoplat-code-confluence-ingestion/code-confluence-flow-bridge
env:
GITHUB_PAT_TOKEN: ${{ secrets.PAT }}
run: uv lock
- name: Refresh query-engine lockfile
if: needs.detect-changes.outputs.query-engine == 'true'
working-directory: unoplat-code-confluence-query-engine
env:
GITHUB_PAT_TOKEN: ${{ secrets.PAT }}
run: uv lock
- name: Refresh CLI lockfile
if: needs.detect-changes.outputs.cli == 'true'
working-directory: unoplat-code-confluence-cli
env:
GITHUB_PAT_TOKEN: ${{ secrets.PAT }}
run: uv lock
- name: Commit refreshed lockfiles
shell: bash
run: |
git add -- \
unoplat-code-confluence-ingestion/code-confluence-flow-bridge/uv.lock \
unoplat-code-confluence-query-engine/uv.lock \
unoplat-code-confluence-cli/uv.lock
if git diff --cached --quiet; then
echo "No lockfile changes to commit."
exit 0
fi
git -c user.name="github-actions[bot]" -c user.email="41898282+github-actions[bot]@users.noreply.github.com" \
commit -m "fix(ci): refresh package uv lockfiles before python lock checks run"
git push origin "HEAD:${{ github.event.pull_request.head.ref }}"
build-commons:
needs: detect-changes
if: ${{ needs.detect-changes.outputs.commons == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
- name: Install python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Install dependencies
working-directory: unoplat-code-confluence-commons
run: uv sync
- name: Build package
working-directory: unoplat-code-confluence-commons
run: uv build
build-cli:
needs:
- detect-changes
- refresh-release-pr-lockfiles
if: ${{ needs.detect-changes.outputs.cli == 'true' && (needs.refresh-release-pr-lockfiles.result == 'success' || needs.refresh-release-pr-lockfiles.result == 'skipped') }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- name: Install python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Check lockfile freshness
working-directory: unoplat-code-confluence-cli
run: uv lock --check
- name: Install dependencies
working-directory: unoplat-code-confluence-cli
run: uv sync --group dev
- name: Type check
working-directory: unoplat-code-confluence-cli
run: uv run pyrefly check
- name: Build package
working-directory: unoplat-code-confluence-cli
run: uv build
test-flow-bridge:
needs:
- detect-changes
- refresh-release-pr-lockfiles
if: ${{ (needs.detect-changes.outputs.flow-bridge == 'true' || needs.detect-changes.outputs.commons == 'true') && (needs.refresh-release-pr-lockfiles.result == 'success' || needs.refresh-release-pr-lockfiles.result == 'skipped') }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install uv
uses: astral-sh/setup-uv@v5
# 1) Always ensure the Compose v2 plugin is present
- name: Set up Docker Compose (v2)
uses: docker/setup-compose-action@v1
# pin a version if you need repeatability:
# with:
# version: '2.37.0'
# 2) Drop in a shim so legacy tools that expect `docker-compose`
# still work (but use v2 under the hood)
- name: Provide docker-compose wrapper for compatibility
shell: bash
run: |
if ! command -v docker-compose >/dev/null; then
echo 'Creating docker-compose wrapper ➜ docker compose "$@"'
sudo install -d /usr/local/bin
printf '#!/usr/bin/env bash\nexec docker compose "$@"\n' | \
sudo tee /usr/local/bin/docker-compose >/dev/null
sudo chmod +x /usr/local/bin/docker-compose
fi
docker compose version
docker-compose version # should output the same version
- name: Install Ruff
run: curl -LsSf https://astral.sh/ruff/install.sh | sh
- name: Install ripgrep
run: |
sudo apt-get update
sudo apt-get install -y ripgrep
- name: Get package name for coverage
working-directory: unoplat-code-confluence-ingestion/code-confluence-flow-bridge
id: package
run: |
# Extract project name from pyproject.toml and convert hyphens to underscores
PACKAGE_NAME=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['name'].replace('-', '_'))")
echo "name=$PACKAGE_NAME" >> $GITHUB_OUTPUT
- name: Check lockfile freshness
working-directory: unoplat-code-confluence-ingestion/code-confluence-flow-bridge
run: uv lock --check
- name: Install dependencies and run tests
working-directory: unoplat-code-confluence-ingestion/code-confluence-flow-bridge
env:
GITHUB_PAT_TOKEN: ${{ github.token }}
run: |
uv sync --group test
uv run --group test pytest --cov=src/${{ steps.package.outputs.name }} --cov-report=html:coverage_reports --cov-report=xml:coverage.xml --cov-report=term-missing tests/ -v
- name: Upload coverage reports
uses: actions/upload-artifact@v4
with:
name: coverage-reports-flow-bridge
path: |
unoplat-code-confluence-ingestion/code-confluence-flow-bridge/coverage_reports/
retention-days: 7
test-query-engine:
needs:
- detect-changes
- refresh-release-pr-lockfiles
if: ${{ (needs.detect-changes.outputs.query-engine == 'true' || needs.detect-changes.outputs.commons == 'true') && (needs.refresh-release-pr-lockfiles.result == 'success' || needs.refresh-release-pr-lockfiles.result == 'skipped') }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install uv
uses: astral-sh/setup-uv@v5
# 1) Always ensure the Compose v2 plugin is present
- name: Set up Docker Compose (v2)
uses: docker/setup-compose-action@v1
# pin a version if you need repeatability:
# with:
# version: '2.37.0'
# 2) Drop in a shim so legacy tools that expect `docker-compose`
# still work (but use v2 under the hood)
- name: Provide docker-compose wrapper for compatibility
shell: bash
run: |
if ! command -v docker-compose >/dev/null; then
echo 'Creating docker-compose wrapper ➜ docker compose "$@"'
sudo install -d /usr/local/bin
printf '#!/usr/bin/env bash\nexec docker compose "$@"\n' | \
sudo tee /usr/local/bin/docker-compose >/dev/null
sudo chmod +x /usr/local/bin/docker-compose
fi
docker compose version
docker-compose version # should output the same version
- name: Install Ruff
run: curl -LsSf https://astral.sh/ruff/install.sh | sh
- name: Install ripgrep
run: |
sudo apt-get update
sudo apt-get install -y ripgrep
- name: Get package name for coverage
working-directory: unoplat-code-confluence-query-engine
id: package
run: |
# Extract project name from pyproject.toml and convert hyphens to underscores
PACKAGE_NAME=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['name'].replace('-', '_'))")
echo "name=$PACKAGE_NAME" >> $GITHUB_OUTPUT
- name: Check lockfile freshness
working-directory: unoplat-code-confluence-query-engine
run: uv lock --check
- name: Install dependencies and run tests
working-directory: unoplat-code-confluence-query-engine
env:
GITHUB_PAT_TOKEN: ${{ github.token }}
run: |
uv sync --group test
uv run --group test pytest --cov=src/${{ steps.package.outputs.name }} --cov-report=html:coverage_reports --cov-report=xml:coverage.xml --cov-report=term-missing tests/ -v
- name: Upload coverage reports
uses: actions/upload-artifact@v4
with:
name: coverage-reports-query-engine
path: |
unoplat-code-confluence-query-engine/coverage_reports/
retention-days: 7