1- name : Lint and test
1+ name : Lint, Test, and Mutation
22
33on :
44 push :
@@ -107,3 +107,103 @@ jobs:
107107
108108 - name : Test coverage
109109 uses : coverallsapp/github-action@v2
110+
111+ mutation-test :
112+ name : Stryker Mutation Tests
113+ runs-on : ubuntu-latest
114+ needs : test # only run if regular tests pass
115+ if : github.event_name == 'pull_request' || github.ref == 'refs/heads/main' # only on PRs
116+ env :
117+ TEST_ENV : ' production'
118+
119+ services :
120+ redis :
121+ image : ' redis:8.0.1'
122+ # Set health checks to wait until redis has started
123+ options : >-
124+ --health-cmd "redis-cli ping"
125+ --health-interval 10s
126+ --health-timeout 5s
127+ --health-retries 5
128+ ports :
129+ # Maps port 6379 on service container to the host
130+ - 6379:6379
131+
132+ steps :
133+ - uses : actions/checkout@v4
134+
135+ - name : Install Node
136+ uses : actions/setup-node@v4
137+ with :
138+ node-version : 22
139+
140+ - name : NPM Install
141+ uses : bahmutov/npm-install@v1
142+ with :
143+ useLockFile : false
144+
145+ - name : Setup on Redis
146+ env :
147+ SETUP : >-
148+ {
149+ "url": "http://127.0.0.1:4567/forum",
150+ "secret": "abcdef",
151+ "admin:username": "admin",
152+ "admin:email": "test@example.org",
153+ "admin:password": "hAN3Eg8W",
154+ "admin:password:confirm": "hAN3Eg8W",
155+
156+ "database": "redis",
157+ "redis:host": "127.0.0.1",
158+ "redis:port": 6379,
159+ "redis:password": "",
160+ "redis:database": 0
161+ }
162+ CI : >-
163+ {
164+ "host": "127.0.0.1",
165+ "database": 1,
166+ "port": 6379
167+ }
168+ MAILGUN_API_KEY: ${{ secrets.MAILGUN_API_KEY }}
169+ MAILGUN_DOMAIN: ${{ secrets.MAILGUN_DOMAIN }}
170+ run : |
171+ node app --setup="${SETUP}" --ci="${CI}"
172+
173+ # add test_database to config.json
174+ - name : Add test_database to config.json
175+ run : |
176+ test -f config.json || echo '{}' > config.json
177+ jq '. + {
178+ "test_database": {
179+ "host": "127.0.0.1",
180+ "port": 6379,
181+ "password": "",
182+ "database": 1
183+ }
184+ }' config.json > config.json.tmp && mv config.json.tmp config.json
185+ echo "✅ Injected test_database into config.json:"
186+ cat config.json
187+
188+ - name : Copy config into Stryker sandboxes
189+ run : |
190+ mkdir -p .stryker-tmp
191+ find .stryker-tmp -type d -name "sandbox-*" -exec cp config.json {}/config.json \; || true
192+
193+ - name : Run Stryker Mutation Testing
194+ env :
195+ NODE_ENV : test
196+ REDIS_HOST : 127.0.0.1
197+ REDIS_PORT : 6379
198+ run : |
199+ echo "Running Stryker mutation tests with Mocha runner..."
200+ rm -f .stryker-incremental.json
201+ npx stryker run
202+ SCORE=$(jq -r '.mutationScore' reports/mutation/mutation.json 2>/dev/null || echo "0")
203+ echo "SCORE=$SCORE" >> $GITHUB_ENV
204+
205+ - name : Upload mutation report artifact
206+ uses : actions/upload-artifact@v4
207+ with :
208+ name : mutation-report
209+ path : reports/mutation
0 commit comments