持续集成

pnpm 可以很容易地用于各种持续集成系统。

Travis

Travis CI,请将此添加到您的 .travis.yml 文件中,使用 pnpm 来安装您的依赖项:

.travis.yml

  1. cache:
  2. npm: false
  3. directories:
  4. - "~/.pnpm-store"
  5. before_install:
  6. - curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@6
  7. - pnpm config set store-dir ~/.pnpm-store
  8. install:
  9. - pnpm install

Semaphore

Semapore上 ,请将此内容添加到 .semaphore/semaphore.yml 文件中,使用 pnpm 来安装和缓存您的依赖:

.semaphore/semaphore.yml

  1. version: v1.0
  2. name: Semaphore CI pnpm example
  3. agent:
  4. machine:
  5. type: e1-standard-2
  6. os_image: ubuntu1804
  7. blocks:
  8. - name: Install dependencies
  9. task:
  10. jobs:
  11. - name: pnpm install
  12. commands:
  13. - curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@6
  14. - checkout
  15. - cache restore node-$(checksum pnpm-lock.yaml)
  16. - pnpm install
  17. - cache store node-$(checksum pnpm-lock.yaml) ~/.pnpm-store

AppVeyor

AppVeyor ,请将此添加您的 appveyor.yml来使用 pnpm 来安装您的依赖项:

appveyor.yml

  1. install:
  2. - ps: Install-Product node $env:nodejs_version
  3. - curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@6
  4. - pnpm install

GitHub Actions

在 GitHub Actions 上,您可以像这样使用 pnpm 安装和缓存您的依赖项 .github/workflows/NAME.yml):

.github/workflows/NAME.yml

  1. name: pnpm Example Workflow
  2. on:
  3. push:
  4. jobs:
  5. build:
  6. runs-on: ubuntu-20.04
  7. strategy:
  8. matrix:
  9. node-version: [15]
  10. steps:
  11. - uses: actions/checkout@v3
  12. - uses: pnpm/action-setup@v2.0.1
  13. with:
  14. version: 6.20.3
  15. - name: Use Node.js ${{ matrix.node-version }}
  16. uses: actions/setup-node@v3
  17. with:
  18. node-version: ${{ matrix.node-version }}
  19. cache: 'pnpm'
  20. - name: Install dependencies
  21. run: pnpm install

::: 注意

使用 actions/setup-node@v2 缓存包依赖项要求您安装版本 6.10+ 的 pnpm。

:::

GitLab CI

在 Gitlab 上,您可以使用 pnpm 来安装和缓存您的依赖项 像这样(在 .gitlab-ci.yml 中):

.gitlab-ci.yml

  1. stages:
  2. - build
  3. build:
  4. stage: build
  5. image: node:14.16.0-buster
  6. before_script:
  7. - curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@6
  8. - pnpm config set store-dir .pnpm-store
  9. script:
  10. - pnpm install # install dependencies
  11. cache:
  12. key: "$CI_COMMIT_REF_SLUG"
  13. paths:
  14. - .pnpm-store

Bitbucket Pipelines

您可以使用 pnpm 来安装和缓存您的依赖项:

.bitbucket-pipelines.yml

  1. definitions:
  2. caches:
  3. pnpm: $BITBUCKET_CLONE_DIR/.pnpm-store
  4. pipelines:
  5. pull-requests:
  6. "**":
  7. - step:
  8. name: Build and test
  9. image: node:14.16.0
  10. script:
  11. - curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@6
  12. - pnpm install
  13. - pnpm run build # Replace with your build/test…etc. commands
  14. caches:
  15. - pnpm