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 27b1a31
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
- name: Install python dependencies
run: pip install -r app/requirements.txt
- name: Run ATS
id: run_ats
uses: ./
with:
folders_to_exclude: node_modules
Expand All @@ -36,12 +37,18 @@ jobs:
CODECOV_STATIC_TOKEN: ${{ secrets.CODECOV_STATIC_TOKEN }}
- name: "[debug] see content of generated files"
run: |
echo ${{ steps.run_ats.outputs.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 [[ "${{ steps.run_ats.outputs.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
11 changes: 9 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,14 @@ 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
# Export 'all_tests_skipped' variable
if [[ "$run_count" -eq 0 ]]; then

Check warning on line 143 in dist/codecov_ats.sh

View check run for this annotation

Codecov / codecov/patch

dist/codecov_ats.sh#L143

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

Check warning on line 145 in dist/codecov_ats.sh

View check run for this annotation

Codecov / codecov/patch

dist/codecov_ats.sh#L145

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

Check warning on line 148 in dist/codecov_ats.sh

View check run for this annotation

Codecov / codecov/patch

dist/codecov_ats.sh#L148

Added line #L148 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 152 in dist/codecov_ats.sh

View check run for this annotation

Codecov / codecov/patch

dist/codecov_ats.sh#L151-L152

Added lines #L151 - L152 were not covered by tests
9 changes: 9 additions & 0 deletions src/codecov_ats.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,14 @@ tee <<< \
"$GITHUB_STEP_SUMMARY" \
"codecov_ats/result.json"
# Export 'all_tests_skipped' variable
if [[ "$run_count" -eq 0 ]]; then
# For use in other jobs
echo "all_tests_skipped=1" >> "$GITHUB_OUTPUT"
else
# For use in other jobs
echo "all_tests_skipped=0" >> "$GITHUB_OUTPUT"

Check warning on line 149 in src/codecov_ats.sh

View check run for this annotation

Codecov / codecov/patch

src/codecov_ats.sh#L149

Added line #L149 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"

0 comments on commit 27b1a31

Please sign in to comment.