From 27b1a31d85137df3ff7364f7f4329a990420fabb Mon Sep 17 00:00:00 2001 From: Gguidini Date: Fri, 22 Dec 2023 14:14:04 -0300 Subject: [PATCH] export variable to let users know if all tests were skipped --- .github/workflows/ci.yml | 7 +++++++ dist/codecov_ats.sh | 11 +++++++++-- src/codecov_ats.sh | 9 +++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eac123c..3f116bb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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: diff --git a/dist/codecov_ats.sh b/dist/codecov_ats.sh index e6e9f9e..885918e 100755 --- a/dist/codecov_ats.sh +++ b/dist/codecov_ats.sh @@ -119,9 +119,7 @@ fi # Create directory to put result files mkdir codecov_ats # 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 @@ -141,5 +139,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" +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" diff --git a/src/codecov_ats.sh b/src/codecov_ats.sh index f339b6a..07f6036 100755 --- a/src/codecov_ats.sh +++ b/src/codecov_ats.sh @@ -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" +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"