|
| 1 | +--- |
| 2 | +name: 'Purge Code Coverage Tools' |
| 3 | +description: 'Purge various Code Coverage tools' |
| 4 | +author: 'Mr. Walls' |
| 5 | +branding: |
| 6 | + icon: 'delete' |
| 7 | + color: 'white' |
| 8 | +inputs: |
| 9 | + token: |
| 10 | + description: | |
| 11 | + The token used to authenticate when performing GitHub API operations. |
| 12 | + When running this action on github.com, the default value is sufficient. When running on |
| 13 | + GHES, you can pass a personal access token for github.com if you are experiencing |
| 14 | + rate limiting. |
| 15 | + default: ${{ github.server_url == 'https://github.com' && github.token || '' }} |
| 16 | + required: true |
| 17 | + codeclimate-token: |
| 18 | + description: | |
| 19 | + The token used to authenticate when performing codeclimate API operations. |
| 20 | + default: '' |
| 21 | + required: true |
| 22 | + cc-test-reporter-id: |
| 23 | + description: | |
| 24 | + The id used to report tests when performing codeclimate API operations. |
| 25 | + default: '' |
| 26 | + required: true |
| 27 | + deepsource-dsn: |
| 28 | + description: | |
| 29 | + The deepsource DSN when performing deepsource API operations. |
| 30 | + default: '' |
| 31 | + required: true |
| 32 | + coveralls-token: |
| 33 | + description: | |
| 34 | + The coveralls token used when performing coveralls API operations. |
| 35 | + default: '' |
| 36 | + required: true |
| 37 | +outputs: |
| 38 | + sha: |
| 39 | + description: "The SHA of the commit checked-out" |
| 40 | + value: ${{ steps.output_sha.outputs.sha || 'HEAD' }} |
| 41 | + can_purge: |
| 42 | + description: "Can the purge tool even be used?" |
| 43 | + value: ${{ steps.output_can_purge.outputs.can_purge || 'false' }} |
| 44 | + status: |
| 45 | + description: "The outcome of the purge test reporter action." |
| 46 | + value: ${{ steps.purge_outcome.outputs.status || 'cancelled' }} |
| 47 | + |
| 48 | +runs: |
| 49 | + using: composite |
| 50 | + steps: |
| 51 | + - name: "Calculate Commit SHA" |
| 52 | + id: output_sha |
| 53 | + shell: bash |
| 54 | + run: | |
| 55 | + printf "sha=%s\n" $(git rev-parse --verify HEAD) >> "$GITHUB_OUTPUT" |
| 56 | + printf "FETCH_SHA=%s\n" $(git rev-parse --verify HEAD) >> "$GITHUB_ENV" |
| 57 | + - name: "Check has Purge Tool" |
| 58 | + id: output_can_purge |
| 59 | + shell: bash |
| 60 | + run: | |
| 61 | + if [[ -x ${{ github.workspace }}/.github/tools/fetch-test-reporter/purge-test-reporter ]] ; then |
| 62 | + printf "can_purge=true\n" >> "$GITHUB_OUTPUT" |
| 63 | + printf "::debug::%s\n" "Found ${{ github.workspace }}/.github/tools/fetch-test-reporter/purge-test-reporter" |
| 64 | + else |
| 65 | + printf "::warning, title='Missing tool':: %s\n" "Can't find purge-test-reporter tool." |
| 66 | + printf "can_purge=false\n" >> "$GITHUB_OUTPUT" |
| 67 | + fi |
| 68 | + - name: "Finalize test reporter tools on ${{ runner.os }}" |
| 69 | + id: purge-test-reporter-main |
| 70 | + if: ${{ !cancelled() && (steps.output_can_purge.outputs.can_purge == 'true') && (runner.os != 'Windows') && (github.repository == 'reactive-firewall/multicast') }} |
| 71 | + shell: bash |
| 72 | + env: |
| 73 | + CODECLIMATE_REPO_TOKEN: ${{ github.server_url == 'https://github.com' && inputs.codeclimate-token || '' }} |
| 74 | + CC_TEST_REPORTER_ID: ${{ github.server_url == 'https://github.com' && inputs.cc-test-reporter-id || '' }} |
| 75 | + COVERALLS_REPO_TOKEN: ${{ github.server_url == 'https://github.com' && inputs.coveralls-token || '' }} |
| 76 | + DEEPSOURCE_DSN: ${{ github.server_url == 'https://github.com' && inputs.deepsource-dsn || '' }} |
| 77 | + run: | |
| 78 | + ${{ github.workspace }}/.github/tools/fetch-test-reporter/purge-test-reporter || exit $? |
| 79 | + - name: "Evaluate Fetch Task" |
| 80 | + id: purge_outcome |
| 81 | + if: ${{ !cancelled() }} |
| 82 | + shell: bash |
| 83 | + run: | |
| 84 | + if [[ "${{ steps.output_can_purge.outputs.can_purge }}" == "true" ]] ; then |
| 85 | + if [[ "${{ steps.purge-test-reporter-main.outcome }}" == "success" ]] ; then |
| 86 | + THE_RESULT="success" |
| 87 | + else |
| 88 | + THE_RESULT="failure" |
| 89 | + fi ; |
| 90 | + else |
| 91 | + THE_RESULT="skipped" |
| 92 | + fi |
| 93 | + printf "status=%s\n" "${THE_RESULT}" >> "$GITHUB_OUTPUT" |
| 94 | + if [[ "${THE_RESULT}" == "failure" ]] ; then |
| 95 | + exit 1 |
| 96 | + else |
| 97 | + exit 0 |
| 98 | + fi |
0 commit comments