持续集成
pnpm 可以很容易地用于各种持续集成系统。
Travis
在 Travis CI,请将此添加到您的 .travis.yml
文件中,使用 pnpm 来安装您的依赖项:
.travis.yml
cache:
npm: false
directories:
- "~/.pnpm-store"
before_install:
- curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@6
- pnpm config set store-dir ~/.pnpm-store
install:
- pnpm install
Semaphore
在 Semapore上 ,请将此内容添加到 .semaphore/semaphore.yml
文件中,使用 pnpm 来安装和缓存您的依赖:
.semaphore/semaphore.yml
version: v1.0
name: Semaphore CI pnpm example
agent:
machine:
type: e1-standard-2
os_image: ubuntu1804
blocks:
- name: Install dependencies
task:
jobs:
- name: pnpm install
commands:
- curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@6
- checkout
- cache restore node-$(checksum pnpm-lock.yaml)
- pnpm install
- cache store node-$(checksum pnpm-lock.yaml) ~/.pnpm-store
AppVeyor
在 AppVeyor ,请将此添加您的 appveyor.yml
来使用 pnpm 来安装您的依赖项:
appveyor.yml
install:
- ps: Install-Product node $env:nodejs_version
- curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@6
- pnpm install
GitHub Actions
在 GitHub Actions 上,您可以像这样使用 pnpm 安装和缓存您的依赖项 .github/workflows/NAME.yml
):
.github/workflows/NAME.yml
name: pnpm Example Workflow
on:
push:
jobs:
build:
runs-on: ubuntu-20.04
strategy:
matrix:
node-version: [15]
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2.0.1
with:
version: 6.20.3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
::: 注意
使用 actions/setup-node@v2
缓存包依赖项要求您安装版本 6.10+ 的 pnpm。
:::
GitLab CI
在 Gitlab 上,您可以使用 pnpm 来安装和缓存您的依赖项 像这样(在 .gitlab-ci.yml
中):
.gitlab-ci.yml
stages:
- build
build:
stage: build
image: node:14.16.0-buster
before_script:
- curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@6
- pnpm config set store-dir .pnpm-store
script:
- pnpm install # install dependencies
cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- .pnpm-store
Bitbucket Pipelines
您可以使用 pnpm 来安装和缓存您的依赖项:
.bitbucket-pipelines.yml
definitions:
caches:
pnpm: $BITBUCKET_CLONE_DIR/.pnpm-store
pipelines:
pull-requests:
"**":
- step:
name: Build and test
image: node:14.16.0
script:
- curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@6
- pnpm install
- pnpm run build # Replace with your build/test…etc. commands
caches:
- pnpm