Skip to content

Commit

Permalink
feat(stryker): enable dashboard (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinezanardi authored Jun 19, 2023
1 parent 8a10a30 commit ee6a487
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 38 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ jobs:
mutant-tests:
name: Mutant Tests 👽
runs-on: ubuntu-latest
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
VERSION: ${{ github.head_ref }}
needs:
- install
steps:
Expand Down Expand Up @@ -195,4 +198,4 @@ jobs:
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,34 @@ jobs:
- name: Install project dependencies 📦
run: npm ci --ignore-scripts
if: steps.cache-node-modules.outputs.cache-hit != 'true'
mutant-tests:
name: Mutant Tests 👽
runs-on: ubuntu-latest
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
VERSION: 'main'
needs:
- install
steps:
- name: Checkout GitHub repository 📡
uses: actions/checkout@v3
- name: Setup NodeJS v20 ⚙️
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Restore npm dependencies from cache 🥡
uses: actions/cache/restore@v3
id: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-npm-v3-${{ hashFiles('package-lock.json') }}
- name: Start Docker containers 🐳
run: npm run docker:test:start
- name: Mutant tests 👽
run: npm run test:stryker
- name: Stop Docker containers 🐳
run: npm run docker:test:stop
release:
name: Release 🏷️
runs-on: ubuntu-latest
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=antoinezanardi_werewolves-assistant-api-next&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=antoinezanardi_werewolves-assistant-api-next)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=antoinezanardi_werewolves-assistant-api-next&metric=coverage)](https://sonarcloud.io/summary/new_code?id=antoinezanardi_werewolves-assistant-api-next)

[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fantoinezanardi%2Fwerewolves-assistant-api-next%2Fmain)](https://dashboard.stryker-mutator.io/reports/github.com/antoinezanardi/werewolves-assistant-api-next/main)

![Build Status](https://github.com/antoinezanardi/werewolves-assistant-api-next/actions/workflows/build.yml/badge.svg)
![Release Status](https://github.com/antoinezanardi/werewolves-assistant-api-next/actions/workflows/release.yml/badge.svg)

![TypeScript](https://img.shields.io/badge/-TypeScript-black?style=for-the-badge&logoColor=white&logo=typescript&color=2F73BF)
![Nest](https://img.shields.io/badge/-NestJs-black?style=for-the-badge&logo=nestjs&color=E0234D)
Expand Down Expand Up @@ -103,7 +106,9 @@ Unit and E2E tests are orchestrated with :

Mutant testing is also available with :

![Stryker](https://img.shields.io/badge/-Stryker-black?style=for-the-badge&logoColor=white&logo=stripe&color=7F1B10)
![Stryker](https://img.shields.io/badge/-Stryker-black?style=for-the-badge&logoColor=white&logo=stripe&color=7F1B10)
[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fantoinezanardi%2Fwerewolves-assistant-api-next%2Fmain)](https://dashboard.stryker-mutator.io/reports/github.com/antoinezanardi/werewolves-assistant-api-next/main)


Before testing, you must follow the [installation steps](#installation).

Expand Down
42 changes: 42 additions & 0 deletions config/stryker/stryker.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const reporters = ["clear-text", "progress", "html", "json"];
const dashboard = {
project: "github.com/antoinezanardi/werewolves-assistant-api-next",
baseUrl: "https://dashboard.stryker-mutator.io/api/reports",
reportType: "full",
};
const version = process.env.VERSION;

if (process.env.STRYKER_DASHBOARD_API_KEY !== undefined) {
reporters.push("dashboard");
}

if (process.env.VERSION !== undefined) {
dashboard.version = version;
}

module.exports = {
cleanTempDir: "always",
incremental: true,
incrementalFile: "tests/stryker/incremental.json",
checkers: ["typescript"],
tsconfigFile: "tsconfig.json",
testRunner: "jest",
ignoreStatic: true,
mutate: [
"src/**/*.ts",
"!**/*.dto.ts",
"!**/*.schema.ts",
"!**/*.constant.ts",
],
jest: { configFile: "config/jest/jest-global.ts" },
reporters,
htmlReporter: { fileName: "tests/stryker/coverage/index.html" },
jsonReporter: { fileName: "tests/stryker/coverage/mutation.json" },
thresholds: {
high: 100,
low: 100,
break: 100,
},
disableTypeChecks: "{test,src,lib}/**/*.{js,ts,jsx,tsx,html,vue}",
dashboard,
};
34 changes: 0 additions & 34 deletions config/stryker/stryker.conf.json

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"test": "NODE_ENV=test jest --config config/jest/jest-global.ts",
"test:watch": "NODE_ENV=test jest --watch --config config/jest/jest-global.ts",
"test:cov": "NODE_ENV=test jest --coverage --config config/jest/jest-global.ts",
"test:stryker": "NODE_ENV=test rimraf tests/stryker/coverage && stryker run config/stryker/stryker.conf.json",
"test:stryker:force": "NODE_ENV=test rimraf tests/stryker/incremental.json tests/stryker/coverage && stryker run config/stryker/stryker.conf.json --force",
"test:stryker": "NODE_ENV=test rimraf tests/stryker/coverage && stryker run config/stryker/stryker.conf.js",
"test:stryker:force": "NODE_ENV=test rimraf tests/stryker/incremental.json tests/stryker/coverage && stryker run config/stryker/stryker.conf.js --force",
"test:unit": "NODE_ENV=test jest --config config/jest/jest-unit.ts",
"test:unit:watch": "NODE_ENV=test jest --watch --config config/jest/jest-unit.ts",
"test:unit:cov": "NODE_ENV=test rimraf tests/unit/coverage && jest --coverage --config config/jest/jest-unit.ts",
Expand Down

0 comments on commit ee6a487

Please sign in to comment.