|
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 | + workflow_dispatch: |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - '*' |
| 10 | + push: |
| 11 | + branches: |
| 12 | + - main |
| 13 | + - latest |
| 14 | + schedule: |
| 15 | + # "At 02:00 on Monday" https://crontab.guru/#0_2_*_*_1 |
| 16 | + - cron: "0 2 * * 1" |
20 | 17 |
|
21 | 18 | jobs:
|
22 |
| - build: |
| 19 | + lint: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v3 |
| 23 | + - name: Setup git user |
| 24 | + run: | |
| 25 | + git config --global user.email "[email protected]" |
| 26 | + git config --global user.name "npm cli ops bot" |
| 27 | + - uses: actions/setup-node@v3 |
| 28 | + with: |
| 29 | + node-version: 16.x |
| 30 | + - name: Update npm to latest |
| 31 | + run: npm i --prefer-online --no-fund --no-audit -g npm@latest |
| 32 | + - run: npm -v |
| 33 | + - run: npm i --ignore-scripts |
| 34 | + - run: npm run lint |
| 35 | + |
| 36 | + test: |
23 | 37 | strategy:
|
24 | 38 | fail-fast: false
|
25 | 39 | 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 |
| - |
| 40 | + node-version: |
| 41 | + - 12.13.0 |
| 42 | + - 12.x |
| 43 | + - 14.15.0 |
| 44 | + - 14.x |
| 45 | + - 16.0.0 |
| 46 | + - 16.x |
| 47 | + platform: |
| 48 | + - os: ubuntu-latest |
| 49 | + shell: bash |
| 50 | + - os: macos-latest |
| 51 | + shell: bash |
| 52 | + - os: windows-latest |
| 53 | + shell: cmd |
| 54 | + runs-on: ${{ matrix.platform.os }} |
| 55 | + defaults: |
| 56 | + run: |
| 57 | + shell: ${{ matrix.platform.shell }} |
31 | 58 | 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 |
| 59 | + - uses: actions/checkout@v3 |
| 60 | + - name: Setup git user |
| 61 | + run: | |
| 62 | + git config --global user.email "[email protected]" |
| 63 | + git config --global user.name "npm cli ops bot" |
| 64 | + - uses: actions/setup-node@v3 |
37 | 65 | with:
|
38 | 66 | 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 |
| - |
61 |
| - - name: Run tests |
| 67 | + - name: Update to workable npm (windows) |
| 68 | + # node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows |
| 69 | + if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.')) |
62 | 70 | run: |
|
63 |
| - git config --global user.email "[email protected]" |
64 |
| - git config --global user.name "Your Name" |
65 |
| - npm test -- --no-coverage --timeout 60 |
66 |
| -
|
67 |
| - ################################################################################ |
68 |
| - # Run coverage check |
69 |
| - # |
70 |
| - # ASSUMPTIONS: |
71 |
| - # - The project has `tap` as a devDependency |
72 |
| - # - There is a script called "coverage" in the package.json |
73 |
| - # |
74 |
| - # Coverage should only be posted once, we are choosing the latest LTS of |
75 |
| - # node, and ubuntu as the matrix point to post coverage from. We limit |
76 |
| - # to the 'push' event so that coverage ins't posted twice from the |
77 |
| - # pull-request event, and push event (line 3). |
78 |
| - ################################################################################ |
79 |
| - - name: Run coverage report |
80 |
| - if: github.event_name == 'push' && matrix.node-version == '12.x' && matrix.os == 'ubuntu-latest' |
81 |
| - run: npm test |
82 |
| - env: |
83 |
| - # The environment variable name is leveraged by `tap` |
84 |
| - COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} |
| 71 | + curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz |
| 72 | + tar xf npm-7.5.4.tgz |
| 73 | + cd package |
| 74 | + node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz |
| 75 | + cd .. |
| 76 | + rmdir /s /q package |
| 77 | + - name: Update npm to 7 |
| 78 | + # If we do test on npm 10 it needs npm7 |
| 79 | + if: startsWith(matrix.node-version, '10.') |
| 80 | + run: npm i --prefer-online --no-fund --no-audit -g npm@7 |
| 81 | + - name: Update npm to latest |
| 82 | + if: ${{ !startsWith(matrix.node-version, '10.') }} |
| 83 | + run: npm i --prefer-online --no-fund --no-audit -g npm@latest |
| 84 | + - run: npm -v |
| 85 | + - run: npm i --ignore-scripts |
| 86 | + - run: npm test --ignore-scripts |
0 commit comments