Skip to content

Commit 7b1cc3a

Browse files
chore(github) add coverage report action to local tests (#2501)
* chore: add coverage report action to local tests * chore: set coverage threshold * add additional coverage report for changed files * activate environment in action * fix the changed files filtering * only create changed files coverage report if there are any changed files * tmp * add threshold to changed files report as well
1 parent 7d21fe6 commit 7b1cc3a

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

.github/workflows/run_tests.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,50 @@ jobs:
155155
pytest --cov=tidy3d -rF --tb=short tests/_test_data/_test_datasets_no_vtk.py
156156
pytest --cov=tidy3d -rF --tb=short tests
157157
coverage report -m
158+
coverage xml -o coverage.xml
158159
TOTAL_COVERAGE=$(coverage report --format=total)
159160
echo "total=$TOTAL_COVERAGE" >> "$GITHUB_ENV"
160161
echo "### Total coverage: ${TOTAL_COVERAGE}%"
161162
163+
- name: Produce the coverage report
164+
uses: insightsengineering/coverage-action@v2
165+
with:
166+
path: ./coverage.xml
167+
threshold: 90.0
168+
fail: false
169+
publish: true
170+
diff: true
171+
diff-branch: develop
172+
diff-storage: _xml_coverage_reports
173+
coverage-summary-title: "Code Coverage Summary"
174+
togglable-report: true
175+
176+
- name: Changed files
177+
id: diff
178+
uses: step-security/changed-files@v46
179+
with:
180+
files: '**/*.py'
181+
182+
- name: Slice report down to changed files
183+
if: ${{ steps.diff.outputs.all_changed_files != '' }}
184+
env:
185+
CHANGED: ${{ steps.diff.outputs.all_changed_files }}
186+
run: |
187+
echo $CHANGED
188+
source ${GITHUB_WORKSPACE}/.venv/bin/activate
189+
include=$(printf '%s\n' $CHANGED | sed 's|^|**/|' | paste -sd, -)
190+
coverage xml -i -o changed.xml --include="$include"
191+
192+
- name: Produce the changed files coverage report
193+
uses: insightsengineering/coverage-action@v2
194+
if: ${{ steps.diff.outputs.all_changed_files != '' }}
195+
with:
196+
path: ./changed.xml
197+
threshold: 90.0
198+
publish: true
199+
fail: false
200+
coverage-summary-title: "Changed Files Coverage"
201+
162202
remote-tests:
163203
# Run tests on a push event OR a workflow dispatch with remote_tests
164204
needs: determine-test-scope

0 commit comments

Comments
 (0)