Skip to content

Commit 2eba1e9

Browse files
authored
fix(test): load unit test metrics into bq (#10474)
Signed-off-by: Tomasz Janiszewski <tomek@redhat.com>
1 parent 095fb75 commit 2eba1e9

3 files changed

Lines changed: 38 additions & 6 deletions

File tree

‎.github/actions/junit2jira/action.yaml‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ branding:
44
icon: 'archive'
55
color: 'blue'
66
inputs:
7+
create-jiras:
8+
description: 'Whether to report failures to Jira'
9+
required: false
10+
default: 'true'
11+
gcp-account:
12+
description: 'Account to be used to upload tests data'
13+
required: true
714
jira-token:
815
description: 'Token used to authenticate with Jira.'
916
required: true
@@ -32,14 +39,28 @@ runs:
3239
- name: Check files
3340
shell: bash
3441
env:
42+
GCP_SERVICE_ACCOUNT_STACKROX_CI: ${{ inputs.gcp-account }}
3543
JIRA_TOKEN: ${{ inputs.jira-token }}
3644
run: |
45+
extra_args=()
46+
if [[ "${{ inputs.create-jiras }}" == "false" ]]; then
47+
extra_args=(--dry-run)
48+
else
49+
echo "Will create JIRA issues for JUnit failures found in ${{ inputs.directory }}"
50+
fi
51+
csv_output="$(mktemp --suffix=.csv)"
3752
./junit2jira \
3853
-base-link "${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}" \
3954
-build-id "${{ github.run_id }}" \
4055
-build-link "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
4156
-build-tag "${{ github.ref_name }}@${{ github.sha }}" \
57+
-csv-output "${csv_output}" \
4258
-job-name "${{ github.job }}" \
4359
-junit-reports-dir "${{ inputs.directory }}" \
4460
-orchestrator "${{ runner.name }} ${{ runner.os }}-${{ runner.arch }}" \
45-
-threshold "${{ inputs.threshold }}"
61+
-threshold "${{ inputs.threshold }}" \
62+
"${extra_args[@]}"
63+
64+
source scripts/ci/lib.sh
65+
setup_gcp
66+
save_test_metrics "${csv_output}"

‎.github/workflows/build.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ jobs:
623623
if: always()
624624
with:
625625
jira-token: ${{ secrets.JIRA_TOKEN }}
626+
gcp-account: ${{ secrets.GCP_SERVICE_ACCOUNT_STACKROX_CI }}
626627
directory: 'junit-reports'
627628

628629
scan-images-with-roxctl:

‎.github/workflows/unit-tests.yaml‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,12 @@ jobs:
6565
paths: 'junit-reports/report.xml'
6666

6767
- name: Report test failures to Jira
68-
if: (!cancelled()) && github.event_name == 'push'
68+
if: (!cancelled())
6969
uses: ./.github/actions/junit2jira
7070
with:
71+
create-jiras: ${{ github.event_name == 'push' }}
7172
jira-token: ${{ secrets.JIRA_TOKEN }}
73+
gcp-account: ${{ secrets.GCP_SERVICE_ACCOUNT_STACKROX_CI }}
7274
directory: 'junit-reports'
7375

7476
go-postgres:
@@ -116,10 +118,12 @@ jobs:
116118
paths: 'junit-reports/report.xml'
117119

118120
- name: Report junit failures in jira
119-
if: (!cancelled()) && github.event_name == 'push'
121+
if: (!cancelled())
120122
uses: ./.github/actions/junit2jira
121123
with:
124+
create-jiras: ${{ github.event_name == 'push' }}
122125
jira-token: ${{ secrets.JIRA_TOKEN }}
126+
gcp-account: ${{ secrets.GCP_SERVICE_ACCOUNT_STACKROX_CI }}
123127
directory: 'junit-reports'
124128

125129
go-bench:
@@ -192,10 +196,12 @@ jobs:
192196
paths: 'ui/apps/platform/test-results/reports/*.xml'
193197

194198
- name: Report junit failures in jira
195-
if: (!cancelled()) && github.event_name == 'push'
199+
if: (!cancelled())
196200
uses: ./.github/actions/junit2jira
197201
with:
202+
create-jiras: ${{ github.event_name == 'push' }}
198203
jira-token: ${{ secrets.JIRA_TOKEN }}
204+
gcp-account: ${{ secrets.GCP_SERVICE_ACCOUNT_STACKROX_CI }}
199205
directory: 'ui/apps/platform/test-results/reports'
200206

201207
local-roxctl-tests:
@@ -226,10 +232,12 @@ jobs:
226232
paths: 'roxctl-test-output/*.xml'
227233

228234
- name: Report junit failures in jira
229-
if: (!cancelled()) && github.event_name == 'push'
235+
if: (!cancelled())
230236
uses: ./.github/actions/junit2jira
231237
with:
238+
create-jiras: ${{ github.event_name == 'push' }}
232239
jira-token: ${{ secrets.JIRA_TOKEN }}
240+
gcp-account: ${{ secrets.GCP_SERVICE_ACCOUNT_STACKROX_CI }}
233241
directory: 'roxctl-test-output'
234242

235243
shell-unit-tests:
@@ -255,10 +263,12 @@ jobs:
255263
paths: 'shell-test-output/*.xml'
256264

257265
- name: Report junit failures in jira
258-
if: (!cancelled()) && github.event_name == 'push'
266+
if: (!cancelled())
259267
uses: ./.github/actions/junit2jira
260268
with:
269+
create-jiras: ${{ github.event_name == 'push' }}
261270
jira-token: ${{ secrets.JIRA_TOKEN }}
271+
gcp-account: ${{ secrets.GCP_SERVICE_ACCOUNT_STACKROX_CI }}
262272
directory: 'shell-test-output'
263273

264274
openshift-ci-unit-tests:

0 commit comments

Comments
 (0)