|
| 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 |
0 commit comments