运行 多个版本 Node.js 仅 运行 最新
Running multiple versions of Node.js only running latest
我已遵循 Running multiple versions of Node.js using a matrix strategy 的指导方针:
.github/workflows/build-test.yml
:
jobs:
build_and_test:
runs-on: ubuntu-latest
strategy:
matrix:
node: [10, 12, 14]
工作流确实开始使用预期的三个不同版本的 Node 进行测试:
但是,每一个都是运行最新的:
例如,对于 Node v14,工作流改为使用 Node v16.14.2:
/usr/local/bin/node --version
v16.14.2
/usr/local/bin/npm --version
8.5.0
为什么会这样?
完整的 yaml
name: Build and Test
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
build_and_test:
runs-on: ubuntu-latest
strategy:
matrix:
node: [10, 12, 14]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install project
run: npm install
- name: Build the project
run: npm run build --if-present
- name: Run tests
run: npm test
根据 @jonrsharpe 的建议使用 最新的 v3,这有效:
.github/workflows/build-test.yml
name: Build and Test
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
build_and_test:
runs-on: ubuntu-latest
strategy:
matrix:
node: [12, 14]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: npm
- name: Install project
run: npm install
- name: Build the project
run: npm run build --if-present
- name: Run tests
run: npm test
我已遵循 Running multiple versions of Node.js using a matrix strategy 的指导方针:
.github/workflows/build-test.yml
:
jobs:
build_and_test:
runs-on: ubuntu-latest
strategy:
matrix:
node: [10, 12, 14]
工作流确实开始使用预期的三个不同版本的 Node 进行测试:
但是,每一个都是运行最新的:
例如,对于 Node v14,工作流改为使用 Node v16.14.2:
/usr/local/bin/node --version
v16.14.2
/usr/local/bin/npm --version
8.5.0
为什么会这样?
完整的 yaml
name: Build and Test
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
build_and_test:
runs-on: ubuntu-latest
strategy:
matrix:
node: [10, 12, 14]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install project
run: npm install
- name: Build the project
run: npm run build --if-present
- name: Run tests
run: npm test
根据 @jonrsharpe 的建议使用 最新的 v3,这有效:
.github/workflows/build-test.yml
name: Build and Test
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
build_and_test:
runs-on: ubuntu-latest
strategy:
matrix:
node: [12, 14]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: npm
- name: Install project
run: npm install
- name: Build the project
run: npm run build --if-present
- name: Run tests
run: npm test