|
| 1 | +# GitHub Actions Workflow configuration |
| 2 | +# https://docs.github.com/actions/reference/workflow-syntax-for-github-actions |
| 3 | +# https://docs.github.com/actions/guides/building-and-testing-nodejs |
| 4 | + |
| 5 | +name: Node.js CI |
| 6 | + |
| 7 | +# Note: on key treated as boolean key by YAML |
| 8 | +# https://github.com/adrienverge/yamllint/issues/158#issuecomment-454313233 |
| 9 | +# However, GitHub Actions documentation is consistent in using it unquoted. |
| 10 | +on: # yamllint disable-line rule:truthy |
| 11 | + pull_request: {} |
| 12 | + push: {} |
| 13 | + schedule: |
| 14 | + # Run once a day (at 8:40 AM UTC) to check for exogenous breakage. |
| 15 | + # TODO: Run when dependencies are updated. (Like Dependabot, but on |
| 16 | + # in-range updates and without sending a PR.) |
| 17 | + - cron: '40 8 * * *' |
| 18 | + |
| 19 | +jobs: |
| 20 | + test-primary: |
| 21 | + name: Lint and Test on Node.js * x64 on ubuntu-latest |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v2 |
| 25 | + - name: Set up Node.js |
| 26 | + uses: actions/setup-node@v2 |
| 27 | + with: |
| 28 | + # '*' is "latest": |
| 29 | + # https://github.com/actions/setup-node/issues/61#issuecomment-577548687 |
| 30 | + # https://github.com/actions/setup-node/issues/164#issuecomment-648999618 |
| 31 | + # https://github.com/actions/setup-node/pull/104 |
| 32 | + node-version: '*' |
| 33 | + architecture: x64 |
| 34 | + - name: Display Node.js version |
| 35 | + run: node --version |
| 36 | + - name: Install dependencies |
| 37 | + run: npm install |
| 38 | + - name: Lint |
| 39 | + run: npm run lint |
| 40 | + - name: Run tests |
| 41 | + run: npm run test-unit-cov |
| 42 | + - name: Upload coverage to Codecov |
| 43 | + uses: codecov/codecov-action@v1 |
| 44 | + - name: Upload coverage to Coveralls |
| 45 | + # Note: @master is currently the only version |
| 46 | + # https://github.com/coverallsapp/github-action/issues/11 |
| 47 | + uses: coverallsapp/github-action@master |
| 48 | + with: |
| 49 | + flag-name: 'ubuntu-latest_x64_*' |
| 50 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 51 | + parallel: true |
| 52 | + |
| 53 | + test-secondary: |
| 54 | + # Only test secondary platforms if primary test platform passed |
| 55 | + needs: |
| 56 | + - test-primary |
| 57 | + name: >- |
| 58 | + Test on Node.js ${{ matrix.node }} ${{ matrix.arch }} on ${{ matrix.os }} |
| 59 | + runs-on: ${{ matrix.os }} |
| 60 | + strategy: |
| 61 | + matrix: |
| 62 | + arch: |
| 63 | + # Uncomment if package needs testing on different architectures |
| 64 | + # - x86 |
| 65 | + - x64 |
| 66 | + os: |
| 67 | + # Uncomment if package needs testing on macOS: |
| 68 | + # - macos-latest |
| 69 | + - ubuntu-latest |
| 70 | + - windows-latest |
| 71 | + node: |
| 72 | + - '10' |
| 73 | + - '*' |
| 74 | + exclude: |
| 75 | + # Exclude os/version already run in test-primary |
| 76 | + - arch: x64 |
| 77 | + os: ubuntu-latest |
| 78 | + node: '*' |
| 79 | + steps: |
| 80 | + - uses: actions/checkout@v2 |
| 81 | + - name: Set up Node.js ${{ matrix.node }} |
| 82 | + uses: actions/setup-node@v2 |
| 83 | + with: |
| 84 | + node-version: ${{ matrix.node }} |
| 85 | + architecture: ${{ matrix.arch }} |
| 86 | + - name: Display Node.js version |
| 87 | + run: node --version |
| 88 | + - name: Install dependencies |
| 89 | + run: npm install |
| 90 | + - name: Run tests |
| 91 | + run: npm run test-unit-cov |
| 92 | + # Note: Not uploading to Codecov, due to poor support for matrix builds |
| 93 | + # https://github.com/codecov/codecov-action/issues/40 |
| 94 | + - name: Upload coverage to Coveralls |
| 95 | + uses: coverallsapp/github-action@master |
| 96 | + with: |
| 97 | + flag-name: ${{ matrix.os }}_${{ matrix.arch }}_${{ matrix.node }} |
| 98 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 99 | + parallel: true |
| 100 | + |
| 101 | + finish: |
| 102 | + needs: test-secondary |
| 103 | + runs-on: ubuntu-latest |
| 104 | + steps: |
| 105 | + - name: Coveralls Finished |
| 106 | + uses: coverallsapp/github-action@master |
| 107 | + with: |
| 108 | + github-token: ${{ secrets.github_token }} |
| 109 | + parallel-finished: true |
0 commit comments