Skip to content

Commit cea19e6

Browse files
committed
chore(ci): fix step ID typo and handle packages without unit tests in coverage job
1 parent 444a007 commit cea19e6

1 file changed

Lines changed: 23 additions & 6 deletions

File tree

.github/workflows/unittest.yml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,18 +134,35 @@ jobs:
134134
id: packages
135135
run: echo "::set-output name=num_files_changed::$(git diff HEAD~1 -- packages | wc -l)"
136136
- name: Install coverage
137-
if: steps.packages.num_files_changed > 0
137+
if: steps.packages.outputs.num_files_changed > 0
138138
run: |
139139
python -m pip install --upgrade setuptools pip wheel
140140
python -m pip install coverage
141141
- name: Download coverage results
142-
if: ${{ steps.date.packages.num_files_changed > 0 }}
142+
if: ${{ steps.packages.outputs.num_files_changed > 0 }}
143143
uses: actions/download-artifact@v4
144144
with:
145145
path: .coverage-results/
146146
- name: Report coverage results
147-
if: ${{ steps.date.packages.num_files_changed > 0 }}
147+
if: ${{ steps.packages.outputs.num_files_changed > 0 }}
148148
run: |
149-
find .coverage-results -type f -name '*.zip' -exec unzip {} \;
150-
coverage combine .coverage-results/**/.coverage*
151-
coverage report --show-missing --fail-under=100
149+
if [ -d .coverage-results ] && find .coverage-results -type f -name '.coverage*' ! -name '.coveragerc*' | grep -q .; then
150+
find .coverage-results -type f -name '*.zip' -exec unzip -o {} \; || true
151+
coverage combine .coverage-results/**/.coverage*
152+
coverage report --show-missing --fail-under=100
153+
else
154+
echo "No coverage files found to combine. Checking if only packages that skip unit tests were modified."
155+
modified_packages=$(git diff --name-only HEAD~1 -- packages | cut -d/ -f1,2 | sort -u)
156+
only_crc32c=true
157+
for pkg in ${modified_packages}; do
158+
if [ "${pkg}" != "packages/google-crc32c" ]; then
159+
only_crc32c=false
160+
fi
161+
done
162+
if [ "${only_crc32c}" = true ]; then
163+
echo "Only packages/google-crc32c was modified which does not support unit test coverage. Skipping coverage check."
164+
else
165+
echo "Error: No coverage results were downloaded, but modified packages are expected to have unit tests."
166+
exit 1
167+
fi
168+
fi

0 commit comments

Comments
 (0)