File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 7
7
suitename :
8
8
description : " test suite name"
9
9
required : true
10
+ code_coverage :
11
+ description : whether to collect code coverage metrics during test run
12
+ type : boolean
13
+ default : false
10
14
outputs :
11
15
status :
12
16
description : " final status from test"
44
48
run : |
45
49
source ${{ inputs.venv }}/bin/activate
46
50
rm -rf src
51
+
52
+ if [[ "${ENABLE_COVERAGE}" == "true" ]]; then
53
+ echo "::group::Installing code coverage requirements via pip"
54
+ pip install bashlex https://github.com/neuralmagic/pytest-nm-releng/archive/v0.4.0.tar.gz
55
+ pip install coverage pytest-cov
56
+
57
+ # Adding Code coverage to the tests
58
+ nmre-generate-coverage-flags --package "compressed_tensors" --output-file ".coverage_flags.sh"
59
+ source .coverage_flags.sh
60
+ echo "::endgroup::"
61
+ fi
62
+
63
+ echo "::group::running tests"
64
+ echo "PYTEST_ADDOPTS set to: ${PYTEST_ADDOPTS}"
65
+
47
66
SUCCESS=0
48
67
pytest tests --junitxml=test-results/report.xml -o junit_suite_name="${{ inputs.suitename }}" || SUCCESS=$?
49
68
echo "status=${SUCCESS}" >> "$GITHUB_OUTPUT"
69
+ echo "::endgroup::"
70
+
71
+ 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"
77
+ echo "::endgroup::"
78
+ fi
79
+
50
80
deactivate
51
81
exit ${SUCCESS}
52
82
shell : bash
83
+ env :
84
+ ENABLE_COVERAGE : ${{ inputs.code_coverage || false }}
Original file line number Diff line number Diff line change 25
25
run_id :
26
26
description : run id of the BUILD job that generated the assets
27
27
type : string
28
+ code_coverage :
29
+ description : whether to collect code coverage metrics during test run
30
+ type : boolean
31
+ default : false
28
32
29
33
# makes workflow manually callable
30
34
workflow_dispatch :
51
55
run_id :
52
56
description : run id of the BUILD job that generated the assets
53
57
type : string
58
+ code_coverage :
59
+ description : whether to collect code coverage metrics during test run
60
+ type : boolean
61
+ default : false
54
62
55
63
jobs :
56
64
@@ -124,6 +132,7 @@ jobs:
124
132
with :
125
133
venv : ${{ steps.create_venv.outputs.penv }}
126
134
suitename : test-${{ inputs.python }}-${{ inputs.test_label }}
135
+ code_coverage : ${{ inputs.code_coverage }}
127
136
128
137
- name : summary
129
138
uses : neuralmagic/nm-actions/actions/summary-test@v1.13.0
@@ -146,3 +155,11 @@ jobs:
146
155
name : report-${{ inputs.test_label }}.xml
147
156
path : test-results/report.xml
148
157
retention-days : 5
158
+
159
+ - name : upload coverage report
160
+ uses : actions/upload-artifact@v4
161
+ if : (success() || failure()) && inputs.code_coverage
162
+ with :
163
+ name : coverage-results
164
+ path : coverage-results/*
165
+ retention-days : 5
You can’t perform that action at this time.
0 commit comments