Skip to content

Commit fc29dc1

Browse files
author
cpdeethree
committed
ci: use custom action to upload job results
1 parent 804bf47 commit fc29dc1

File tree

2 files changed

+179
-25
lines changed

2 files changed

+179
-25
lines changed

.github/workflows/gradle.yml

Lines changed: 105 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ jobs:
8484
${{ secrets.SUPERTOPHER_PAT }} \
8585
${{ secrets.DAVINCHIA_PAT }}
8686
87+
8788
# Uncomment to debug.
8889
# changes-output:
8990
# name: "Debug Change Detection Logic"
@@ -235,6 +236,37 @@ jobs:
235236
- name: Ensure no file change
236237
run: git --no-pager diff && test -z "$(git --no-pager diff)"
237238

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

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

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

702-
- name: Upload test results to Github for analysis
703-
if: '!cancelled()' # Run this step even when the tests fail. Skip if the workflow is cancelled.
704-
uses: actions/upload-artifact@v3
705-
with:
706-
path: |
707-
/actions-runner/_work/airbyte/airbyte/*/build/test-results/*/*.xml
708-
/actions-runner/_work/airbyte/airbyte/*/*/build/test-results/*/*.xml
709-
name: test-results-kube
710-
711796
- uses: actions/upload-artifact@v2
712797
if: failure()
713798
with:
714799
name: Kubernetes Logs
715800
path: /tmp/kubernetes_logs/*
801+
802+
716803
# In case of self-hosted EC2 errors, remove this block.
717804
stop-kube-acceptance-test-runner:
718805
name: "Platform: Stop Kube Acceptance Test EC2 Runner"
@@ -859,13 +946,6 @@ jobs:
859946
# SECRET_STORE_GCP_PROJECT_ID: ${{ secrets.SECRET_STORE_GCP_PROJECT_ID }}
860947
# run: |
861948
# CI=true IS_MINIKUBE=true ./tools/bin/acceptance_test_kube_helm.sh
862-
# - name: Generate Test Report
863-
# uses: dorny/test-reporter@v1
864-
# if: always() # run this step even if previous step failed
865-
# with:
866-
# name: Platform Helm E2E Test Report
867-
# path: '/actions-runner/_work/airbyte/airbyte/*/build/test-results/*/*.xml'
868-
# reporter: java-junit
869949
#
870950
# - uses: actions/upload-artifact@v2
871951
# if: failure()
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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 uploads it to GCS with a ".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+
token = os.getenv('GITHUB_TOKEN')
26+
27+
f = open(args.json)
28+
d = json.load(f)
29+
out = []
30+
31+
check_run_id = int(d["check_url"].split("/")[-1])
32+
for elem in d['cases']:
33+
if 'success' in elem['states']:
34+
for i in range(len(elem['states']['success'])):
35+
output = {
36+
"test_name": elem['states']['success'][i]['test_name'],
37+
"class_name": elem['states']['success'][i]['class_name'],
38+
"result_file": elem['states']['success'][i]['result_file'],
39+
"time": elem['states']['success'][i]['time'],
40+
"state": "success",
41+
"check_run_id": check_run_id,
42+
}
43+
out.append(output)
44+
if 'failure' in elem['states']:
45+
for i in range(len(elem['states']['failure'])):
46+
output = {
47+
"test_name": elem['states']['failure'][i]['test_name'],
48+
"class_name": elem['states']['failure'][i]['class_name'],
49+
"result_file": elem['states']['failure'][i]['result_file'],
50+
"time": elem['states']['failure'][i]['time'],
51+
"state": "failure",
52+
"check_run_id": check_run_id,
53+
}
54+
out.append(output)
55+
if 'skipped' in elem['states']:
56+
for i in range(len(elem['states']['skipped'])):
57+
output = {
58+
"test_name": elem['states']['skipped'][i]['test_name'],
59+
"class_name": elem['states']['skipped'][i]['class_name'],
60+
"result_file": elem['states']['skipped'][i]['result_file'],
61+
"time": elem['states']['skipped'][i]['time'],
62+
"state": "skipped",
63+
"check_run_id": check_run_id,
64+
}
65+
out.append(output)
66+
67+
with open(args.json + "l", 'w') as f:
68+
for o in out:
69+
json.dump(o, f)
70+
f.write('\n')
71+
72+
73+
if __name__ == '__main__':
74+
main()

0 commit comments

Comments
 (0)