Skip to content

Commit 49b5b7b

Browse files
authored
ref(ci): Adding a step to collect test data for backend tests (#68383)
Building off of #68263. Adding usages of [action-collect-test-data](https://github.com/getsentry/action-collect-test-data) to start collecting data about our backend tests.
1 parent 8c4d6bd commit 49b5b7b

File tree

4 files changed

+77
-1
lines changed

4 files changed

+77
-1
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: 'Collect Test Data'
2+
description: 'Collects test data and uploads it to our internal test data collection service.'
3+
4+
inputs:
5+
artifact_path:
6+
description: 'Path to test data output artifact to upload to our internal test data collection service'
7+
required: true
8+
gcs_bucket:
9+
description: 'The GCS bucket to upload the test data to'
10+
required: true
11+
gcp_project_id:
12+
description: 'The GCP project ID to use for uploading the test data'
13+
required: true
14+
workload_identity_provider:
15+
description: 'The workload identity provider to use for uploading the test data'
16+
required: true
17+
service_account_email:
18+
description: 'The service account email to use for uploading the test data'
19+
required: true
20+
matrix_instance_number:
21+
description: 'The instance number of the matrix job'
22+
required: false
23+
24+
runs:
25+
using: 'composite'
26+
steps:
27+
- name: Collect test data
28+
uses: getsentry/action-collect-test-data@c0a2fd3f79d3867e2c8b486ccb1c4bf925477742 # v0.3.0
29+
with:
30+
path: ${{ inputs.artifact_path }}
31+
gcs_path: ${{ inputs.gcs_bucket }}/pytest/${{ github.repository }}/${{ github.workflow }}/${{ github.job }}${{ inputs.matrix_instance_number != '' && '/instance' || '' }}${{ inputs.matrix_instance_number != '' && inputs.matrix_instance_number || '' }}/${{ github.repository_id }}/${{ github.run_id }}/${{ github.run_attempt }}
32+
gcp_project_id: ${{ inputs.gcp_project_id }}
33+
workload_identity_provider: ${{ inputs.workload_identity_provider }}
34+
service_account_email: ${{ inputs.service_account_email }}
35+
continue-on-error: true

.github/workflows/acceptance.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ jobs:
4646
name: acceptance
4747
runs-on: ubuntu-22.04
4848
timeout-minutes: 30
49+
permissions:
50+
contents: read
51+
id-token: write
4952
strategy:
5053
# This helps not having to run multiple jobs because one fails, thus, reducing resource usage
5154
# and reducing the risk that one of many runs would turn red again (read: intermittent tests)
@@ -113,6 +116,17 @@ jobs:
113116
- name: Run acceptance tests (#${{ steps.setup.outputs.matrix-instance-number }} of ${{ steps.setup.outputs.matrix-instance-total }})
114117
run: make run-acceptance
115118

119+
- name: Collect test data
120+
uses: ./.github/actions/collect-test-data
121+
if: ${{ !cancelled() && needs.files-changed.outputs.backend_all == 'true' }}
122+
with:
123+
artifact_path: .artifacts/pytest.acceptance.json
124+
gcs_bucket: ${{ secrets.COLLECT_TEST_DATA_GCS_BUCKET }}
125+
gcp_project_id: ${{ secrets.COLLECT_TEST_DATA_GCP_PROJECT_ID }}
126+
workload_identity_provider: ${{ secrets.SENTRY_GCP_DEV_WORKLOAD_IDENTITY_POOL }}
127+
service_account_email: ${{ secrets.COLLECT_TEST_DATA_SERVICE_ACCOUNT_EMAIL }}
128+
matrix_instance_number: ${{ steps.setup.outputs.matrix-instance-number }}
129+
116130
# This job runs when FE or BE changes happen, however, we only upload coverage data for
117131
# BE changes since it conflicts with codecov's carry forward functionality
118132
# Upload coverage data even if running the tests step fails since

.github/workflows/backend.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ jobs:
6767
name: backend test
6868
runs-on: ubuntu-22.04
6969
timeout-minutes: 60
70+
permissions:
71+
contents: read
72+
id-token: write
7073
strategy:
7174
# This helps not having to run multiple jobs because one fails, thus, reducing resource usage
7275
# and reducing the risk that one of many runs would turn red again (read: intermittent tests)
@@ -106,6 +109,17 @@ jobs:
106109
run: |
107110
make test-python-ci
108111
112+
- name: Collect test data
113+
uses: ./.github/actions/collect-test-data
114+
if: ${{ !cancelled() }}
115+
with:
116+
artifact_path: .artifacts/pytest.json
117+
gcs_bucket: ${{ secrets.COLLECT_TEST_DATA_GCS_BUCKET }}
118+
gcp_project_id: ${{ secrets.COLLECT_TEST_DATA_GCP_PROJECT_ID }}
119+
workload_identity_provider: ${{ secrets.SENTRY_GCP_DEV_WORKLOAD_IDENTITY_POOL }}
120+
service_account_email: ${{ secrets.COLLECT_TEST_DATA_SERVICE_ACCOUNT_EMAIL }}
121+
matrix_instance_number: ${{ steps.setup.outputs.matrix-instance-number }}
122+
109123
# Upload coverage data even if running the tests step fails since
110124
# it reduces large coverage fluctuations
111125
- name: Handle artifacts
@@ -245,6 +259,9 @@ jobs:
245259
name: monolith-dbs test
246260
runs-on: ubuntu-22.04
247261
timeout-minutes: 20
262+
permissions:
263+
contents: read
264+
id-token: write
248265
steps:
249266
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
250267
with:
@@ -260,6 +277,16 @@ jobs:
260277
run: |
261278
make test-monolith-dbs
262279
280+
- name: Collect test data
281+
uses: ./.github/actions/collect-test-data
282+
if: ${{ !cancelled() }}
283+
with:
284+
artifact_path: .artifacts/pytest.monolith-dbs.json
285+
gcs_bucket: ${{ secrets.COLLECT_TEST_DATA_GCS_BUCKET }}
286+
gcp_project_id: ${{ secrets.COLLECT_TEST_DATA_GCP_PROJECT_ID }}
287+
workload_identity_provider: ${{ secrets.SENTRY_GCP_DEV_WORKLOAD_IDENTITY_POOL }}
288+
service_account_email: ${{ secrets.COLLECT_TEST_DATA_SERVICE_ACCOUNT_EMAIL }}
289+
263290
# Upload coverage data even if running the tests step fails since
264291
# it reduces large coverage fluctuations
265292
- name: Handle artifacts

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fetch-release-registry:
9191

9292
run-acceptance:
9393
@echo "--> Running acceptance tests"
94-
pytest tests/acceptance --cov . --cov-report="xml:.artifacts/acceptance.coverage.xml" --json-report --json-report-file=".artifact/pytest.acceptance.json" --json-report-omit=log
94+
pytest tests/acceptance --cov . --cov-report="xml:.artifacts/acceptance.coverage.xml" --json-report --json-report-file=".artifacts/pytest.acceptance.json" --json-report-omit=log
9595
@echo ""
9696

9797
test-cli: create-db

0 commit comments

Comments
 (0)