Repository navigation
229 lines (210 loc) 路 9.16 KB
/
Copy path_scheduled-test-hourly.yml
File metadata and controls
229 lines (210 loc) 路 9.16 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
name: "> Scheduled Test (Hourly)"
on:
workflow_call:
inputs:
platform_environment:
description: 'Environment to test against, that is staging or production'
required: false
default: 'staging'
type: string
branch:
description: 'Branch to checkout (leave empty for default branch)'
required: false
default: ''
type: string
secrets:
AIGNOSTICS_CLIENT_ID_DEVICE_STAGING:
required: true
AIGNOSTICS_REFRESH_TOKEN_STAGING:
required: true
GCP_CREDENTIALS_STAGING:
required: true
BETTERSTACK_HEARTBEAT_URL_STAGING:
required: true
BETTERSTACK_HEARTBEAT_URL_PLATFORM_APPLICATIONS_STAGING:
required: false
BETTERSTACK_HEARTBEAT_URL_PLATFORM_API_STAGING:
required: false
AIGNOSTICS_CLIENT_ID_DEVICE_PRODUCTION:
required: true
AIGNOSTICS_REFRESH_TOKEN_PRODUCTION:
required: true
GCP_CREDENTIALS_PRODUCTION:
required: true
BETTERSTACK_HEARTBEAT_URL_PRODUCTION:
required: true
BETTERSTACK_HEARTBEAT_URL_PLATFORM_APPLICATIONS_PRODUCTION:
required: false
BETTERSTACK_HEARTBEAT_URL_PLATFORM_API_PRODUCTION:
required: false
SENTRY_DSN:
required: true
env:
# https://gist.github.com/NodeJSmith/e7e37f2d3f162456869f015f842bcf15
PYTHONIOENCODING: "utf8"
AIGNOSTICS_PLATFORM_ENVIRONMENT: ${{ inputs.platform_environment }}
jobs:
test-scheduled-hourly:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ inputs.branch || github.ref }}
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
with:
version-file: "pyproject.toml"
enable-cache: true
cache-dependency-glob: uv.lock
- name: Install dev tools
shell: bash
run: .github/workflows/_install_dev_tools.bash
- name: Install Python, venv and dependencies
shell: bash
run: uv sync --all-extras --frozen --link-mode=copy
- 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_CLIENT_ID_DEVICE: ${{ inputs.platform_environment == 'staging' && secrets.AIGNOSTICS_CLIENT_ID_DEVICE_STAGING || secrets.AIGNOSTICS_CLIENT_ID_DEVICE_PRODUCTION }}
envkey_AIGNOSTICS_REFRESH_TOKEN: ${{ inputs.platform_environment == 'staging' && secrets.AIGNOSTICS_REFRESH_TOKEN_STAGING || secrets.AIGNOSTICS_REFRESH_TOKEN_PRODUCTION }}
envkey_AIGNOSTICS_SENTRY_ENABLED: true
envkey_AIGNOSTICS_SENTRY_DSN: ${{ secrets.SENTRY_DSN}}
envkey_AIGNOSTICS_SENTRY_DEBUG: false
envkey_AIGNOSTICS_SENTRY_SEND_DEFAULT_PII: false
envkey_AIGNOSTICS_SENTRY_SAMPLE_RATE: 0
envkey_AIGNOSTICS_SENTRY_TRACES_SAMPLE_RATE: 0
envkey_AIGNOSTICS_SENTRY_PROFILES_SAMPLE_RATE: 0
fail_on_empty: false
- name: Set up GCP credentials for bucket access
shell: bash
env:
GCP_CREDENTIALS: ${{ inputs.platform_environment == 'staging' && secrets.GCP_CREDENTIALS_STAGING || secrets.GCP_CREDENTIALS_PRODUCTION }}
run: |
echo "$GCP_CREDENTIALS" | base64 -d > credentials.json
echo "GOOGLE_APPLICATION_CREDENTIALS=$(pwd)/credentials.json" >> $GITHUB_ENV
- name: Test / scheduled / sdk
id: test_sdk
env:
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
shell: bash
run: |
set +e
XDIST_WORKER_FACTOR=1 uv run --all-extras nox -s test -- \
-m "(scheduled or scheduled_only) and not platform_api and not platform_applications and not stress_only"
echo "exit_code=$?" >> $GITHUB_OUTPUT
- name: Test / scheduled / platform-api
id: test_platform_api
env:
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
shell: bash
run: |
set +e
XDIST_WORKER_FACTOR=1 uv run --all-extras nox -s test -- \
-m "(scheduled or scheduled_only) and platform_api and not stress_only"
echo "exit_code=$?" >> $GITHUB_OUTPUT
- name: Test / scheduled / platform-applications
id: test_platform_applications
env:
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
shell: bash
run: |
set +e
XDIST_WORKER_FACTOR=1 uv run --all-extras nox -s test -- \
-m "(scheduled or scheduled_only) and platform_applications and not stress_only"
echo "exit_code=$?" >> $GITHUB_OUTPUT
- name: Collect combined exit code and publish summary
id: collect
if: always()
shell: bash
run: |
SDK_EXIT=${{ steps.test_sdk.outputs.exit_code || '1' }}
PLATFORM_API_EXIT=${{ steps.test_platform_api.outputs.exit_code || '1' }}
PLATFORM_APPLICATIONS_EXIT=${{ steps.test_platform_applications.outputs.exit_code || '1' }}
if [ "$SDK_EXIT" != "0" ] || [ "$PLATFORM_API_EXIT" != "0" ] || [ "$PLATFORM_APPLICATIONS_EXIT" != "0" ]; then
COMBINED_EXIT=1
else
COMBINED_EXIT=0
fi
echo "sdk_exit=${SDK_EXIT}" >> $GITHUB_OUTPUT
echo "platform_api_exit=${PLATFORM_API_EXIT}" >> $GITHUB_OUTPUT
echo "platform_applications_exit=${PLATFORM_APPLICATIONS_EXIT}" >> $GITHUB_OUTPUT
echo "combined_exit=${COMBINED_EXIT}" >> $GITHUB_OUTPUT
found_files=0
for file in reports/pytest_*.md reports/pytest.md; do
if [ -f "$file" ]; then
cat "$file" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
found_files=1
fi
done
if [ $found_files -eq 0 ]; then
echo "# All scheduled tests passed" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
fi
if [ -f "reports/coverage.md" ]; then
cat "reports/coverage.md" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
else
echo "# No test coverage computed." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
fi
- name: Heartbeat / Sentry
if: always()
shell: bash
env:
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
COMBINED_EXIT: ${{ steps.collect.outputs.combined_exit }}
run: |
sentry-cli monitors run -e CI --schedule "0 * * * *" --check-in-margin 30 --max-runtime 1 \
scheduled-testing-${{ inputs.platform_environment }}-hourly \
--timezone "Europe/Berlin" -- sh -c "exit ${COMBINED_EXIT}" || true
- name: Heartbeat / BetterStack / SDK
if: always()
env:
BETTERSTACK_HEARTBEAT_URL: "${{ inputs.platform_environment == 'staging' && secrets.BETTERSTACK_HEARTBEAT_URL_STAGING || secrets.BETTERSTACK_HEARTBEAT_URL_PRODUCTION }}"
BETTERSTACK_EXIT_CODE: ${{ steps.collect.outputs.sdk_exit }}
BETTERSTACK_LABEL: SDK
JOB_STATUS: ${{ job.status }}
shell: bash
run: python3 .github/workflows/_betterstack_heartbeat.py
- name: Heartbeat / BetterStack / Platform API
if: always()
env:
BETTERSTACK_HEARTBEAT_URL: "${{ inputs.platform_environment == 'staging' && secrets.BETTERSTACK_HEARTBEAT_URL_PLATFORM_API_STAGING || secrets.BETTERSTACK_HEARTBEAT_URL_PLATFORM_API_PRODUCTION }}"
BETTERSTACK_EXIT_CODE: ${{ steps.collect.outputs.platform_api_exit }}
BETTERSTACK_LABEL: "Platform API"
JOB_STATUS: ${{ job.status }}
shell: bash
run: python3 .github/workflows/_betterstack_heartbeat.py
- name: Heartbeat / BetterStack / Platform Applications
if: always()
env:
BETTERSTACK_HEARTBEAT_URL: "${{ inputs.platform_environment == 'staging' && secrets.BETTERSTACK_HEARTBEAT_URL_PLATFORM_APPLICATIONS_STAGING || secrets.BETTERSTACK_HEARTBEAT_URL_PLATFORM_APPLICATIONS_PRODUCTION }}"
BETTERSTACK_EXIT_CODE: ${{ steps.collect.outputs.platform_applications_exit }}
BETTERSTACK_LABEL: "Platform Applications"
JOB_STATUS: ${{ job.status }}
shell: bash
run: python3 .github/workflows/_betterstack_heartbeat.py
- name: Upload test results
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: ${{ always() && (env.GITHUB_WORKFLOW_RUNTIME != 'ACT') }}
with:
name: test-results-scheduled
path: |
reports/junit_*.xml
reports/coverage.xml
reports/coverage.md
reports/coverage_html
aignostics.log
retention-days: 7
- name: Fail job if any tests failed
if: always()
shell: bash
run: exit ${{ steps.collect.outputs.combined_exit }}