mirror of
https://github.com/verilator/verilator.git
synced 2026-09-02 18:58:51 +02:00
CI: Factor out coverage report generation
This commit is contained in:
@@ -132,52 +132,35 @@ jobs:
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
ls -lsha obj_coverage
|
||||
# Combine reports from test jobs
|
||||
nodist/fastcov.py -C obj_coverage/verilator-*.info --lcov -o obj_coverage/verilator.info
|
||||
# For a PR, report patch coverage against the merge-base between the head of the PR and the target branch
|
||||
ci/ci-coverage-report.bash \
|
||||
${{ github.run_id }} \
|
||||
"${{ github.event_name == 'pull_request' && github.event.number || '' }}" \
|
||||
"${{ github.event.pull_request.base.sha }}" \
|
||||
"${{ github.event.pull_request.head.sha }}"
|
||||
# Create the report artifact. Note there is no report if the patch is empty.
|
||||
mkdir ../report-artifact
|
||||
[ ! -d obj_coverage/report ] || mv obj_coverage/report ../report-artifact/
|
||||
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
|
||||
COVERAGE_BASE=$(git rev-parse --short $(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}))
|
||||
make coverage-report COVERAGE_BASE=${COVERAGE_BASE} |& tee ${{ github.workspace }}/make-coverage-report.log
|
||||
else
|
||||
make coverage-report
|
||||
echo ${{ github.event.number }} > ../report-artifact/pr-number.txt
|
||||
fi
|
||||
# Remove data files
|
||||
rm -f obj_coverage/verilator*.info
|
||||
# Some extra work for PRs only
|
||||
# Create the notification artifact, for pull requests only
|
||||
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
|
||||
# Save PR number in report
|
||||
echo ${{ github.event.number }} > obj_coverage/pr-number.txt
|
||||
# Generate notification comment content
|
||||
mkdir -p notification
|
||||
echo ${{ github.event.number }} > notification/pr-number.txt
|
||||
NUM=$(gh run view ${{ github.run_id }} --json number --jq ".number")
|
||||
URL=$(gh run view ${{ github.run_id }} --json url --jq ".url")
|
||||
echo "Patch coverage from PR workflow [#$NUM]($URL) (code coverage of lines changed relative to ${COVERAGE_BASE}):" > notification/body.txt
|
||||
if [[ ! -f obj_coverage/empty-patch ]]; then
|
||||
echo "<pre>" >> notification/body.txt
|
||||
grep -E "(lines|branches)\.*:" ${{ github.workspace }}/make-coverage-report.log | sed "s/\.*:/:/" >> notification/body.txt || true
|
||||
echo "</pre>" >> notification/body.txt
|
||||
echo "Report: [${{ github.run_id }}](https://${{ github.repository_owner }}.github.io/verilator/coverage-reports/${{ github.run_id }}/index.html)" >> notification/body.txt
|
||||
echo "" >> notification/body.txt
|
||||
echo "Please get to 100% line coverage, and understand all branches; see https://github.com/verilator/verilator/blob/master/docs/internals.rst#code-coverage-results" >> notification/body.txt
|
||||
else
|
||||
echo "Patch contains no code changes" >> notification/body.txt
|
||||
fi
|
||||
cat notification/body.txt
|
||||
mkdir ../notification-artifact
|
||||
mv obj_coverage/notification.txt ../notification-artifact/body.txt
|
||||
echo ${{ github.event.number }} > ../notification-artifact/pr-number.txt
|
||||
fi
|
||||
|
||||
- name: Upload report
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
|
||||
with:
|
||||
path: repo/obj_coverage
|
||||
path: report-artifact
|
||||
name: coverage-report
|
||||
|
||||
- name: Upload notification
|
||||
if: ${{ github.event_name == 'pull_request' }}
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
|
||||
with:
|
||||
path: repo/notification
|
||||
path: notification-artifact
|
||||
name: pr-notification
|
||||
|
||||
# Create GitHub issue for failed scheduled jobs
|
||||
|
||||
Reference in New Issue
Block a user