Skip to content

Commit d072691

Browse files
[HOTFIX] Fix for Coveralls reporting in CI/CD (- WIP #130 -)
Changes in file .github/actions/test-reporter-upload/action.yml: * added debug logging * fix for windows edge-case error handling * related work Changes in file .github/workflows/CI-BUILD.yml: * minor update to tie license to build with attestation in CI/CD Changes in file .github/workflows/Tests.yml: * new job to trigger Coveralls API to signal when reporting compleates for a build-id * related work
1 parent bae04d7 commit d072691

File tree

3 files changed

+86
-32
lines changed

3 files changed

+86
-32
lines changed

.github/actions/test-reporter-upload/action.yml

Lines changed: 57 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,25 @@ outputs:
7070
description: "The SHA of the commit checked-out"
7171
value: ${{ steps.output_sha.outputs.sha || 'HEAD' }}
7272
can_upload:
73-
description: "Can the upload tool even be used?"
73+
description: "Can the upload tools even be used?"
7474
value: ${{ steps.output_can_upload.outputs.can_upload || 'false' }}
7575
status:
7676
description: "The outcome of the coverage test reporter action."
7777
value: ${{ steps.coverage_outcome.outputs.status || 'cancelled' }}
7878
coverage_upload_codecov_outcome:
79+
description: "The outcome of the CodeCov coverage test reporter action."
7980
value: ${{ steps.coverage-codecov-upload.outcome || 'cancelled' }}
8081
coverage_upload_codeclimate_outcome:
82+
description: "The outcome of the CodeClimate coverage test reporter action."
8183
value: ${{ steps.coverage-codeclimate-upload.outcome || 'cancelled' }}
8284
coverage_upload_deepsource_outcome:
85+
description: "The outcome of the DeepSource coverage test reporter action."
8386
value: ${{ steps.coverage-deepsource-upload.outcome || 'cancelled' }}
8487
coverage_upload_coveralls_outcome:
88+
description: "The outcome of the Coveralls coverage test reporter action."
8589
value: ${{ steps.coverage-coveralls-upload.outcome || 'cancelled' }}
8690
coverage_upload_artifact_outcome:
91+
description: "The outcome of the coverage test upload action."
8792
value: ${{ steps.coverage-reports-upload.outcome || 'cancelled' }}
8893

8994
runs:
@@ -94,6 +99,7 @@ runs:
9499
shell: bash
95100
run: |
96101
printf "sha=%s\n" $(git rev-parse --verify HEAD) >> "$GITHUB_OUTPUT"
102+
printf "::debug::%s %s\n" "Will report coverage for" $(git rev-parse --verify HEAD)
97103
printf "BUILD_SHA=%s\n" $(git rev-parse --verify HEAD) >> "$GITHUB_ENV"
98104
- name: "Identify Python Version"
99105
id: output_python
@@ -109,6 +115,11 @@ runs:
109115
printf "python-version=%s\n" "${PYTHON_VERSION}" >> "$GITHUB_OUTPUT"
110116
fi
111117
printf "%s\n" "PYTHON_VERSION=${PYTHON_VERSION}" >> "$GITHUB_ENV"
118+
if [[ -z $PYTHON_VERSION ]] ; then
119+
printf "::debug::%s\n" "Found Python version ${PYTHON_VERSION}"
120+
else
121+
printf "::debug::%s\n" "Missing Python version"
122+
fi
112123
- name: "Identify Operating System"
113124
id: output_os
114125
if: ${{ !cancelled() }}
@@ -122,6 +133,12 @@ runs:
122133
else
123134
printf "os=%s\n" "${OS:-unknown}" >> "$GITHUB_OUTPUT"
124135
fi
136+
if [[ -z $OS ]] ; then
137+
printf "::debug::%s\n" "Identified ${OS}"
138+
else
139+
printf "::error file=.github/actions/test-reporter-upload/action.yml::%s\n" "Invalid OS"
140+
exit 1
141+
fi
125142
printf "%s\n" "OS=${OS}" >> "$GITHUB_ENV"
126143
- name: "Prepare Artifact Name"
127144
id: output_artifact_name
@@ -145,7 +162,7 @@ runs:
145162
printf "can_upload_to_codeclimate=true\n" >> "$GITHUB_OUTPUT"
146163
printf "::debug::%s\n" "Found ${{ github.workspace }}/cc-test-reporter"
147164
else
148-
printf "::warning, title='Missing tool':: %s\n" "Can't find cc-test-reporter tool."
165+
printf "::warning title='Missing tool':: %s\n" "Can't find cc-test-reporter tool."
149166
printf "can_upload_to_codeclimate=false\n" >> "$GITHUB_OUTPUT"
150167
fi
151168
LOCALBIN="${{ github.workspace }}/bin"
@@ -156,25 +173,25 @@ runs:
156173
printf "::debug::%s\n" "Found ${BINDIR:-${LOCALBIN}}/coveralls"
157174
printf "coveralls_executable=${BINDIR:-${LOCALBIN}}/coveralls\n" >> "$GITHUB_OUTPUT"
158175
else
159-
printf "::warning, title='Missing tool':: %s\n" "Can't find coveralls tool."
176+
printf "::warning title='Missing tool':: %s\n" "Can't find coveralls tool."
160177
printf "can_upload_to_coveralls=false\n" >> "$GITHUB_OUTPUT"
161178
fi
162179
if [[ -x "${BINDIR:-${LOCALBIN}}/deepsource" ]] ; then
163180
printf "can_upload_to_deepsource=true\n" >> "$GITHUB_OUTPUT"
164181
printf "::debug::%s\n" "Found ${BINDIR:-${LOCALBIN}}/deepsource"
165182
printf "deepsource_executable=%s\n" "${BINDIR:-${LOCALBIN}}/deepsource" >> "$GITHUB_OUTPUT"
166183
else
167-
printf "::warning, title='Missing tool':: %s\n" "Can't find deepsource tool."
184+
printf "::warning title='Missing tool':: %s\n" "Can't find deepsource tool."
168185
printf "can_upload_to_deepsource=false\n" >> "$GITHUB_OUTPUT"
169186
fi
170187
else
171-
printf "::notice, title='Missing BINDIR':: %s\n" "Can't find ${BINDIR:-${LOCALBIN}}."
188+
printf "::notice title='Missing BINDIR':: %s\n" "Can't find ${BINDIR:-${LOCALBIN}}."
172189
if [[ -x $(command -v coveralls) ]] ; then
173190
printf "can_upload_to_coveralls=true\n" >> "$GITHUB_OUTPUT"
174191
printf "::debug::%s %s\n" "Found" $(command -v coveralls)
175192
printf "coveralls_executable=%s\n" $(command -v coveralls) >> "$GITHUB_OUTPUT"
176193
else
177-
printf "::warning, title='Missing tool':: %s\n" "Can't find coveralls tool."
194+
printf "::warning title='Missing tool':: %s\n" "Can't find coveralls tool."
178195
printf "can_upload_to_coveralls=false\n" >> "$GITHUB_OUTPUT"
179196
printf "coveralls_executable=coveralls\n" >> "$GITHUB_OUTPUT"
180197
fi
@@ -183,37 +200,39 @@ runs:
183200
printf "::debug::%s %s\n" "Found" $(command -v deepsource)
184201
printf "deepsource_executable=%s\n" $(command -v deepsource) >> "$GITHUB_OUTPUT"
185202
else
186-
printf "::warning, title='Missing tool':: %s\n" "Can't find deepsource tool."
203+
printf "::warning title='Missing tool':: %s\n" "Can't find deepsource tool."
187204
printf "can_upload_to_deepsource=false\n" >> "$GITHUB_OUTPUT"
188205
printf "deepsource_executable=deepsource\n" >> "$GITHUB_OUTPUT"
189206
fi
190207
fi
191208
else
192-
printf "::warning, title='Missing tools':: %s\n" "Can't find any supported tool."
209+
printf "::warning title='Missing tools':: %s\n" "Can't find any supported tool."
193210
printf "can_upload_to_codeclimate=false\n" >> "$GITHUB_OUTPUT"
194211
printf "can_upload_to_coveralls=false\n" >> "$GITHUB_OUTPUT"
195212
printf "can_upload_to_deepsource=false\n" >> "$GITHUB_OUTPUT"
196213
fi
197214
if [[ -d "${{ github.workspace }}/test-reports" ]] ; then
198-
if [[ ( -x $(command -v coverage3) ) ]] ; then
199-
printf "\n" >> "${GITHUB_STEP_SUMMARY}"
200-
coverage3 combine --keep --data-file=coverage_codecov ./.coverage.* 2>/dev/null || true
201-
wait ;
202-
coverage3 report -m --include=multicast/* --ignore-errors --data-file=coverage_codecov 2>/dev/null >> "${GITHUB_STEP_SUMMARY}" || true
203-
if [[ ! ( -f "${{ github.workspace }}/test-reports/coverage.xml" ) ]] ; then
204-
coverage3 xml -o "${{ github.workspace }}/test-reports/coverage.xml" --data-file=coverage_codecov --include=multicast/* 2>/dev/null || true
205-
fi ;
206-
rm -f coverage_codecov 2>/dev/null || true ; wait ;
207-
printf "\n\n" >> "${GITHUB_STEP_SUMMARY}"
208-
elif [[ ( -x $(command -v coverage) ) ]] ; then
209-
coverage combine --keep --data-file=coverage_codecov ./.coverage.* 2>/dev/null || true
210-
wait ;
211-
coverage report -m --include=multicast/* --ignore-errors --data-file=coverage_codecov --format=markdown 2>/dev/null >> "${GITHUB_STEP_SUMMARY}" || true
212-
if [[ ! ( -f "${{ github.workspace }}/test-reports/coverage.xml" ) ]] ; then
213-
coverage xml -o "${{ github.workspace }}/test-reports/coverage.xml" --include=multicast/* --data-file=coverage_codecov 2>/dev/null || true
214-
fi ;
215-
rm -f coverage_codecov 2>/dev/null || true ; wait ;
216-
printf "\n\n" >> "${GITHUB_STEP_SUMMARY}"
215+
if [[ ( -e ./.coverage.* ) ]] ; then
216+
if [[ ( -x $(command -v coverage3) ) ]] ; then
217+
printf "\n" >> "${GITHUB_STEP_SUMMARY}"
218+
coverage3 combine --keep --data-file=coverage_codecov ./.coverage.* 2>/dev/null || true
219+
wait ;
220+
coverage3 report -m --include=multicast/* --ignore-errors --data-file=coverage_codecov 2>/dev/null >> "${GITHUB_STEP_SUMMARY}" || true
221+
if [[ ! ( -f "${{ github.workspace }}/test-reports/coverage.xml" ) ]] ; then
222+
coverage3 xml -o "${{ github.workspace }}/test-reports/coverage.xml" --data-file=coverage_codecov --include=multicast/* 2>/dev/null || true
223+
fi ;
224+
rm -f coverage_codecov 2>/dev/null || true ; wait ;
225+
printf "\n\n" >> "${GITHUB_STEP_SUMMARY}"
226+
elif [[ ( -x $(command -v coverage) ) ]] ; then
227+
coverage combine --keep --data-file=coverage_codecov ./.coverage.* 2>/dev/null || true
228+
wait ;
229+
coverage report -m --include=multicast/* --ignore-errors --data-file=coverage_codecov --format=markdown 2>/dev/null >> "${GITHUB_STEP_SUMMARY}" || true
230+
if [[ ! ( -f "${{ github.workspace }}/test-reports/coverage.xml" ) ]] ; then
231+
coverage xml -o "${{ github.workspace }}/test-reports/coverage.xml" --include=multicast/* --data-file=coverage_codecov 2>/dev/null || true
232+
fi ;
233+
rm -f coverage_codecov 2>/dev/null || true ; wait ;
234+
printf "\n\n" >> "${GITHUB_STEP_SUMMARY}"
235+
fi
217236
fi
218237
if [[ -f "${{ github.workspace }}/test-reports/coverage.xml" ]] ; then
219238
printf "can_upload_to_codecov=true\n" >> "$GITHUB_OUTPUT"
@@ -235,7 +254,11 @@ runs:
235254
[[ "${{ steps.output_upload_tools.outputs.can_upload_to_deepsource }}" == "true" ]] ; then
236255
THE_RESULT="success"
237256
else
238-
THE_RESULT="failure"
257+
if [[ "${OS}" != "Windows" ]] ; then
258+
THE_RESULT="failure"
259+
else
260+
THE_RESULT="skipped" # Windows need only upload coverage artifact
261+
fi
239262
fi
240263
else
241264
THE_RESULT="skipped"
@@ -255,7 +278,9 @@ runs:
255278
if: ${{ !cancelled() && (steps.output_can_upload.outputs.can_upload == 'true') && (steps.output_upload_tools.outputs.can_upload_to_codecov == 'true') }}
256279
shell: bash
257280
run: |
258-
${{ github.workspace }}/tests/check_codecov || exit 1
281+
if [[ "${OS}" != "unknown" ]] ; then
282+
${{ github.workspace }}/tests/check_codecov || exit 1
283+
fi # else just finish with implied success
259284
- name: Upload ${{ steps.output_os.outputs.os }} Python ${{ steps.output_python.outputs.python-version }} coverage to Codecov
260285
id: coverage-codecov-upload
261286
if: ${{ success() && (steps.output_can_upload.outputs.can_upload == 'true') && (steps.output_upload_tools.outputs.can_upload_to_codecov == 'true') }}
@@ -302,7 +327,7 @@ runs:
302327
DEEPSOURCE_DSN: ${{ github.server_url == 'https://github.com' && inputs.deepsource-dsn || '' }}
303328
DEEPSOURCE_TOOL: ${{ steps.output_upload_tools.outputs.deepsource_executable }}
304329
run: |
305-
${DEEPSOURCE_TOOL} report --analyzer test-coverage --key python --value-file ./coverage.xml 2>/dev/null
330+
${DEEPSOURCE_TOOL} report --analyzer test-coverage --key python --value-file ${COV_CORE_DATAFILE:-./coverage.xml} 2>/dev/null
306331
- name: Upload ${{ steps.output_os.outputs.os }} Python ${{ steps.output_python.outputs.python-version }} coverage to coveralls
307332
if: ${{ !cancelled() && (steps.output_can_upload.outputs.can_upload == 'true') && (steps.output_upload_tools.outputs.can_upload_to_coveralls == 'true') && (steps.output_os.outputs.os != 'Windows') && (github.repository == 'reactive-firewall/multicast') }}
308333
id: coverage-coveralls-upload
@@ -312,9 +337,9 @@ runs:
312337
COVERALLS_TOOL: ${{ steps.output_upload_tools.outputs.coveralls_executable }}
313338
run: |
314339
if [[ "${{ inputs.tests-outcome }}" == "success" ]] ; then
315-
${COVERALLS_TOOL} report ./coverage.xml --base-path="${{ github.workspace }}" --service-job-id=${{ github.run_id }} --parallel --job-flag='${{ steps.output_os.outputs.os }}-${{ steps.output_python.outputs.python-version }}' --build-number=${{ inputs.job_code }} || exit 1 ;
340+
${COVERALLS_TOOL} report ${COV_CORE_DATAFILE:-./coverage.xml} --base-path="${{ github.workspace }}" --service-job-id=${{ github.run_id }} --parallel --job-flag='${{ steps.output_os.outputs.os }}-${{ steps.output_python.outputs.python-version }}' --build-number=${{ inputs.job_code }} || exit 1 ;
316341
else
317-
${COVERALLS_TOOL} report ./coverage.xml --base-path="${{ github.workspace }}" --allow-empty --service-job-id=${{ github.run_id }} --parallel --job-flag='${{ steps.output_os.outputs.os }}-${{ steps.output_python.outputs.python-version }}' --build-number=${{ inputs.job_code }} || exit 1 ;
342+
${COVERALLS_TOOL} report ${COV_CORE_DATAFILE:-./coverage.xml} --base-path="${{ github.workspace }}" --allow-empty --service-job-id=${{ github.run_id }} --parallel --job-flag='${{ steps.output_os.outputs.os }}-${{ steps.output_python.outputs.python-version }}' --build-number=${{ inputs.job_code }} || exit 1 ;
318343
fi
319344
- name: "Evaluate Coverage Report Task"
320345
id: coverage_outcome

.github/workflows/CI-BUILD.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,18 @@ jobs:
6767
- name: Pre-Clean
6868
id: clean
6969
run: make -j1 -f Makefile purge 2>/dev/null || true
70+
- name: "License"
71+
id: show-build-license
72+
shell: bash
73+
if: ${{ !cancelled() && (github.repository == 'reactive-firewall/multicast') }}
74+
run: |
75+
if [[ -r LICENSE.md ]] ; then
76+
printf "\n\n"
77+
cat <LICENSE.md ;
78+
printf "\n\n"
79+
else
80+
printf "%s\n" "::warning title=UNLICENSED:: This is an UNLICENSED Build"
81+
fi
7082
- name: Test Build
7183
id: build
7284
run: make -j1 -f Makefile build

.github/workflows/Tests.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,23 @@ jobs:
746746
token: ${{ github.token }}
747747
body-path: '${{ steps.download-coverage-summary.outputs.download-path }}/COVERAGE-Summary-Artifact.txt'
748748

749+
COVERALLS_SIGNAL_DONE:
750+
permissions:
751+
actions: read
752+
contents: read
753+
needs: [check_mats, COVERAGE, DOCTESTS]
754+
if: ${{ always() && (needs.check_mats.outputs.should_run == 'true') }}
755+
runs-on: ubuntu-latest
756+
steps:
757+
- name: Signal Coveralls Finished
758+
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2.3.6
759+
with:
760+
build-number: ${{ needs.check_mats.outputs.tests_id }}
761+
parallel-finished: true
762+
git-commit: ${{ needs.check_mats.outputs.build_sha }}
763+
allow-empty: true
764+
fail-on-error: false
765+
749766
STYLE:
750767
permissions:
751768
actions: read

0 commit comments

Comments
 (0)