Skip to content

Commit 7e82abb

Browse files
authored
Merge pull request #6 from Chisanan232/release
🎉🎊🍾 [New Feature + Breaking Change] (config) Modify the process about organizing and uploading testing coverage reports.
2 parents 8ce5155 + 7a13a35 commit 7e82abb

4 files changed

+95
-17
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
############################################################################
2+
#
3+
# Workflow Description:
4+
# Organize all the testing coverage reports. (it would save reports by 'actions/upload-artifact@v3').
5+
#
6+
# Workflow input parameters:
7+
# * test_type: The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'.
8+
# * generate_xml_report_finally: Something, it only has 1 test type currently. So it could let this option
9+
# to be 'true' than it would generate XML report finally to let uploading process to use it directly.
10+
#
11+
# Workflow running output:
12+
# No, but it would save the testing coverage reports (coverage.xml) to provide after-process to organize and record.
13+
#
14+
############################################################################
15+
16+
name: Organize testing coverage reports as a testing coverage report
17+
18+
on:
19+
workflow_call:
20+
inputs:
21+
test_type:
22+
description: "The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'."
23+
required: true
24+
type: string
25+
generate_xml_report_finally:
26+
description: "Something, it only has 1 test type currently. So it could let this option to be 'true' than it would generate XML report finally to let uploading process to use it directly."
27+
required: true
28+
type: boolean
29+
30+
31+
jobs:
32+
organize_and_generate_test_report:
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v2
37+
38+
- name: Download code coverage result file
39+
uses: actions/download-artifact@v3
40+
with:
41+
name: coverage
42+
path: .coverage.${{ inputs.test_type }}*
43+
44+
- name: Setup Python 3.10 in Ubuntu OS
45+
uses: actions/setup-python@v2
46+
with:
47+
python-version: '3.10'
48+
49+
- name: Install Python tool 'coverage'
50+
run: |
51+
python3 -m pip install --upgrade pip
52+
pip3 install -U pip
53+
pip3 install coverage
54+
55+
- name: Combine all code coverage result files
56+
run: coverage combine .coverage.*
57+
58+
- name: Report testing coverage of project code
59+
run: coverage report -m
60+
61+
- name: General testing coverage report as XML format
62+
if: ${{ inputs.generate_xml_report_finally }} == 'true'
63+
run: coverage xml
64+
65+
- name: Rename the testing coverage report with test type
66+
if: ${{ inputs.generate_xml_report_finally }} == 'false'
67+
run: mv .coverage .coverage-${{ inputs.test_type }}
68+
69+
- name: Upload testing coverage report
70+
if: ${{ inputs.generate_xml_report_finally }} == 'true'
71+
uses: actions/upload-artifact@v3
72+
with:
73+
name: final_project_testing_coverage_report
74+
path: coverage.xml
75+
if-no-files-found: error
76+
77+
- name: Upload testing coverage report
78+
if: ${{ inputs.generate_xml_report_finally }} == 'false'
79+
uses: actions/upload-artifact@v3
80+
with:
81+
name: project_testing_coverage_report
82+
path: .coverage-${{ inputs.test_type }}
83+
if-no-files-found: error

.github/workflows/organize_and_generate_testing_report.yaml renamed to .github/workflows/organize_all_testing_reports_with_different_test_type.yaml

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,17 @@
44
# Organize all the testing coverage reports. (it would save reports by 'actions/upload-artifact@v3').
55
#
66
# Workflow input parameters:
7-
# * test_type: The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'.
7+
# No input parameters.
88
#
99
# Workflow running output:
1010
# No, but it would save the testing coverage reports (coverage.xml) to provide after-process to organize and record.
1111
#
1212
############################################################################
1313

14-
name: Upload test report to Codecov
14+
name: Organize all testing coverage reports, e.g., different runtime OS, as a final testing coverage report.
1515

1616
on:
1717
workflow_call:
18-
inputs:
19-
test_type:
20-
description: "The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'."
21-
required: true
22-
type: string
2318

2419

2520
jobs:
@@ -32,8 +27,8 @@ jobs:
3227
- name: Download code coverage result file
3328
uses: actions/download-artifact@v3
3429
with:
35-
name: coverage
36-
path: .coverage.${{ inputs.test_type }}*
30+
name: project_testing_coverage_report
31+
path: .coverage-*
3732

3833
- name: Setup Python 3.10 in Ubuntu OS
3934
uses: actions/setup-python@v2
@@ -42,22 +37,22 @@ jobs:
4237

4338
- name: Install Python tool 'coverage'
4439
run: |
45-
python3 -m pip install --upgrade pip
46-
pip3 install -U pip
47-
pip3 install coverage
40+
python -m pip install --upgrade pip
41+
pip install -U pip
42+
pip install coverage
4843
4944
- name: Combine all code coverage result files
50-
run: coverage combine .coverage.*
45+
run: coverage combine .coverage-*
5146

5247
- name: Report testing coverage of project code
5348
run: coverage report -m
5449

55-
- name: Generate testing report for Codacy
50+
- name: Generate testing coverage report as XML file
5651
run: coverage xml
5752

5853
- name: Upload testing coverage report
5954
uses: actions/upload-artifact@v3
6055
with:
61-
name: project_coverage_report
56+
name: final_project_testing_coverage_report
6257
path: coverage.xml
6358
if-no-files-found: error

.github/workflows/upload_code_report_to_codacy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
- name: Download testing coverage report
3939
uses: actions/download-artifact@v3
4040
with:
41-
name: project_coverage_report
41+
name: final_project_testing_coverage_report
4242
path: ${{ inputs.download_path }}
4343

4444
- name: Generate testing report for Codacy

.github/workflows/upload_test_report_to_codecov.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
- name: Download code coverage result file
5252
uses: actions/download-artifact@v3
5353
with:
54-
name: project_coverage_report
54+
name: final_project_testing_coverage_report
5555
path: ${{ inputs.download_path }}
5656

5757
- name: Upload coverage report to platform Codecov

0 commit comments

Comments
 (0)