|
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 |
| 1 | +# This file is automatically added by @npmcli/template-oss. Do not edit. |
18 | 2 |
|
19 |
| -on: [push, pull_request] |
| 3 | +name: CI |
| 4 | + |
| 5 | +on: |
| 6 | + pull_request: |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + - latest |
| 11 | + schedule: |
| 12 | + # "At 02:00 on Monday" https://crontab.guru/#0_2_*_*_1 |
| 13 | + - cron: "0 2 * * 1" |
20 | 14 |
|
21 | 15 | jobs:
|
22 |
| - build: |
| 16 | + lint: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v2 |
| 20 | + - uses: actions/setup-node@v2 |
| 21 | + with: |
| 22 | + node-version: '16' |
| 23 | + - run: npm i --prefer-online -g npm@latest |
| 24 | + - run: npm i |
| 25 | + - run: npm run lint |
| 26 | + |
| 27 | + test: |
23 | 28 | strategy:
|
24 | 29 | fail-fast: false
|
25 | 30 | 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 | + node-version: [12.13.0, 12.x, 14.15.0, 14.x, 16.13.0, 16.x] |
| 32 | + platform: |
| 33 | + - os: ubuntu-latest |
| 34 | + shell: bash |
| 35 | + - os: macos-latest |
| 36 | + shell: bash |
| 37 | + - os: windows-latest |
| 38 | + shell: cmd |
| 39 | + runs-on: ${{ matrix.platform.os }} |
| 40 | + defaults: |
| 41 | + run: |
| 42 | + shell: ${{ matrix.platform.shell }} |
31 | 43 | steps:
|
32 |
| - # Checkout the repository |
33 | 44 | - 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 |
| 45 | + - uses: actions/setup-node@v2 |
37 | 46 | with:
|
38 | 47 | 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 |
| 48 | + # node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows |
| 49 | + - name: Update to workable npm (windows) |
| 50 | + if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12') || startsWith(matrix.node-version, '14')) |
| 51 | + run: | |
| 52 | + curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz |
| 53 | + tar xf npm-7.5.4.tgz |
| 54 | + cd package |
| 55 | + node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz |
| 56 | + cd .. |
| 57 | + rmdir /s /q package |
| 58 | + - name: Update npm |
| 59 | + run: npm i --prefer-online --no-fund --no-audit -g npm@latest |
| 60 | + - run: npm -v |
| 61 | + - run: npm i |
| 62 | + - run: npm test --ignore-scripts |
0 commit comments