Skip to content

Commit c6927a7

Browse files
committed
feat: check files before accessing them
1 parent 921a01d commit c6927a7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

.github/workflows/pr-differences-mutants.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ jobs:
6969
cargo mutants --in-diff git.diff --list > all_mutants.txt
7070
mkdir -p mutants_by_packages
7171
72+
# Check that the file exists before performing actions on it
73+
if [ -s all_mutants.txt ]; then
74+
echo "The file containing mutants is missing or empty!"
75+
exit 1
76+
fi
77+
7278
# Split the differences from git into 2 parts, big packages ('stacks-node' and 'stackslib') and small packages (all others) and put them into separate files
7379
while IFS= read -r line; do
7480
package=$(echo "$line" | cut -d'/' -f1)
@@ -242,7 +248,7 @@ jobs:
242248
done
243249
244250
for folder in "${folders[@]}"; do
245-
if [[ -s "$folder" ]]; then
251+
if [[ -s "$folder/exit_code.txt" ]]; then
246252
exit_code=$(<"${folder}/exit_code.txt")
247253
most_relevant_exit_code=0
248254
@@ -346,7 +352,7 @@ jobs:
346352
347353
case $exit_code in
348354
0)
349-
if [ -s ./mutants-shards/unviable.txt ]; then
355+
if [[ -f ./mutants-shards/unviable.txt ]]; then
350356
echo "Found unviable mutants!"
351357
exit 1
352358
fi

0 commit comments

Comments
 (0)