Skip to content

Commit

Permalink
feat: add a strict engines check to ci (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys authored Sep 22, 2022
1 parent 99f3945 commit 88f8387
Show file tree
Hide file tree
Showing 5 changed files with 361 additions and 1 deletion.
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,56 @@ on:
- cron: "0 9 * * 1"

jobs:
engines:
name: Engines - ${{ matrix.platform.name }} - ${{ matrix.node-version }}
if: github.repository_owner == 'npm'
strategy:
fail-fast: false
matrix:
platform:
- name: Linux
os: ubuntu-latest
shell: bash
node-version:
- 14.17.0
- 16.13.0
- 18.0.0
runs-on: ${{ matrix.platform.os }}
defaults:
run:
shell: ${{ matrix.platform.shell }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Git User
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Update Windows npm
# node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows
if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.'))
run: |
curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
tar xf npm-7.5.4.tgz
cd package
node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz
cd ..
rmdir /s /q package
- name: Install npm@7
if: startsWith(matrix.node-version, '10.')
run: npm i --prefer-online --no-fund --no-audit -g npm@7
- name: Install npm@latest
if: ${{ !startsWith(matrix.node-version, '10.') }}
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- name: npm Version
run: npm -v
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund --engines-strict

lint:
name: Lint
if: github.repository_owner == 'npm'
Expand Down
9 changes: 9 additions & 0 deletions lib/content/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ on:
{{> onCi }}

jobs:
engines:
{{> jobMatrix
jobName="Engines"
jobDepFlags="--engines-strict"
macCI=false
windowsCI=false
ciVersions=(reject ciVersions '\.x$')
}}

lint:
{{> job jobName="Lint" }}
{{> stepLint jobRunFlags=pkgFlags }}
Expand Down
1 change: 1 addition & 0 deletions lib/util/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const setupHandlebars = (...partialDirs) => {
Handlebars.registerHelper('obj', ({ hash }) => Object.fromEntries(safeValues(hash)))
Handlebars.registerHelper('join', (arr, sep) => arr.join(typeof sep === 'string' ? sep : ', '))
Handlebars.registerHelper('pluck', (arr, key) => arr.map(a => a[key]))
Handlebars.registerHelper('reject', (arr, re) => arr.filter(a => !new RegExp(re).test(a)))
Handlebars.registerHelper('quote', (arr) => arr.map(a => `'${a}'`))
Handlebars.registerHelper('last', (arr) => arr[arr.length - 1])
Handlebars.registerHelper('json', (c) => JSON.stringify(c))
Expand Down
Loading

0 comments on commit 88f8387

Please sign in to comment.