Skip to content

Commit

Permalink
11 support strykerjs to be ran with this action (#16)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
tom171296 authored Oct 14, 2023
1 parent 2c186a4 commit 74b10d6
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Create base image for Stryker.NET
name: Stryker.NET base image
run-name: ${{ github.actor }} is creating a new base image.
on:
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
IMAGE_NAME: stryker-mutator/run-stryker-net

jobs:
docker:
Expand Down Expand Up @@ -35,6 +35,7 @@ jobs:
uses: docker/build-push-action@v5
with:
context: .
file: ./Stryker_NET.Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
41 changes: 41 additions & 0 deletions .github/workflows/strykerjs-runner-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: StrykerJS base image
run-name: ${{ github.actor }} is creating a new StrykerJS base image.
on:
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: stryker-mutator/run-strykerjs

jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@b4bedf8053341df3b5a9f9e0f2cf4e79e27360c6
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./StrykerJS.Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ This action runs [Stryker.NET](https://stryker-mutator.io/docs/stryker-net/intro

## Inputs

### `tool`

**Required** The version of stryker that needs to be ran. accepted values: 'Stryker.NET'

### `testProject`

**Required** The path to the directory of the test project that needs to be tested by Stryker. No default.
Expand Down
8 changes: 8 additions & 0 deletions StrykerJS.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM node:14

COPY strykerjs-entrypoint.sh.sh /entrypoint.sh
RUN npm install -g stryker-cli

RUN chmod +x entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
7 changes: 6 additions & 1 deletion Dockerfile → Stryker_NET.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Container image that runs your code
FROM mcr.microsoft.com/dotnet/sdk:6.0

COPY entrypoint.sh /entrypoint.sh
COPY stryker-net-entrypoint.sh.sh /entrypoint.sh
RUN dotnet tool install -g dotnet-stryker

RUN chmod +x entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]

42 changes: 34 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,43 @@ branding:
icon: 'zap'
color: 'red'
inputs:
tool:
description: "The type of stryker that you want to run (accepted values: Stryker.NET)"
required: true
testProject:
description: "The path to the test project directory (e.g. BusinessLogic.Test/)"
required: true
breakAt:
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."
configFile:
description: "The path to the stryker config file"
required: false
default: "0"
default: ./

runs:
using: 'docker'
image: 'run-stryker-net.dockerfile'
args:
- ${{ inputs.testProject }}
- ${{ inputs.breakAt }}
using: "composite"
steps:
- name: Check tool
if: ${{ inputs.tool != 'Stryker.NET' }}
run: |
echo "Invalid tool. Expected 'Stryker.NET' or StrykerJS."
exit 1
shell: bash

- name: Run Stryker.NET
if: ${{ inputs.tool == 'Stryker.NET' }}
shell: bash
run: |
docker run \
-v ${{ github.workspace }}:/workspace \
ghcr.io/stryker-mutator/run-stryker-net:11-support-strykerjs-to-be-ran-with-this-action \
/workspace/${{ inputs.testProject }} \
${{ inputs.configFile }} \
- name: Run StrykerJS
if: ${{ inputs.strykerVersion == 'StrykerJS' }}
shell: bash
run: |
docker run \
-v ${{ github.workspace }}:/workspace \
ghcr.io/stryker-mutator/run-strykerjs:11-support-strykerjs-to-be-ran-with-this-action \
/workspace/${{ inputs.testProject }} \
${{ inputs.configFile }} \
3 changes: 0 additions & 3 deletions run-stryker-net.dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion entrypoint.sh → stryker-net-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ cd $testProject

echo "Starting Stryker.NET run"
dotnet stryker \
--break-at $2 \
--config-file $2 \
--reporter html \
--reporter json \
--reporter cleartext
10 changes: 10 additions & 0 deletions strykerjs-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh -l
testProject=$1

# export PATH="$PATH:/root/.dotnet/tools"

echo "Changing direcotry to $testProject"
cd $testProject

echo "Starting StrykerJS run"
stryker run

0 comments on commit 74b10d6

Please sign in to comment.