From d895a46624d7507c68a5c87b75fa9ae22cc2d1ef Mon Sep 17 00:00:00 2001 From: Matjaz Verbole Date: Mon, 3 Jun 2024 10:03:49 +0200 Subject: [PATCH] Add slither-mutate support in GH actions --- .github/workflows/slither-mutate.yml | 36 ++++++++++++++++++++++++++++ test/scripts/runSlitherMutate.sh | 20 ++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 .github/workflows/slither-mutate.yml create mode 100755 test/scripts/runSlitherMutate.sh diff --git a/.github/workflows/slither-mutate.yml b/.github/workflows/slither-mutate.yml new file mode 100644 index 00000000..bcbaa6d9 --- /dev/null +++ b/.github/workflows/slither-mutate.yml @@ -0,0 +1,36 @@ +name: Slither Mutate Analysis + +#on: workflow_dispatch +on: + pull_request: + branches: [ main ] + +env: + FOUNDRY_PROFILE: ci + +jobs: + check: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + with: + version: nightly + + - name: Install Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install Slither + run: | + pip install slither-analyzer + + - name: Run Slither-Mutate + run: | + slither-mutate . --test-cmd='forge test' --test-dir='test' --ignore-dirs='script,lib,test,utils,deployment' + id: slither-mutate diff --git a/test/scripts/runSlitherMutate.sh b/test/scripts/runSlitherMutate.sh new file mode 100755 index 00000000..f2421d01 --- /dev/null +++ b/test/scripts/runSlitherMutate.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +echo "Instructing the shell to exit immediately if any command returns a non-zero exit status..." +set -e +echo "Done." + +echo "Navigating to the root directory of the project..." +cd ../../ +echo "Done." + +echo "Removing directory mutation_campaign if it exists..." +if [ -d "mutation_campaign" ] +then + rm -rf mutation_campaign +fi +echo "Done." + +echo "Starting Slither Mutate Campaign..." +slither-mutate . --test-cmd='forge test' --test-dir='test' --ignore-dirs='script,lib,test,utils,cache,out,broadcast,deployment' +echo "Done."