Repository navigation
262 lines (236 loc) · 10.7 KB
/
Copy path_test.yml
File metadata and controls
262 lines (236 loc) · 10.7 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
name: "> Test"
on:
workflow_call:
inputs:
platform_environment:
description: 'Environment to test against, that is staging or production'
required: false
default: 'staging'
type: string
commit_message:
description: 'Commit message to check for skip/enable markers'
required: false
type: string
secrets:
AIGNOSTICS_REFRESH_TOKEN_STAGING:
required: false
AIGNOSTICS_REFRESH_TOKEN_PRODUCTION:
required: false
SONAR_TOKEN:
required: false
env:
# https://gist.github.com/NodeJSmith/e7e37f2d3f162456869f015f842bcf15
PYTHONIOENCODING: "utf8"
AIGNOSTICS_PLATFORM_ENVIRONMENT: ${{ inputs.platform_environment }}
jobs:
generate-matrix:
runs-on: ubuntu-latest
permissions: {}
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Set matrix based on commit message and PR labels
id: set-matrix
env:
COMMIT_MESSAGE: ${{ inputs.commit_message }}
PR_LABELS: ${{ toJSON(github.event.pull_request.labels.*.name) }}
run: |
if [[ "$COMMIT_MESSAGE" == *"skip:test:matrix-runner"* ]] || [[ "$PR_LABELS" == *"skip:test:matrix-runner"* ]]; then
echo 'matrix={"runner":["ubuntu-latest"],"experimental":[false]}' >> $GITHUB_OUTPUT
else
echo 'matrix={"runner":["ubuntu-latest"],"experimental":[false],"include":[{"runner":"ubuntu-24.04-arm","experimental":true},{"runner":"macos-latest","experimental":true},{"runner":"macos-15-intel","experimental":true},{"runner":"windows-latest","experimental":true}]}' >> $GITHUB_OUTPUT
fi
test:
needs: generate-matrix
runs-on: ${{ matrix.runner }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
permissions:
contents: read
id-token: write # Codecov OIDC upload
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
with:
version-file: "pyproject.toml"
enable-cache: true
cache-dependency-glob: uv.lock
- name: Install dev tools
if: ${{ matrix.runner == 'ubuntu-latest' || matrix.runner == 'ubuntu-24.04-arm' }}
shell: bash
run: .github/workflows/_install_dev_tools.bash
- name: Install Python, venv and dependencies
shell: bash
run: uv sync --all-extras --locked --link-mode=copy
# Need xdisplay for testing QuPath app integration
- name: Setup display
uses: pyvista/setup-headless-display-action@10e6efb97af3cd1523828f0e22c39f0e4567f3e4 # v5.2
- name: Release version check
if: startsWith(github.ref, 'refs/tags/v')
shell: bash
run: |
TAG_VERSION=${GITHUB_REF#refs/tags/v}
TOML_VERSION=$(uv run --locked python -c "import tomli; print(tomli.load(open('pyproject.toml', 'rb'))['project']['version'])")
if [ "$TAG_VERSION" != "$TOML_VERSION" ]; then
echo "Release version mismatch: Tag $TAG_VERSION != pyproject.toml $TOML_VERSION"
exit 1
fi
- name: Print development version info
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
shell: bash
run: |
TOML_VERSION=$(uv run --locked python -c "import tomli; print(tomli.load(open('pyproject.toml', 'rb'))['project']['version'])")
echo "Development build - Current version in pyproject.toml: $TOML_VERSION"
- name: Create .env file
uses: SpicyPizza/create-envfile@ace6d4f5d7802b600276c23ca417e669f1a06f6f # v2.0.3
with:
# The following 3 lines are correct even if vscode complains
envkey_AIGNOSTICS_API_ROOT: ${{ inputs.platform_environment == 'staging' && 'https://platform-staging.aignostics.com' || 'https://platform.aignostics.com' }}
envkey_AIGNOSTICS_REFRESH_TOKEN: ${{ inputs.platform_environment == 'staging' && secrets.AIGNOSTICS_REFRESH_TOKEN_STAGING || secrets.AIGNOSTICS_REFRESH_TOKEN_PRODUCTION }}
fail_on_empty: false
- name: Validate installation (single Python version)
shell: bash
run: |
OUTPUT=$(uv run --locked --no-dev aignostics --help)
if [[ "$OUTPUT" != *"built with love in Berlin"* ]]; then
echo "Output does not contain 'built with love in Berlin'"
exit 1
fi
- name: Test / Smoke (single Python version)
shell: bash
run: |
uv run --locked --no-dev aignostics --help
uv run --locked --all-extras aignostics system info
uv run --locked --all-extras aignostics system health
uv run --locked --all-extras aignostics user whoami --mask-secrets
uv run --locked --all-extras aignostics application list
uv run --locked --all-extras aignostics application run list --verbose --limit 1
# All test steps use continue-on-error: true so that every test suite
# always runs regardless of whether earlier suites failed. This ensures
# Codecov always receives a complete coverage report (partial reports
# cause the coverage badge to read lower than the true value).
# A single "Assert no test failures" gate step at the end surfaces any
# failures and fails the job — so the workflow still fails correctly.
- name: Test / Unit (multiple Python versions)
id: unit
continue-on-error: true
if: ${{ !cancelled() }}
uses: $/.github/actions/run-tests
with:
test-type: unit
make-target: test_unit_matrix
skip-marker: skip:test:unit
summary-title: All unit tests passed
commit-message: ${{ inputs.commit_message }}
- name: Test / Integration (multiple Python versions)
id: integration
continue-on-error: true
if: ${{ !cancelled() }}
uses: $/.github/actions/run-tests
with:
test-type: integration
make-target: test_integration_matrix
skip-marker: skip:test:integration
summary-title: All integration tests passed
commit-message: ${{ inputs.commit_message }}
- name: Test / E2E / regular (multiple Python versions)
id: e2e_regular
continue-on-error: true
if: ${{ !cancelled() }}
uses: $/.github/actions/run-tests
with:
test-type: e2e
make-target: test_e2e_matrix
skip-marker: skip:test:e2e
summary-title: All regular e2e tests passed
commit-message: ${{ inputs.commit_message }}
- name: Test / E2E / long running (single Python version)
id: e2e_long_running
continue-on-error: true
if: ${{ !cancelled() }}
uses: $/.github/actions/run-tests
with:
test-type: long-running
make-target: test_long_running
skip-marker: skip:test:long_running
summary-title: All long running e2e tests passed
commit-message: ${{ inputs.commit_message }}
- name: Test / E2E / very long running (single Python version)
id: e2e_very_long_running
continue-on-error: true
if: |
!cancelled() && (
contains(inputs.commit_message, 'enable:test:very_long_running') ||
contains(github.event.pull_request.labels.*.name, 'enable:test:very_long_running') ||
((github.event_name == 'push' || github.event_name == 'workflow_dispatch') && startsWith(github.ref, 'refs/heads/release/v'))
)
uses: $/.github/actions/run-tests
with:
test-type: very-long-running
make-target: test_very_long_running
summary-title: All very long running e2e tests passed
commit-message: ${{ inputs.commit_message }}
- name: Upload test artifacts for inspection
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: ${{ always() && (env.GITHUB_WORKFLOW_RUNTIME != 'ACT') }}
with:
name: test-results-${{ matrix.runner }}
path: |
reports/mypy_junit.xml
reports/junit_*.xml
reports/coverage.xml
reports/coverage.md
reports/coverage_html
retention-days: 7
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
if: |
!cancelled() &&
(env.GITHUB_WORKFLOW_RUNTIME != 'ACT') &&
matrix.runner == 'ubuntu-latest' &&
!contains(inputs.commit_message, 'skip:codecov') &&
!contains(github.event.pull_request.labels.*.name, 'skip:codecov')
with:
use_oidc: true
slug: aignostics/python-sdk
- name: Upload test results to Codecov
if: |
!cancelled() &&
(env.GITHUB_WORKFLOW_RUNTIME != 'ACT') &&
matrix.runner == 'ubuntu-latest' &&
!contains(inputs.commit_message, 'skip:codecov') &&
!contains(github.event.pull_request.labels.*.name, 'skip:codecov')
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
with:
use_oidc: true
report_type: test_results
- name: SonarQube Scan
if: ${{ !cancelled() && (env.GITHUB_WORKFLOW_RUNTIME != 'ACT') && matrix.runner == 'ubuntu-latest' }}
uses: SonarSource/sonarqube-scan-action@d209202bc7d53ff1cc128f7f907dac145c9d6ae9 # v8.3.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Assert no test failures
# Single gate that fails the job if any test suite failed. Kept last so
# that all reporting steps (Codecov, SonarQube, artifact upload) always
# run to completion before the job is marked as failed.
if: ${{ !cancelled() }}
shell: bash
run: |
failed=()
[[ "${{ steps.unit.outcome }}" == "failure" ]] && failed+=("unit")
[[ "${{ steps.integration.outcome }}" == "failure" ]] && failed+=("integration")
[[ "${{ steps.e2e_regular.outcome }}" == "failure" ]] && failed+=("e2e_regular")
[[ "${{ steps.e2e_long_running.outcome }}" == "failure" ]] && failed+=("e2e_long_running")
[[ "${{ steps.e2e_very_long_running.outcome }}" == "failure" ]] && failed+=("e2e_very_long_running")
if [[ ${#failed[@]} -gt 0 ]]; then
echo "The following test suites failed: ${failed[*]}"
exit 1
fi
echo "All test suites passed."