From e6727afb2b89bcd14238d5ed3057b4ac5983d626 Mon Sep 17 00:00:00 2001 From: ASuciuX Date: Fri, 24 Nov 2023 02:46:15 +0200 Subject: [PATCH] feat: initial testing with cargo mutants on a PR, the CI should run the dockerfile --- .../Dockerfile.mutation-tests | 33 +++++++++++++++++++ .gitignore | 1 + build-scripts/mutants.sh | 32 ++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 .github/actions/bitcoin-int-tests/Dockerfile.mutation-tests create mode 100644 build-scripts/mutants.sh diff --git a/.github/actions/bitcoin-int-tests/Dockerfile.mutation-tests b/.github/actions/bitcoin-int-tests/Dockerfile.mutation-tests new file mode 100644 index 0000000000..ff7744353b --- /dev/null +++ b/.github/actions/bitcoin-int-tests/Dockerfile.mutation-tests @@ -0,0 +1,33 @@ +FROM rust:bullseye + +# Set the working directory in the container +WORKDIR /src + +# Copy all the files into the container +COPY . . + +# Update rustup and build the project +RUN rustup update && \ + cargo build + +# Install cargo-mutagen +RUN cargo install cargo-mutagen + +# Remove old log folders (TODO: check if to delete) +# RUN rm -rf mutants.out mutants.out.old/ + +# Make a directory for mutants +RUN mkdir -p mutants + +# Run mutants for different packages +RUN cargo mutants --package clarity --output mutants/clarity && \ + cargo mutants --package libsigner --output mutants/libsigner && \ + cargo mutants --package libstackerdb --output mutants/libstackerdb && \ + cargo mutants --package pox-locking --output mutants/pox-locking && \ + cargo mutants --package stacks-common --output mutants/stacks-common && \ + cargo mutants --package stx-genesis --output mutants/stx-genesis + +# Comment out the commands for 'stacks-node' and 'stackslib' following the mutants.sh script +# RUN cargo mutants --package stacks-signer --output mutants/stacks-signer +# RUN cargo mutants --package stacks-node --output mutants/stacks-node +# RUN cargo mutants --package stackslib --output mutants/stackslib \ No newline at end of file diff --git a/.gitignore b/.gitignore index 5069c47120..ef04f35d59 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ pip-log.txt .coverage .tox nosetests.xml +mutants.out* # Translations *.mo diff --git a/build-scripts/mutants.sh b/build-scripts/mutants.sh new file mode 100644 index 0000000000..c8639d2f52 --- /dev/null +++ b/build-scripts/mutants.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# Create mutants directory +mkdir mutants + +# Run mutation testing for clarity package +cargo mutants --package clarity --output mutants/clarity + +# Run mutation testing for libsigner package +cargo mutants --package libsigner --output mutants/libsigner + +# Run mutation testing for libstackerdb package +cargo mutants --package libstackerdb --output mutants/libstackerdb + +# Run mutation testing for pox-locking package +cargo mutants --package pox-locking --output mutants/pox-locking + +# Run mutation testing for stacks-common package +cargo mutants --package stacks-common --output mutants/stacks-common + +# Run mutation testing for stx-genesis package +cargo mutants --package stx-genesis --output mutants/stx-genesis + + +# Run mutation testing for stacks-signer package - working, 10 min approx. +# cargo mutants --package stacks-signer --output mutants/stacks-signer + +# Commented out mutation testing for stacks-node package due to test errors and long compile/testing time +# cargo mutants --package stacks-node --output mutants/stacks-node + +# Commented out mutation testing for stackslib package due to long compile/testing time +# cargo mutants --package stackslib --output mutants/stackslib \ No newline at end of file