Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Häni <[email protected]>
  • Loading branch information
sebastianhaeni committed Sep 18, 2023
0 parents commit 9aeb2f4
Show file tree
Hide file tree
Showing 45 changed files with 21,090 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"presets": [
["@babel/preset-env", {
"targets": {
"node": 18
}
}],
"@babel/typescript"
],
"ignore": [
"**/*.d.ts"
]
}
3 changes: 3 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:18

RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm alias 16 system"
20 changes: 20 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "skills17-stryker-helpers",
"build": {
"dockerfile": "Dockerfile"
},
"workspaceFolder": "/workspaces/stryker-helpers",
"remoteUser": "node",
"extensions": [
"dbaeumer.vscode-eslint",
"redhat.vscode-yaml"
],
"settings": {
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"editor.tabSize": 2,
"editor.rulers": [100]
},
"postCreateCommand": "npm install"
}
10 changes: 10 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: '3'

services:
app:
build:
context: .
dockerfile: Dockerfile
volumes:
- ..:/workspaces/stryker-helpers:cached
command: sleep infinity
34 changes: 34 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"extends": [
"airbnb-base",
"plugin:prettier/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"ignorePatterns": [
"**/node_modules/**",
"**/lib/**",
"**/*.d.ts",
"*.d.ts"
],
"settings": {
"import/resolver": {
"node": {
"extensions": [".js", ".ts"]
}
}
},
"rules": {
"import/extensions": ["error", {
"d.ts": "always"
}],
"import/no-import-module-exports": ["off"],
"no-useless-constructor": ["off"],
"no-shadow": ["off"],
"@typescript-eslint/no-shadow": ["error"]
}
}
22 changes: 22 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: CI - lint

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Use Node.js 18
uses: actions/setup-node@v1
with:
node-version: 18
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
27 changes: 27 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CI - test

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: .devcontainer

steps:
- uses: actions/checkout@v2
- name: Start containers
run: docker-compose up -d
- name: Change permissions
run: docker-compose exec -T app chown -R node:node /workspaces/stryker-helpers
- name: Install dependencies
run: docker-compose exec -T --workdir /workspaces/stryker-helpers --user node app npm ci
- name: Build library
run: docker-compose exec -T --workdir /workspaces/stryker-helpers --user node app npm run build
- name: Test
run: docker-compose exec -T --workdir /workspaces/stryker-helpers --user node app npm test
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# os
.DS_Store

# editor
.vscode
.idea

# node
node_modules
npm-debug.log*

# project
lib/
.history/
.stryker-tmp/
reports/
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
5 changes: 5 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"printWidth": 100,
"singleQuote": true,
"trailingComma": "all"
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Sebastian Häni

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
81 changes: 81 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# skills17/stryker-helpers

This package provides Stryker helpers for usage in a skills competition environment. It includes:

- Custom output formatter

## Table of contents

- [Installation](#installation)
- [Usage](#usage)
- [License](#license)

## Installation

**Requirements:**

- Node `18` or greater

To install this package, run the following command:

```bash
npm install @skills17/stryker-helpers
```

It is suggested to add the following npm scripts:

```json
"scripts": {
"test": "skills17-stryker run",
"test:json": "skills17-stryker run --json"
},
```

This will provide the following commands:

- `npm test` - Run all tests once and show a nice output with the awarded points (useful for the competitors to see
their points)
- `npm run test:json` - Run all tests once and get a json output (useful for automated marking scripts)

Points can be awarded for coverage of conditionals and deductions for number of mutants survived. If any test fails in
normal execution, no points will be awarded.

## Usage

A `config.yaml` file needs to be created that contains some information about the task. It should be placed in the root
folder of your task, next to the `package.json` file.

See the [`@skills17/task-config`](https://github.com/skills17/task-config#configuration) package for a detailed
description of all available properties in the `config.yaml` file.

### CLI

As seen in the installation instructions, the `skills17-stryker` command is available.

It is a thin wrapper around the `stryker run` command.

All arguments to the command will be forwarded to `stryker` so Stryker can be used exactly the same way if this package
wouldn't be installed.

Additionally, the following new arguments are available:

- `--json` output the test result with scored points in json to standard out

### Scoring

The generated test names are in the following format:

```
[file key]-[mutant name]
```

The file key is the file name being tested with the extension and `src/` removed. Path separators are replace with `.`.
If multiple mutants with the same name are generated, any surviving mutant will make the test fail.

### Extra tests

With `skills17/stryker-helpers` there are no extra tests needed.

## License

[MIT](https://github.com/skills17/stryker-helpers/blob/master/LICENSE)
8 changes: 8 additions & 0 deletions bin/skills17-stryker
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env node
const CommandWrapper = require('../lib/CommandWrapper').default; // eslint-disable-line @typescript-eslint/no-var-requires

const cmd = new CommandWrapper(process.argv.slice(2));

(async () => {
await cmd.process();
})();
6 changes: 6 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
maxWorkers: 1,
testEnvironment: 'node',
testRegex: '.+\\/tests\\/integration\\/.*\\.test.ts$',
testPathIgnorePatterns: ['/node_modules/', '/\\.stryker-tmp/'],
};
Loading

0 comments on commit 9aeb2f4

Please sign in to comment.