Skip to content

Commit 40ec65b

Browse files
authored
Enable code coverage report for nightly tests (#388)
* enable code coverage * fix error * fix again * switch code coverage to run in another job * try uploading coverage to pages * fix error * fix error * allow pages write permission * fix report path issue and not reporting coverage if tests fail * minor fix * show coverage link in the summary
1 parent 5a451b0 commit 40ec65b

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

.github/actions/test/action.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ runs:
6969
echo "::endgroup::"
7070
7171
if [[ "${ENABLE_COVERAGE}" == "true" ]]; then
72-
echo "::group::consolidating coverage reports"
73-
mkdir -p coverage-results
74-
mv .coverage coverage-results/ || echo ".coverage file not found"
75-
mv coverage-html coverage-results/ || echo "coverage-html folder not found"
76-
mv coverage.json coverage-results/ || echo "coverage.json file not found"
72+
echo "::group::check coverage reports"
73+
if [ ! -d coverage-html ]; then
74+
echo "ERROR: coverage-html folder not found"
75+
exit 1
76+
fi
7777
echo "::endgroup::"
7878
fi
7979

.github/workflows/build-test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ on:
2525

2626
# test related parameters
2727
test_configs:
28-
description: "python, label, timeout"
28+
description: "python, label, timeout, etc"
2929
type: string
3030
required: true
3131

@@ -53,6 +53,7 @@ jobs:
5353
python: ${{ matrix.test_config.python }}
5454
timeout: ${{ matrix.test_config.timeout }}
5555
whl: ${{ needs.BUILD.outputs.whl }}
56+
code_coverage: ${{ matrix.test_config.code_coverage || false }}
5657
secrets: inherit
5758

5859
UPLOAD:

.github/workflows/test.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ jobs:
7070
permissions:
7171
contents: 'read'
7272
id-token: 'write'
73+
pages: 'write'
74+
environment:
75+
name: github-pages
76+
url: ${{ steps.coverage.outputs.page_url }}
7377

7478
steps:
7579

@@ -134,6 +138,11 @@ jobs:
134138
suitename: test-${{ inputs.python }}-${{ inputs.test_label }}
135139
code_coverage: ${{ inputs.code_coverage }}
136140

141+
- name: extra info for summary
142+
if: ${{ inputs.code_coverage }}
143+
run: |
144+
echo "EXTRA='Code Coverage: https://neuralmagic.github.io/compressed-tensors/'" >> $GITHUB_ENV
145+
137146
- name: summary
138147
uses: neuralmagic/nm-actions/actions/summary-test@v1.13.0
139148
if: success() || failure()
@@ -143,6 +152,7 @@ jobs:
143152
python: ${{ inputs.python }}
144153
whl: ${{ inputs.whl }}
145154
test_status: ${{ steps.test.outputs.status }}
155+
extra: ${{ env.EXTRA }}
146156

147157
- name: copy results to GCP
148158
run: |
@@ -157,9 +167,13 @@ jobs:
157167
retention-days: 5
158168

159169
- name: upload coverage report
160-
uses: actions/upload-artifact@v4
161-
if: (success() || failure()) && inputs.code_coverage
170+
uses: actions/upload-pages-artifact@v3
171+
if: ${{ inputs.code_coverage }}
162172
with:
163-
name: coverage-results
164-
path: coverage-results/*
173+
path: coverage-html
165174
retention-days: 5
175+
176+
- name: deploy to Github Pages
177+
id: coverage
178+
uses: actions/deploy-pages@v4
179+
if: ${{ inputs.code_coverage }}

.github/workflows/trigger-all.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
wf_category: ${{ inputs.wf_category || 'NIGHTLY' }}
3333
gitref: ${{ inputs.gitref || 'main' }}
3434
push_to_pypi: ${{ (github.event.schedule == '30 0 * * *') || inputs.push_to_pypi || false }}
35-
test_configs: '[{"python":"3.11.4","label":"ubuntu-24.04","timeout":"40"},
35+
test_configs: '[{"python":"3.11.4","label":"ubuntu-24.04","timeout":"40","code_coverage":true},
3636
{"python":"3.10.12","label":"ubuntu-22.04","timeout":"40"},
3737
{"python":"3.9.17","label":"k8s-h100-solo","timeout":"40"},
3838
{"python":"3.12.6","label":"k8s-a100-duo","timeout":"40"}]'

0 commit comments

Comments
 (0)