|
| 1 | +--- |
| 2 | +################################################################################ |
| 3 | +# Template - Node CI |
| 4 | +# |
| 5 | +# Description: |
| 6 | +# This contains the basic information to: install dependencies, run tests, |
| 7 | +# get coverage, and run linting on a nodejs project. This template will run |
| 8 | +# over the MxN matrix of all operating systems, and all current LTS versions |
| 9 | +# of NodeJS. |
| 10 | +# |
| 11 | +# Dependencies: |
| 12 | +# This template assumes that your project is using the `tap` module for |
| 13 | +# testing. If you're not using this module, then the step that runs your |
| 14 | +# coverage will need to be adjusted. |
| 15 | +# |
| 16 | +################################################################################ |
| 17 | +name: Node CI |
| 18 | + |
| 19 | +on: [push, pull_request] |
| 20 | + |
| 21 | +jobs: |
| 22 | + build: |
| 23 | + strategy: |
| 24 | + fail-fast: false |
| 25 | + matrix: |
| 26 | + node-version: [10.x, 12.x, 13.x] |
| 27 | + os: [ubuntu-latest, windows-latest, macOS-latest] |
| 28 | + |
| 29 | + runs-on: ${{ matrix.os }} |
| 30 | + |
| 31 | + steps: |
| 32 | + # Checkout the repository |
| 33 | + - uses: actions/checkout@v2 |
| 34 | + # Installs the specific version of Node.js |
| 35 | + - name: Use Node.js ${{ matrix.node-version }} |
| 36 | + uses: actions/setup-node@v1 |
| 37 | + with: |
| 38 | + node-version: ${{ matrix.node-version }} |
| 39 | + |
| 40 | + ################################################################################ |
| 41 | + # Install Dependencies |
| 42 | + # |
| 43 | + # ASSUMPTIONS: |
| 44 | + # - The project has a package-lock.json file |
| 45 | + # |
| 46 | + # Simply run the tests for the project. |
| 47 | + ################################################################################ |
| 48 | + - name: Install dependencies |
| 49 | + run: npm ci |
| 50 | + |
| 51 | + ################################################################################ |
| 52 | + # Run Testing |
| 53 | + # |
| 54 | + # ASSUMPTIONS: |
| 55 | + # - The project has `tap` as a devDependency |
| 56 | + # - There is a script called "test" in the package.json |
| 57 | + # |
| 58 | + # Simply run the tests for the project. |
| 59 | + ################################################################################ |
| 60 | + - name: Run tests |
| 61 | + run: npm test |
| 62 | + |
| 63 | + ################################################################################ |
| 64 | + # Run coverage check |
| 65 | + # |
| 66 | + # ASSUMPTIONS: |
| 67 | + # - The project has `tap` as a devDependency |
| 68 | + # - There is a script called "coverage" in the package.json |
| 69 | + # |
| 70 | + # Coverage should only be posted once, we are choosing the latest LTS of |
| 71 | + # node, and ubuntu as the matrix point to post coverage from. We limit |
| 72 | + # to the 'push' event so that coverage ins't posted twice from the |
| 73 | + # pull-request event, and push event (line 3). |
| 74 | + ################################################################################ |
| 75 | + - name: Run coverage report |
| 76 | + if: github.event_name == 'push' && matrix.node-version == '12.x' && matrix.os == 'ubuntu-latest' |
| 77 | + run: npm run coverage |
| 78 | + env: |
| 79 | + # The environment variable name is leveraged by `tap` |
| 80 | + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} |
| 81 | + |
| 82 | + ################################################################################ |
| 83 | + # Run linting |
| 84 | + # |
| 85 | + # ASSUMPTIONS: |
| 86 | + # - There is a script called "lint" in the package.json |
| 87 | + # |
| 88 | + # We run linting AFTER we run testing and coverage checks, because if a step |
| 89 | + # fails in an GitHub Action, all other steps are not run. We don't want to |
| 90 | + # fail to run tests or coverage because of linting. It should be the lowest |
| 91 | + # priority of all the steps. |
| 92 | + ################################################################################ |
| 93 | + - name: Run linter |
| 94 | + run: npm run lint |
0 commit comments