2021-02-23 14:29:59 +01:00
|
|
|
name: Validate JS
|
2021-02-23 12:19:07 +01:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
2021-02-23 14:00:32 +01:00
|
|
|
- main
|
2021-02-23 12:19:07 +01:00
|
|
|
paths:
|
2021-02-23 14:29:59 +01:00
|
|
|
- '.github/workflows/validate-js.yml'
|
2021-02-23 12:41:31 +01:00
|
|
|
- 'src/**'
|
|
|
|
- '*.json'
|
2021-03-09 09:45:06 +01:00
|
|
|
- '*.js'
|
|
|
|
- '*.lock'
|
2021-03-12 14:58:09 +01:00
|
|
|
- 'example/src/**'
|
|
|
|
- 'example/*.json'
|
|
|
|
- 'example/*.js'
|
|
|
|
- 'example/*.lock'
|
|
|
|
- 'example/*.tsx'
|
2021-02-23 12:19:07 +01:00
|
|
|
pull_request:
|
|
|
|
paths:
|
2021-02-23 14:29:59 +01:00
|
|
|
- '.github/workflows/validate-js.yml'
|
2021-02-23 12:41:31 +01:00
|
|
|
- 'src/**'
|
|
|
|
- '*.json'
|
2021-03-09 09:45:06 +01:00
|
|
|
- '*.js'
|
|
|
|
- '*.lock'
|
2021-03-12 14:58:09 +01:00
|
|
|
- 'example/src/**'
|
|
|
|
- 'example/*.json'
|
|
|
|
- 'example/*.js'
|
|
|
|
- 'example/*.lock'
|
|
|
|
- 'example/*.tsx'
|
2021-02-23 12:19:07 +01:00
|
|
|
|
2021-02-23 11:58:30 +01:00
|
|
|
jobs:
|
2021-03-12 13:21:46 +01:00
|
|
|
compile:
|
|
|
|
name: Compile JS (tsc)
|
2021-02-23 14:39:54 +01:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2021-02-23 14:43:23 +01:00
|
|
|
- uses: actions/checkout@v2
|
2021-02-23 14:46:11 +01:00
|
|
|
|
2021-03-12 14:19:22 +01:00
|
|
|
- name: Install reviewdog
|
|
|
|
uses: reviewdog/action-setup@v1
|
|
|
|
|
2021-02-23 14:46:11 +01:00
|
|
|
- name: Get yarn cache directory path
|
|
|
|
id: yarn-cache-dir-path
|
|
|
|
run: echo "::set-output name=dir::$(yarn cache dir)"
|
2021-03-08 17:51:47 +01:00
|
|
|
- name: Restore node_modules from cache
|
|
|
|
uses: actions/cache@v2
|
2021-02-23 14:46:11 +01:00
|
|
|
id: yarn-cache
|
2021-02-23 14:43:23 +01:00
|
|
|
with:
|
2021-02-23 14:46:11 +01:00
|
|
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
|
|
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
2021-02-23 14:43:23 +01:00
|
|
|
restore-keys: |
|
2021-02-23 14:46:11 +01:00
|
|
|
${{ runner.os }}-yarn-
|
|
|
|
|
2021-03-08 17:51:47 +01:00
|
|
|
- name: Install node_modules
|
|
|
|
run: yarn install --frozen-lockfile
|
|
|
|
- name: Install node_modules (example/)
|
|
|
|
run: yarn install --frozen-lockfile --cwd example
|
2021-02-23 14:49:17 +01:00
|
|
|
|
2021-03-12 14:19:22 +01:00
|
|
|
- name: Run TypeScript # Reviewdog tsc errorformat: %f:%l:%c - error TS%n: %m
|
|
|
|
run: |
|
|
|
|
yarn typescript | reviewdog -name="tsc" -efm="%f(%l,%c): error TS%n: %m" -reporter="github-pr-review" -filter-mode="nofilter" -fail-on-error -tee
|
|
|
|
env:
|
|
|
|
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
2021-03-12 13:21:46 +01:00
|
|
|
|
2021-08-16 10:45:41 +02:00
|
|
|
- name: Run TypeScript in example/ # Reviewdog tsc errorformat: %f:%l:%c - error TS%n: %m
|
|
|
|
run: |
|
|
|
|
cd example && yarn typescript | reviewdog -name="tsc" -efm="%f(%l,%c): error TS%n: %m" -reporter="github-pr-review" -filter-mode="nofilter" -fail-on-error -tee && cd ..
|
|
|
|
env:
|
|
|
|
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
2021-03-12 13:21:46 +01:00
|
|
|
lint:
|
|
|
|
name: Lint JS (eslint, prettier)
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Get yarn cache directory path
|
|
|
|
id: yarn-cache-dir-path
|
|
|
|
run: echo "::set-output name=dir::$(yarn cache dir)"
|
|
|
|
- name: Restore node_modules from cache
|
|
|
|
uses: actions/cache@v2
|
|
|
|
id: yarn-cache
|
|
|
|
with:
|
|
|
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
|
|
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-yarn-
|
|
|
|
|
|
|
|
- name: Install node_modules
|
|
|
|
run: yarn install --frozen-lockfile
|
|
|
|
- name: Install node_modules (example/)
|
|
|
|
run: yarn install --frozen-lockfile --cwd example
|
2021-02-23 14:49:17 +01:00
|
|
|
|
2021-02-23 11:58:30 +01:00
|
|
|
- name: Run ESLint
|
2021-03-12 14:19:22 +01:00
|
|
|
run: yarn lint -f @jamesacarr/github-actions
|
2021-03-12 15:10:44 +01:00
|
|
|
|
|
|
|
- name: Run ESLint with auto-fix
|
|
|
|
run: yarn lint --fix
|
|
|
|
|
2021-08-16 10:45:41 +02:00
|
|
|
- name: Run ESLint in example/
|
|
|
|
run: cd example && yarn lint -f @jamesacarr/github-actions && cd ..
|
|
|
|
|
|
|
|
- name: Run ESLint in example/ with auto-fix
|
|
|
|
run: cd example && yarn lint --fix && cd ..
|
|
|
|
|
2021-03-12 15:10:44 +01:00
|
|
|
- name: Verify no files have changed after auto-fix
|
|
|
|
run: git diff --exit-code HEAD
|