From d4144824b335fd8caf026893f26bd2f603d2fb27 Mon Sep 17 00:00:00 2001 From: ASuciuX Date: Tue, 5 Dec 2023 17:13:46 +0200 Subject: [PATCH] feat: fail workflow on missed/timeout mutations on pr (different workflow) --- .github/workflows/ci.yml | 25 ------------- .../{mutants.yml => logging-mutants.yml} | 31 +++++----------- .github/workflows/tracking-pr-mutants.yml | 36 +++++++++++++++++++ 3 files changed, 45 insertions(+), 47 deletions(-) rename .github/workflows/{mutants.yml => logging-mutants.yml} (91%) create mode 100644 .github/workflows/tracking-pr-mutants.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5e9eaee6fb..a5de0144af 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -75,31 +75,6 @@ jobs: base: ${{ env.BRANCH_NAME }} head: HEAD - ## Mutants testing: Execute on PR on packages that have tested functions modified - incremental-mutants: - name: Incremental Mutants Testing - runs-on: ubuntu-latest - if: github.event_name == 'pull_request' - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 # do we want to fetch all? - - name: Relative diff - run: | - git branch -av - git diff origin/${{ github.base_ref }}.. | tee git.diff - - uses: Swatinem/rust-cache@v2 - - run: cargo install cargo-mutants - - name: Mutants - run: | - cargo mutants --no-shuffle -j 2 -vV --in-diff git.diff || true - - name: Archive mutants.out - uses: actions/upload-artifact@v3 - if: always() - with: - name: mutants-incremental.out - path: mutants.out - ############################################### ## Build Tagged Release ############################################### diff --git a/.github/workflows/mutants.yml b/.github/workflows/logging-mutants.yml similarity index 91% rename from .github/workflows/mutants.yml rename to .github/workflows/logging-mutants.yml index 4c44b748a1..a13e6864e1 100644 --- a/.github/workflows/mutants.yml +++ b/.github/workflows/logging-mutants.yml @@ -1,11 +1,14 @@ -name: Mutants -# to be tried cache vs artifacts +name: Logging Mutants -# only run on push in order to update the artifact output +# only run on push in order to update the cache output # flow: -# download artifact -# run sh script for cargo mutants diff -# upload artifact +# restore cache +# install cargo-mutants crate in order to run the 'cargo mutants' command +# create a file with the current commit hash if a previous one doesn't exist, then print it +# run the script that handles the 'cargo mutants' command on the differences between the latest updates and the last commit where it was ran +# overwrite the previous commit hash with the current one for the following run +# delete the old cache +# save the new cache with the updated mutants on: push: @@ -52,22 +55,6 @@ jobs: fi working-directory: ./mutation-testing/scripts - - name: Check if we have missed/timeout mutants, and if so, fail the workflow - run: | - if [ -s ./missed.txt ] || [ -s ./timeout.txt ]; then - echo "Found timed out or missed mutants, aborting..." - echo "missed.txt:" - cat ./missed.txt - echo "------------------" - echo "timeout.txt:" - cat ./timeout.txt - exit 1; - else - rm -rf ../git.diff - rm -rf ../temp - fi - working-directory: ./mutation-testing/temp/mutants.out - - name: Re-write the old commit hash with the current one run: | echo "${{ github.sha }}" > last_commit_hash.txt diff --git a/.github/workflows/tracking-pr-mutants.yml b/.github/workflows/tracking-pr-mutants.yml new file mode 100644 index 0000000000..5ad80c493a --- /dev/null +++ b/.github/workflows/tracking-pr-mutants.yml @@ -0,0 +1,36 @@ +name: Tracking PR Mutants + +on: + pull_request: + +jobs: + # Mutants testing: Execute on PR on packages that have functions modified, and fail the workflow if there are missed or timeout mutations + incremental-mutants: + name: Incremental Mutants Testing + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Relative diff + run: | + git branch -av + git diff origin/${{ github.base_ref }}.. | tee git.diff + - uses: Swatinem/rust-cache@v2 + - run: cargo install cargo-mutants + - name: Mutants + run: | + cargo mutants --no-shuffle -j 2 -vV --in-diff git.diff || true + - name: Check if we have missed/timeout mutants, and if so, fail the workflow + run: | + if [ -s ./missed.txt ] || [ -s ./timeout.txt ]; then + echo "Found timed out or missed mutants, aborting..." + echo "missed.txt:" + cat ./missed.txt + echo "------------------" + echo "timeout.txt:" + cat ./timeout.txt + exit 1; + fi + working-directory: ./mutants.out \ No newline at end of file