|
| 1 | +# Useful GitHub Actions docs: |
| 2 | +# |
| 3 | +# - https://help.github.com/en/actions |
| 4 | +# - https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions |
| 5 | +# - https://help.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow |
| 6 | +# - https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions |
| 7 | + |
| 8 | +name: test |
| 9 | + |
| 10 | +on: |
| 11 | + - push |
| 12 | + - pull_request |
| 13 | + |
| 14 | +jobs: |
| 15 | + # Job to run linter / autoformat |
| 16 | + |
| 17 | + lint: |
| 18 | + runs-on: ubuntu-20.04 |
| 19 | + steps: |
| 20 | + # Action Repo: https://github.com/actions/checkout |
| 21 | + - name: "Checkout repo" |
| 22 | + uses: actions/checkout@v2 |
| 23 | + |
| 24 | + # Action Repo: https://github.com/actions/setup-node |
| 25 | + - name: "Setup Node" |
| 26 | + uses: actions/setup-node@v1 |
| 27 | + with: |
| 28 | + node-version: "14" |
| 29 | + |
| 30 | + # Action Repo: https://github.com/actions/cache |
| 31 | + - name: "Cache node_modules" |
| 32 | + uses: actions/cache@v2 |
| 33 | + with: |
| 34 | + path: node_modules |
| 35 | + key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} |
| 36 | + restore-keys: | |
| 37 | + ${{ runner.os }}-npm- |
| 38 | +
|
| 39 | + - name: "Install" |
| 40 | + run: | |
| 41 | + npm ci |
| 42 | +
|
| 43 | + - name: "`npm run fmt` and check for changes" |
| 44 | + run: | |
| 45 | + # If this fails, run `npm run fmt` and push the result |
| 46 | + # amend if you feel so inclined. |
| 47 | + npm run fmt |
| 48 | + git diff --exit-code |
| 49 | +
|
| 50 | + - name: npm audit |
| 51 | + run: | |
| 52 | + # If this fails, run `npm audit fix` |
| 53 | + npm audit --production --audit-level=moderate |
| 54 | +
|
| 55 | + test: |
| 56 | + # no need to wait for lint |
| 57 | + # needs: lint |
| 58 | + runs-on: ubuntu-20.04 |
| 59 | + # - https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstrategy |
| 60 | + strategy: |
| 61 | + fail-fast: false # Do not cancel all jobs if one fails |
| 62 | + matrix: |
| 63 | + node_version: |
| 64 | + - "10" |
| 65 | + - "12" |
| 66 | + - "14" |
| 67 | + - "15" |
| 68 | + |
| 69 | + steps: |
| 70 | + - name: "Checkout repo" |
| 71 | + uses: actions/checkout@v2 |
| 72 | + |
| 73 | + # Action Repo: https://github.com/actions/setup-node |
| 74 | + - name: "Setup Node" |
| 75 | + uses: actions/setup-node@v1 |
| 76 | + with: |
| 77 | + node-version: ${{ matrix.node_version }} |
| 78 | + |
| 79 | + # Action Repo: https://github.com/actions/cache |
| 80 | + - name: "Cache node_modules" |
| 81 | + uses: actions/cache@v2 |
| 82 | + with: |
| 83 | + path: node_modules |
| 84 | + key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} |
| 85 | + restore-keys: | |
| 86 | + ${{ runner.os }}-npm- |
| 87 | +
|
| 88 | + - name: "Install dependencies" |
| 89 | + run: | |
| 90 | + npm ci |
| 91 | +
|
| 92 | + - name: "Run tests" |
| 93 | + run: | |
| 94 | + npm test |
| 95 | +
|
| 96 | + # Action Repo: https://github.com/codecov/codecov-action |
| 97 | + - name: "Upload coverage to codecov" |
| 98 | + uses: codecov/codecov-action@v1 |
0 commit comments