Skip to content

Commit 66a2d2d

Browse files
Conornataly
authored andcommitted
ci: use custom test-reporter action to upload job results (#18004)
* ci: use custom action to upload job results
1 parent b6c8b20 commit 66a2d2d

File tree

2 files changed

+160
-25
lines changed

2 files changed

+160
-25
lines changed

.github/workflows/gradle.yml

Lines changed: 106 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ jobs:
8686
${{ secrets.SUPERTOPHER_PAT }} \
8787
${{ secrets.DAVINCHIA_PAT }}
8888
89+
8990
# Uncomment to debug.
9091
# changes-output:
9192
# name: "Debug Change Detection Logic"
@@ -237,6 +238,37 @@ jobs:
237238
- name: Ensure no file change
238239
run: git --no-pager diff && test -z "$(git --no-pager diff)"
239240

241+
- name: Publish Connectors Base Test Results
242+
uses: EnricoMi/publish-unit-test-result-action@v2
243+
id: connectors-test-results
244+
if: always()
245+
with:
246+
junit_files: "/actions-runner/_work/airbyte/airbyte/*/build/test-results/*/*.xml\n/actions-runner/_work/airbyte/airbyte/*/*/build/test-results/*/*.xml"
247+
comment_mode: off
248+
json_file: connectors_base_results.json
249+
json_test_case_results: true
250+
check_name: "Connectors Base Test Results"
251+
252+
- name: Setup Google Cloud SDK
253+
if: always()
254+
uses: google-github-actions/setup-gcloud@v0
255+
with:
256+
service_account_key: ${{ secrets.GKE_TEST_SA_KEY }}
257+
export_default_credentials: true
258+
259+
- name: Prep Test Results For GCS
260+
if: always()
261+
run: |
262+
python tools/bin/prep_test_results_for_gcs.py --json connectors_base_results.json
263+
264+
- name: Upload Test Results to GCS
265+
if: always()
266+
run: |
267+
gcs_bucket_name="dev-ab-ci-run-results"
268+
filename=$(echo "${{ fromJSON( steps.connectors-test-results.outputs.json ).check_url }}" | sed 's@.*/@@')
269+
echo "$filename"
270+
gsutil -h "Cache-Control:public" cp connectors_base_results.jsonl "gs://$gcs_bucket_name/oss/$filename.jsonl"
271+
240272
- name: Generate Test Report
241273
uses: dorny/test-reporter@v1
242274
if: always()
@@ -524,6 +556,42 @@ jobs:
524556
- name: Automatic Migration Acceptance Test
525557
run: SUB_BUILD=PLATFORM ./gradlew :airbyte-tests:automaticMigrationAcceptanceTest --scan -i
526558

559+
- uses: actions/setup-python@v2
560+
if: always()
561+
with:
562+
python-version: "3.9"
563+
564+
- name: Publish Platform Test Results
565+
uses: EnricoMi/publish-unit-test-result-action@v2
566+
id: platform-results
567+
if: always()
568+
with:
569+
junit_files: "/actions-runner/_work/airbyte/airbyte/*/build/test-results/*/*.xml\n/actions-runner/_work/airbyte/airbyte/*/*/build/test-results/*/*.xml"
570+
comment_mode: off
571+
json_file: platform_results.json
572+
json_test_case_results: true
573+
check_name: "Platform Test Results"
574+
575+
- name: Setup Google Cloud SDK
576+
if: always()
577+
uses: google-github-actions/setup-gcloud@v0
578+
with:
579+
service_account_key: ${{ secrets.GKE_TEST_SA_KEY }}
580+
export_default_credentials: true
581+
582+
- name: Prep Test Results For GCS
583+
if: always()
584+
run: |
585+
python tools/bin/prep_test_results_for_gcs.py --json platform_results.json
586+
587+
- name: Upload Test Results to GCS
588+
if: always()
589+
run: |
590+
gcs_bucket_name="dev-ab-ci-run-results"
591+
filename=$(echo "${{ fromJSON( steps.platform-results.outputs.json ).check_url }}" | sed 's@.*/@@')
592+
echo "$filename"
593+
gsutil -h "Cache-Control:public" cp platform_results.jsonl "gs://$gcs_bucket_name/oss/$filename.jsonl"
594+
527595
- name: Generate Test Report
528596
uses: dorny/test-reporter@v1
529597
if: always() # run this step even if previous step failed
@@ -543,15 +611,6 @@ jobs:
543611
key: ${{ secrets.BUILDPULSE_ACCESS_KEY_ID }}
544612
secret: ${{ secrets.BUILDPULSE_SECRET_ACCESS_KEY }}
545613

546-
- name: Upload test results to Github for analysis
547-
if: '!cancelled()' # Run this step even when the tests fail. Skip if the workflow is cancelled.
548-
uses: actions/upload-artifact@v3
549-
with:
550-
path: |
551-
/actions-runner/_work/airbyte/airbyte/*/build/test-results/*/*.xml
552-
/actions-runner/_work/airbyte/airbyte/*/*/build/test-results/*/*.xml
553-
name: test-results-build
554-
555614
# In case of self-hosted EC2 errors, remove this block.
556615
stop-platform-build-runner:
557616
name: "Platform: Stop Build EC2 Runner"
@@ -683,6 +742,42 @@ jobs:
683742
run: |
684743
CI=true IS_MINIKUBE=true ./tools/bin/acceptance_test_kube.sh
685744
745+
- uses: actions/setup-python@v2
746+
if: always()
747+
with:
748+
python-version: "3.9"
749+
750+
- name: Publish Kube Test Results
751+
id: kube-results
752+
uses: EnricoMi/publish-unit-test-result-action@v2
753+
if: always()
754+
with:
755+
junit_files: "/actions-runner/_work/airbyte/airbyte/*/build/test-results/*/*.xml\n/actions-runner/_work/airbyte/airbyte/*/*/build/test-results/*/*.xml"
756+
comment_mode: off
757+
json_file: kube_results.json
758+
json_test_case_results: true
759+
check_name: "Kube Test Results"
760+
761+
- name: Setup Google Cloud SDK
762+
if: always()
763+
uses: google-github-actions/setup-gcloud@v0
764+
with:
765+
service_account_key: ${{ secrets.GKE_TEST_SA_KEY }}
766+
export_default_credentials: true
767+
768+
- name: Prep Test Results For GCS
769+
if: always()
770+
run: |
771+
python tools/bin/prep_test_results_for_gcs.py --json kube_results.json
772+
773+
- name: Upload Test Results to GCS
774+
if: always()
775+
run: |
776+
gcs_bucket_name="dev-ab-ci-run-results"
777+
filename=$(echo "${{ fromJSON( steps.kube-results.outputs.json ).check_url }}" | sed 's@.*/@@')
778+
echo "$filename"
779+
gsutil -h "Cache-Control:public" cp kube_results.jsonl "gs://$gcs_bucket_name/oss/$filename.jsonl"
780+
686781
- name: Generate Test Report
687782
uses: dorny/test-reporter@v1
688783
if: always() # run this step even if previous step failed
@@ -701,20 +796,13 @@ jobs:
701796
key: ${{ secrets.BUILDPULSE_ACCESS_KEY_ID }}
702797
secret: ${{ secrets.BUILDPULSE_SECRET_ACCESS_KEY }}
703798

704-
- name: Upload test results to Github for analysis
705-
if: '!cancelled()' # Run this step even when the tests fail. Skip if the workflow is cancelled.
706-
uses: actions/upload-artifact@v3
707-
with:
708-
path: |
709-
/actions-runner/_work/airbyte/airbyte/*/build/test-results/*/*.xml
710-
/actions-runner/_work/airbyte/airbyte/*/*/build/test-results/*/*.xml
711-
name: test-results-kube
712-
713799
- uses: actions/upload-artifact@v2
714800
if: failure()
715801
with:
716802
name: Kubernetes Logs
717803
path: /tmp/kubernetes_logs/*
804+
805+
718806
# In case of self-hosted EC2 errors, remove this block.
719807
stop-kube-acceptance-test-runner:
720808
name: "Platform: Stop Kube Acceptance Test EC2 Runner"
@@ -861,13 +949,6 @@ jobs:
861949
# SECRET_STORE_GCP_PROJECT_ID: ${{ secrets.SECRET_STORE_GCP_PROJECT_ID }}
862950
# run: |
863951
# CI=true IS_MINIKUBE=true ./tools/bin/acceptance_test_kube_helm.sh
864-
# - name: Generate Test Report
865-
# uses: dorny/test-reporter@v1
866-
# if: always() # run this step even if previous step failed
867-
# with:
868-
# name: Platform Helm E2E Test Report
869-
# path: '/actions-runner/_work/airbyte/airbyte/*/build/test-results/*/*.xml'
870-
# reporter: java-junit
871952
#
872953
# - uses: actions/upload-artifact@v2
873954
# if: failure()
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import argparse
2+
import json
3+
import os
4+
5+
6+
'''
7+
8+
This script is intended to be run in conjuction with https://github.com/EnricoMi/publish-unit-test-result-action to upload trimmed
9+
test results from the output to a GCS bucket for further analysis.
10+
11+
The script takes as input the filename of the json output by the aforementioned action, trims it, and writes it out in jsonl format with ".jsonl" filename
12+
13+
'''
14+
15+
# Initiate the parser
16+
parser = argparse.ArgumentParser()
17+
18+
# Add long and short argument
19+
parser.add_argument("--json", "-j", help="Path to the result json output by https://github.com/EnricoMi/publish-unit-test-result-action")
20+
21+
def main():
22+
# Read arguments from the command line
23+
args = parser.parse_args()
24+
25+
f = open(args.json)
26+
d = json.load(f)
27+
out = []
28+
29+
check_run_id = int(d["check_url"].split("/")[-1])
30+
31+
for elem in d['cases']:
32+
for conclusion in ('success', 'failure', 'skipped'):
33+
if conclusion not in elem['states']:
34+
continue
35+
for i in range(len(elem['states'][conclusion])):
36+
output = {
37+
"test_name": elem['states'][conclusion][i]['test_name'],
38+
"class_name": elem['states'][conclusion][i]['class_name'],
39+
"result_file": elem['states'][conclusion][i]['result_file'],
40+
"time": elem['states'][conclusion][i]['time'],
41+
"state": conclusion,
42+
"check_run_id": check_run_id,
43+
"repo": "airbytehq/airbyte"
44+
}
45+
out.append(output)
46+
47+
with open(args.json + "l", 'w') as f:
48+
for o in out:
49+
json.dump(o, f)
50+
f.write('\n')
51+
52+
53+
if __name__ == '__main__':
54+
main()

0 commit comments

Comments
 (0)