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

Deployer/testing shell script #3

Deployer/testing shell script

Deployer/testing shell script #3

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
working-directory: ./mutation-testing/scripts
- uses: Swatinem/rust-cache@v2
- run: cargo install cargo-mutants
- name: Remove deleted file lines from git.diff file
run: ./remove-deleted-file-lines.sh
working-directory: ./mutation-testing/scripts
- name: Mutants
run: |
cargo mutants --no-shuffle -j 2 -vV --in-diff git.diff || true
working-directory: ./mutation-testing/scripts
- name: Check the exit code of the 'mutants' command, and if the mutations are not caught, fail the workflow
run: |
exit_code=$?
case $exit_code in
0)
if [ -s ./unviable.txt ]; then
echo "-------------"
echo "Found unviable mutants:"
cat ./unviable.txt
exit 1
fi
echo "All new and updated functions are caught!"
;;
1)
echo "Invalid command line arguments!"
exit 1
;;
2 | 3)
if [ -s ./missed.txt ]; then
echo "Found missed mutants:"
cat ./missed.txt
fi
if [ -s ./timeout.txt ]; then
echo "-------------"
echo "Found timeout mutants:"
cat ./timeout.txt
fi
if [ -s ./unviable.txt ]; then
echo "-------------"
echo "Found unviable mutants:"
cat ./unviable.txt
fi
exit 1
;;
4)
echo "Building the packages failed without any mutations!"
exit 1
;;
*)
echo "Unknown exit code: $exit_code"
exit 1
;;
esac
working-directory: ./mutants.out