Skip to content

Commit 74b10d6

Browse files
authored
11 support strykerjs to be ran with this action (#16)
* test if composite can run docker container * update to right image * revert to local docker image * run local docker image * some other test * run local docker image * does this work? * temp test * update * update arg ref * test for public package * test for public package * chmod stuff; * removed html reporter * update docker image with arguments * does this work? * use github workspace * update * mount github workspace inside of container * shell is mandatory * update * changed target of mount to base * added LS to see what happens.... * list directory * update * update * update * update * update * update * update * update * added workspace to testporject ref * removed ls command * update dockerfile stuff; * renamed stryker.net dockerfile * update * update * update * update * update packge reference * remove not working stuff; * added stryker version * update * update readme * update input parameter name * update base image name * added strykerJS base image * bring back the html report * run strykerJS config * run strykerJS from the pipeline
1 parent 2c186a4 commit 74b10d6

File tree

9 files changed

+107
-15
lines changed

9 files changed

+107
-15
lines changed

.github/workflows/create-base-image.yml renamed to .github/workflows/stryker-net-runner-image.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
name: Create base image for Stryker.NET
1+
name: Stryker.NET base image
22
run-name: ${{ github.actor }} is creating a new base image.
33
on:
44
workflow_dispatch:
55

66
env:
77
REGISTRY: ghcr.io
8-
IMAGE_NAME: ${{ github.repository }}
8+
IMAGE_NAME: stryker-mutator/run-stryker-net
99

1010
jobs:
1111
docker:
@@ -35,6 +35,7 @@ jobs:
3535
uses: docker/build-push-action@v5
3636
with:
3737
context: .
38+
file: ./Stryker_NET.Dockerfile
3839
push: true
3940
tags: ${{ steps.meta.outputs.tags }}
4041
labels: ${{ steps.meta.outputs.labels }}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: StrykerJS base image
2+
run-name: ${{ github.actor }} is creating a new StrykerJS base image.
3+
on:
4+
workflow_dispatch:
5+
6+
env:
7+
REGISTRY: ghcr.io
8+
IMAGE_NAME: stryker-mutator/run-strykerjs
9+
10+
jobs:
11+
docker:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
packages: write
16+
17+
steps:
18+
- name: Check out the repo
19+
uses: actions/checkout@v4
20+
21+
- name: Log in to the Container registry
22+
uses: docker/login-action@b4bedf8053341df3b5a9f9e0f2cf4e79e27360c6
23+
with:
24+
registry: ${{ env.REGISTRY }}
25+
username: ${{ github.actor }}
26+
password: ${{ secrets.GITHUB_TOKEN }}
27+
28+
- name: Extract metadata (tags, labels) for Docker
29+
id: meta
30+
uses: docker/metadata-action@v5
31+
with:
32+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
33+
34+
- name: Build and push Docker image
35+
uses: docker/build-push-action@v5
36+
with:
37+
context: .
38+
file: ./StrykerJS.Dockerfile
39+
push: true
40+
tags: ${{ steps.meta.outputs.tags }}
41+
labels: ${{ steps.meta.outputs.labels }}

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ This action runs [Stryker.NET](https://stryker-mutator.io/docs/stryker-net/intro
44

55
## Inputs
66

7+
### `tool`
8+
9+
**Required** The version of stryker that needs to be ran. accepted values: 'Stryker.NET'
10+
711
### `testProject`
812

913
**Required** The path to the directory of the test project that needs to be tested by Stryker. No default.

StrykerJS.Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM node:14
2+
3+
COPY strykerjs-entrypoint.sh.sh /entrypoint.sh
4+
RUN npm install -g stryker-cli
5+
6+
RUN chmod +x entrypoint.sh
7+
8+
ENTRYPOINT ["/entrypoint.sh"]
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Container image that runs your code
22
FROM mcr.microsoft.com/dotnet/sdk:6.0
33

4-
COPY entrypoint.sh /entrypoint.sh
4+
COPY stryker-net-entrypoint.sh.sh /entrypoint.sh
55
RUN dotnet tool install -g dotnet-stryker
6+
7+
RUN chmod +x entrypoint.sh
8+
9+
ENTRYPOINT ["/entrypoint.sh"]
10+

action.yml

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,43 @@ branding:
55
icon: 'zap'
66
color: 'red'
77
inputs:
8+
tool:
9+
description: "The type of stryker that you want to run (accepted values: Stryker.NET)"
10+
required: true
811
testProject:
912
description: "The path to the test project directory (e.g. BusinessLogic.Test/)"
1013
required: true
11-
breakAt:
12-
description: "When threshold break is set to anything other than 0 and the mutation score is lower than the threshold Stryker will exit with a non-zero code."
14+
configFile:
15+
description: "The path to the stryker config file"
1316
required: false
14-
default: "0"
17+
default: ./
1518

1619
runs:
17-
using: 'docker'
18-
image: 'run-stryker-net.dockerfile'
19-
args:
20-
- ${{ inputs.testProject }}
21-
- ${{ inputs.breakAt }}
20+
using: "composite"
21+
steps:
22+
- name: Check tool
23+
if: ${{ inputs.tool != 'Stryker.NET' }}
24+
run: |
25+
echo "Invalid tool. Expected 'Stryker.NET' or StrykerJS."
26+
exit 1
27+
shell: bash
28+
29+
- name: Run Stryker.NET
30+
if: ${{ inputs.tool == 'Stryker.NET' }}
31+
shell: bash
32+
run: |
33+
docker run \
34+
-v ${{ github.workspace }}:/workspace \
35+
ghcr.io/stryker-mutator/run-stryker-net:11-support-strykerjs-to-be-ran-with-this-action \
36+
/workspace/${{ inputs.testProject }} \
37+
${{ inputs.configFile }} \
38+
39+
- name: Run StrykerJS
40+
if: ${{ inputs.strykerVersion == 'StrykerJS' }}
41+
shell: bash
42+
run: |
43+
docker run \
44+
-v ${{ github.workspace }}:/workspace \
45+
ghcr.io/stryker-mutator/run-strykerjs:11-support-strykerjs-to-be-ran-with-this-action \
46+
/workspace/${{ inputs.testProject }} \
47+
${{ inputs.configFile }} \

run-stryker-net.dockerfile

Lines changed: 0 additions & 3 deletions
This file was deleted.

entrypoint.sh renamed to stryker-net-entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ cd $testProject
88

99
echo "Starting Stryker.NET run"
1010
dotnet stryker \
11-
--break-at $2 \
11+
--config-file $2 \
1212
--reporter html \
1313
--reporter json \
1414
--reporter cleartext

strykerjs-entrypoint.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh -l
2+
testProject=$1
3+
4+
# export PATH="$PATH:/root/.dotnet/tools"
5+
6+
echo "Changing direcotry to $testProject"
7+
cd $testProject
8+
9+
echo "Starting StrykerJS run"
10+
stryker run

0 commit comments

Comments
 (0)