Skip to content

Commit

Permalink
export variable to let users know if all tests were skipped
Browse files Browse the repository at this point in the history
  • Loading branch information
giovanni-guidini committed Dec 22, 2023
1 parent b24dbec commit f83efc2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,18 @@ jobs:
CODECOV_STATIC_TOKEN: ${{ secrets.CODECOV_STATIC_TOKEN }}
- name: "[debug] see content of generated files"
run: |
echo $all_tests_skipped
ls codecov_ats
cat codecov_ats/tests_to_run.txt
cat codecov_ats/tests_to_skip.txt
- name: Run Tests and collect coverage (if there are tests to run)
run: |
if [[ "$all_tests_skipped" != 1 ]]; then
cat codecov_ats/tests_to_run.txt | xargs pytest --cov app
fi
- name: "[debug] Running skipped tests"
run: |
cat codecov_ats/tests_to_skip.txt | xargs pytest --cov app
- name: Upload to Codecov
uses: codecov/codecov-action@v4-beta
env:
Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ branding:

runs:
using: "composite"
outputs:
ALL_TESTS_SKIPPED: ${{ steps.codecov-ats.outputs.all_tests_skipped }}
steps:
- id: codecov-ats
run: |
Expand Down
9 changes: 7 additions & 2 deletions dist/codecov_ats.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,7 @@ fi
# Create directory to put result files
mkdir codecov_ats

Check warning on line 120 in dist/codecov_ats.sh

View check run for this annotation

Codecov / codecov/patch

dist/codecov_ats.sh#L120

Added line #L120 was not covered by tests
# Export tests to run and tests to skip into respective files
jq <<< "$response" '.runner_options + .ats_tests_to_run | @json' --raw-output > codecov_ats/tests_to_run.json
jq <<< "$response" '.runner_options + .ats_tests_to_run | @sh' --raw-output > codecov_ats/tests_to_run.txt
jq <<< "$response" '.runner_options + .ats_tests_to_skip | @json' --raw-output > codecov_ats/tests_to_skip.json
jq <<< "$response" '.runner_options + .ats_tests_to_skip | @sh' --raw-output > codecov_ats/tests_to_skip.txt

Check warning on line 123 in dist/codecov_ats.sh

View check run for this annotation

Codecov / codecov/patch

dist/codecov_ats.sh#L122-L123

Added lines #L122 - L123 were not covered by tests


Expand All @@ -141,5 +139,12 @@ tee <<< \
"$GITHUB_STEP_SUMMARY" \
"codecov_ats/result.json"

Check warning on line 140 in dist/codecov_ats.sh

View check run for this annotation

Codecov / codecov/patch

dist/codecov_ats.sh#L137-L140

Added lines #L137 - L140 were not covered by tests
if [[ "$run_count" -eq 0 ]]; then

Check warning on line 142 in dist/codecov_ats.sh

View check run for this annotation

Codecov / codecov/patch

dist/codecov_ats.sh#L142

Added line #L142 was not covered by tests
# For use in other jobs
echo "all_tests_skipped=1" >> "$GITHUB_OUTPUT"

Check warning on line 144 in dist/codecov_ats.sh

View check run for this annotation

Codecov / codecov/patch

dist/codecov_ats.sh#L144

Added line #L144 was not covered by tests
# For use in current jobs
export all_tests_skipped=1

Check warning on line 146 in dist/codecov_ats.sh

View check run for this annotation

Codecov / codecov/patch

dist/codecov_ats.sh#L146

Added line #L146 was not covered by tests
fi
echo "Tests to run exported to ./codecov_ats/tests_to_run.txt"
echo "Tests to run exported to ./codecov_ats/tests_to_skip.txt"

Check warning on line 150 in dist/codecov_ats.sh

View check run for this annotation

Codecov / codecov/patch

dist/codecov_ats.sh#L149-L150

Added lines #L149 - L150 were not covered by tests

0 comments on commit f83efc2

Please sign in to comment.