Skip to content

Commit 19407ab

Browse files
committed
Added null checks for coverage workflow
1 parent 2b4e257 commit 19407ab

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

.github/workflows/coverage-check-parallel.yml

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,40 @@ jobs:
2222
id: discover
2323
run: |
2424
# Find all test files in e2e directory
25-
E2E_FILES=$(find tests/e2e -name "test_*.py" -type f | sort | jq -R -s -c 'split("\n")[:-1]')
26-
echo "e2e-test-files=$E2E_FILES" >> $GITHUB_OUTPUT
27-
echo "Discovered E2E test files: $E2E_FILES"
25+
E2E_FILES=$(find tests/e2e -name "test_*.py" -type f | sort)
26+
if [ -n "$E2E_FILES" ]; then
27+
E2E_JSON=$(echo "$E2E_FILES" | jq -R -s -c 'split("\n")[:-1]')
28+
else
29+
E2E_JSON="[]"
30+
fi
31+
echo "e2e-test-files=$E2E_JSON" >> $GITHUB_OUTPUT
32+
echo "Discovered E2E test files: $E2E_JSON"
2833
2934
# Find all test files in unit directory
30-
UNIT_FILES=$(find tests/unit -name "test_*.py" -type f | sort | jq -R -s -c 'split("\n")[:-1]')
31-
echo "unit-test-files=$UNIT_FILES" >> $GITHUB_OUTPUT
32-
echo "Discovered unit test files: $UNIT_FILES"
35+
UNIT_FILES=$(find tests/unit -name "test_*.py" -type f | sort)
36+
if [ -n "$UNIT_FILES" ]; then
37+
UNIT_JSON=$(echo "$UNIT_FILES" | jq -R -s -c 'split("\n")[:-1]')
38+
else
39+
UNIT_JSON="[]"
40+
fi
41+
echo "unit-test-files=$UNIT_JSON" >> $GITHUB_OUTPUT
42+
echo "Discovered unit test files: $UNIT_JSON"
3343
3444
# Find all test files in common directory
35-
COMMON_FILES=$(find tests/e2e/common -name "*.py" -type f | grep -v __init__ | sort | jq -R -s -c 'split("\n")[:-1]')
36-
echo "common-test-files=$COMMON_FILES" >> $GITHUB_OUTPUT
37-
echo "Discovered common test files: $COMMON_FILES"
45+
COMMON_FILES=$(find tests/e2e/common -name "*.py" -type f | grep -v __init__ | sort)
46+
if [ -n "$COMMON_FILES" ]; then
47+
COMMON_JSON=$(echo "$COMMON_FILES" | jq -R -s -c 'split("\n")[:-1]')
48+
else
49+
COMMON_JSON="[]"
50+
fi
51+
echo "common-test-files=$COMMON_JSON" >> $GITHUB_OUTPUT
52+
echo "Discovered common test files: $COMMON_JSON"
3853
3954
e2e-tests:
4055
runs-on: ubuntu-latest
4156
environment: azure-prod
4257
needs: discover-tests
58+
if: ${{ fromJson(needs.discover-tests.outputs.e2e-test-files)[0] != null }}
4359
strategy:
4460
matrix:
4561
test_file: ${{ fromJson(needs.discover-tests.outputs.e2e-test-files) }}
@@ -138,6 +154,7 @@ jobs:
138154
unit-tests:
139155
runs-on: ubuntu-latest
140156
needs: discover-tests
157+
if: ${{ fromJson(needs.discover-tests.outputs.unit-test-files)[0] != null }}
141158
strategy:
142159
matrix:
143160
test_file: ${{ fromJson(needs.discover-tests.outputs.unit-test-files) }}
@@ -218,6 +235,7 @@ jobs:
218235
common-tests:
219236
runs-on: ubuntu-latest
220237
needs: discover-tests
238+
if: ${{ fromJson(needs.discover-tests.outputs.common-test-files)[0] != null }}
221239
strategy:
222240
matrix:
223241
test_file: ${{ fromJson(needs.discover-tests.outputs.common-test-files) }}
@@ -298,6 +316,7 @@ jobs:
298316
merge-coverage:
299317
runs-on: ubuntu-latest
300318
needs: [e2e-tests, unit-tests, common-tests]
319+
if: always()
301320
steps:
302321
- name: Check out repository
303322
uses: actions/checkout@v4

0 commit comments

Comments
 (0)