School Edit Page now prevents user from editing the Abbrev param #135
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: 0 | |
- 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/reports/mutation | |
- run: npm ci | |
working-directory: ./frontend | |
# Modified from https://stackoverflow.com/a/74268200 | |
- name: Run stryker on changed files | |
id: changed-files | |
run: | | |
git diff --name-only -r origin/main HEAD | # get changed files in PR | |
grep "\.js" | # remove non .js files from list | |
sed 's|\(.*\)tests\(.*\)\.test.js|\1main\2.js|' | # alters test files to main files to account for changed tests | |
grep -v "\.stories\.js" | # remove .stories.js files from list | |
grep "src/main/" | # remove files outside of src/main | |
sed 's|frontend/||' | # remove 'frontend/' from file paths | |
sort -u | # remove duplicates | |
xargs -I{} sh -c '[ -f "{}" ] && echo "{}"' | # check if file exists | |
xargs printf '%s,' | # convert to comma separated list | |
sed 's/.$//' | # remove trailing comma | |
xargs -r npx stryker run --mutate # run stryker on changed files | |
working-directory: ./frontend | |
- 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 |