-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path33-frontend-pr-mutation-testing.yml
More file actions
94 lines (79 loc) · 3.24 KB
/
Copy path33-frontend-pr-mutation-testing.yml
File metadata and controls
94 lines (79 loc) · 3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: "33-frontend-pr-mutation-testing: Stryker JS Mutation Testing (JavaScript/Jest)"
# This workflow pulls incremental mutation testing results
# if they exist for the given PR, and then
# uses those incremental results to run mutation testing faster.
# Reference: https://stryker-mutator.io/docs/stryker-js/incremental/
on:
workflow_dispatch:
pull_request:
paths: [frontend/**, .github/workflows/33-frontend-pr-mutation-testing.yml]
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 120
env:
destination: frontend/reports/mutation
steps:
- uses: szenius/set-timezone@v1.2
with:
timezoneLinux: "America/Los_Angeles"
- uses: actions/checkout@v3.5.2
with:
fetch-depth: 2
- name: Get PR number
id: get-pr-num
run: |
echo "GITHUB_EVENT_PATH=${GITHUB_EVENT_PATH}"
pr_number=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
echo "pr_number=${pr_number}"
if [[ "${pr_number}" == "null" ]]; then
echo "This is not a PR"
pr_number="main"
fi
echo "pr_number=${pr_number}" >> "$GITHUB_ENV"
- name: Setup Node.js
uses: actions/setup-node@v3.6.0
with:
node-version-file: 'frontend/package.json'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Create directory in case it doesn't exist
run: |
mkdir -p frontend/history
- name: Download artifact
uses: dawidd6/action-download-artifact@v2.27.0
with:
github_token: ${{secrets.GITHUB_TOKEN}}
branch: main
name: stryker-incremental-${{env.pr_number}}.json
path: frontend/history
check_artifacts: true
if_no_artifact_found: warn
- run: npm ci
working-directory: ./frontend
- run: npx stryker run --incremental --incrementalFile history/stryker-incremental-${{env.pr_number}}.json
working-directory: ./frontend
- name: Upload stryker incremental file to Artifacts
if: always() # always upload artifacts, even if tests fail
uses: actions/upload-artifact@v3.1.2
with:
name: stryker-incremental-${{env.pr_number}}.json
path: frontend/history/stryker-incremental-${{env.pr_number}}.json
- name: Set path for github pages deploy when there is a PR num
if: always() # always upload artifacts, even if tests fail
run: |
if [ "${{env.pr_number }}" = "main" ]; then
prefix=""
else
prefix="prs/${{ env.pr_number }}/"
fi
echo "prefix=${prefix}"
echo "prefix=${prefix}" >> "$GITHUB_ENV"
- name: Deploy 🚀
if: always() # always upload artifacts, even if tests fail
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages # The branch the action should deploy to.
folder: frontend/reports/mutation # The folder where the javadoc files are located
clean: true # Automatically remove deleted files from the deploy branch
target-folder: ${{env.prefix}}/stryker # The folder that we serve our javadoc files from