|
| 1 | +name: Validate JS |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - '.github/workflows/validate-js.yml' |
| 9 | + - 'src/**' |
| 10 | + - '*.json' |
| 11 | + - '*.js' |
| 12 | + - '*.lock' |
| 13 | + pull_request: |
| 14 | + paths: |
| 15 | + - '.github/workflows/validate-js.yml' |
| 16 | + - 'src/**' |
| 17 | + - '*.json' |
| 18 | + - '*.js' |
| 19 | + - '*.lock' |
| 20 | + |
| 21 | +jobs: |
| 22 | + compile: |
| 23 | + name: Compile JS (tsc) |
| 24 | + runs-on: ubuntu-latest |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v2 |
| 27 | + |
| 28 | + - name: Install reviewdog |
| 29 | + uses: reviewdog/action-setup@v1 |
| 30 | + |
| 31 | + - name: Get yarn cache directory path |
| 32 | + id: yarn-cache-dir-path |
| 33 | + run: echo "::set-output name=dir::$(yarn cache dir)" |
| 34 | + - name: Restore node_modules from cache |
| 35 | + uses: actions/cache@v2 |
| 36 | + id: yarn-cache |
| 37 | + with: |
| 38 | + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} |
| 39 | + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} |
| 40 | + restore-keys: | |
| 41 | + ${{ runner.os }}-yarn- |
| 42 | +
|
| 43 | + - name: Install node_modules |
| 44 | + run: yarn install --frozen-lockfile |
| 45 | + |
| 46 | + - name: Run TypeScript # Reviewdog tsc errorformat: %f:%l:%c - error TS%n: %m |
| 47 | + run: | |
| 48 | + yarn typescript | reviewdog -name="tsc" -efm="%f(%l,%c): error TS%n: %m" -reporter="github-pr-review" -filter-mode="nofilter" -fail-on-error -tee |
| 49 | + env: |
| 50 | + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 51 | + |
| 52 | + lint: |
| 53 | + name: Lint JS (eslint, prettier) |
| 54 | + runs-on: ubuntu-latest |
| 55 | + steps: |
| 56 | + - uses: actions/checkout@v2 |
| 57 | + |
| 58 | + - name: Get yarn cache directory path |
| 59 | + id: yarn-cache-dir-path |
| 60 | + run: echo "::set-output name=dir::$(yarn cache dir)" |
| 61 | + - name: Restore node_modules from cache |
| 62 | + uses: actions/cache@v2 |
| 63 | + id: yarn-cache |
| 64 | + with: |
| 65 | + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} |
| 66 | + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} |
| 67 | + restore-keys: | |
| 68 | + ${{ runner.os }}-yarn- |
| 69 | +
|
| 70 | + - name: Install node_modules |
| 71 | + run: yarn install --frozen-lockfile |
| 72 | + |
| 73 | + - name: Run ESLint |
| 74 | + run: yarn lint -f @jamesacarr/github-actions |
| 75 | + |
| 76 | + - name: Run ESLint with auto-fix |
| 77 | + run: yarn lint --fix |
| 78 | + |
| 79 | + - name: Verify no files have changed after auto-fix |
| 80 | + run: git diff --exit-code HEAD |
0 commit comments