From f83efc28f392c3d26382edb662ac7264b835cbad 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 | 6 ++++++ action.yml | 2 ++ dist/codecov_ats.sh | 9 +++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eac123c..56a3fb6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: diff --git a/action.yml b/action.yml index e6de88e..de67613 100644 --- a/action.yml +++ b/action.yml @@ -75,6 +75,8 @@ branding: runs: using: "composite" + outputs: + ALL_TESTS_SKIPPED: ${{ steps.codecov-ats.outputs.all_tests_skipped }} steps: - id: codecov-ats run: | diff --git a/dist/codecov_ats.sh b/dist/codecov_ats.sh index e6e9f9e..7654388 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,12 @@ tee <<< \ "$GITHUB_STEP_SUMMARY" \ "codecov_ats/result.json" +if [[ "$run_count" -eq 0 ]]; then + # For use in other jobs + echo "all_tests_skipped=1" >> "$GITHUB_OUTPUT" + # For use in current jobs + export all_tests_skipped=1 +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"