Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Commit

Permalink
feat: fail workflow on missed/timeout mutations on pr (different work…
Browse files Browse the repository at this point in the history
…flow)
  • Loading branch information
ASuciuX committed Dec 5, 2023
1 parent 5424adf commit d414482
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 47 deletions.
25 changes: 0 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
###############################################
Expand Down
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/tracking-pr-mutants.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d414482

Please sign in to comment.