Continuous Integration

pnpm can easily be used in various continuous integration systems.

Travis

On Travis CI, you can use pnpm for installing your dependencies by adding this to your .travis.yml file:

.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

On Semaphore, you can use pnpm for installing and caching your dependencies by adding this to your .semaphore/semaphore.yml file:

.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

On AppVeyor, you can use pnpm for installing your dependencies by adding this to your appveyor.yml:

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

On GitHub Actions, you can use pnpm for installing and caching your dependencies like so (belongs in .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

Continuous Integration - 图1note

Caching packages dependencies with actions/setup-node@v2 requires you to install pnpm with version 6.10+.

GitLab CI

On GitLab, you can use pnpm for installing and caching your dependencies like so (belongs in .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

You can use pnpm for installing and caching your dependencies:

.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