From 8ea78e6a541f9da64abe5eff91bd63faee66357a Mon Sep 17 00:00:00 2001 From: AugistineCreates Date: Fri, 29 May 2026 19:45:41 +0100 Subject: [PATCH] Add mutation testing quality gate script and CI workflow --- .github/workflows/mutation.yml | 31 +++++++++++++++++++++++++++++++ package.json | 3 ++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/mutation.yml 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 diff --git a/package.json b/package.json index 7fa84eff..1294dfac 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,8 @@ "sdk:generate": "echo 'Start dev server first (npm run dev), then run: openapi-generator-cli generate -i http://localhost:3000/docs/openapi.json -c sdk-config.yaml -o sdk'", "sdk:build": "cd sdk && ./gradlew build", "docs:dev": "npm --prefix docs-portal run start", - "docs:build": "npm --prefix docs-portal run build" + "docs:build": "npm --prefix docs-portal run build", + "quality-gate": "npm run test && npm run test:mutation" }, "lint-staged": { "*.{ts,tsx,js,cjs,mjs,json,md,yml,yaml}": "prettier --write"