|
| 1 | +# This file is automatically added by @npmcli/template-oss. Do not edit. |
| 2 | + |
| 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" |
| 17 | + |
| 18 | +jobs: |
| 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 "ops+npm-cli@npmjs.com" |
| 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: |
| 37 | +strategy: |
| 38 | +fail-fast:false |
| 39 | +matrix: |
| 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 }} |
| 58 | +steps: |
| 59 | + -uses:actions/checkout@v3 |
| 60 | + -name:Setup git user |
| 61 | +run:| |
| 62 | + git config --global user.email "ops+npm-cli@npmjs.com" |
| 63 | + git config --global user.name "npm cli ops bot" |
| 64 | + -uses:actions/setup-node@v3 |
| 65 | +with: |
| 66 | +node-version:${{ matrix.node-version }} |
| 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.')) |
| 70 | +run:| |
| 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 |