diff --git a/.github/workflows/mutation.yml b/.github/workflows/mutation.yml new file mode 100644 index 00000000..c9d9f8ef --- /dev/null +++ b/.github/workflows/mutation.yml @@ -0,0 +1,31 @@ +name: Mutation Testing Quality Gate + +on: + push: + branches: + - main + pull_request: + branches: + - '*' + +jobs: + mutation-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + - name: Install dependencies + run: npm ci + - name: Run mutation tests + run: npm run test:mutation + - name: Enforce mutation score threshold + run: | + MUTATION_SCORE=$(cat reports/mutation/mutation.json | jq '.mutationScore' -r) + echo "Mutation Score: $MUTATION_SCORE" + if (( $(echo "$MUTATION_SCORE < 80" | bc -l) )); then + echo "Mutation score below threshold (80). Failing CI." + exit 1 + fi