microsoft/TypeAgent

Public

mirrored fromhttps://github.com/microsoft/TypeAgentAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
b9ae73e8c13f9df3b5d8951fd682f55f20ae9678

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

pipelines/include-install-pnpm.yml

59lines · modecode

1# Copyright (c) Microsoft Corporation.
2# Licensed under the MIT License.
3
4# include-install-pnpm
5#
6# This template can be included in pipelines to install pnpm with store caching enabled.
7
8parameters:
9 # The path containing the project(s) to build.
10 - name: buildDirectory
11 type: string
12
13 # If set to false, the pnpm store will not be cached or restored from cache.
14 - name: enableCache
15 type: boolean
16 default: true
17
18 # The path to the pnpm store. The contents here will be cached and restored when using pnpm in a pipeline.
19 - name: pnpmStorePath
20 type: string
21 default: $(Pipeline.Workspace)/.pnpm-store
22
23steps:
24 - ${{ if eq(parameters.enableCache, true) }}:
25 - task: Cache@2
26 displayName: Cache pnpm store
27 timeoutInMinutes: 3
28 continueOnError: true
29 inputs:
30 # Caches are already scoped to individual pipelines, so no need to include the release group name or tag
31 # in the cache key
32 key: pnpm-store | $(Agent.OS) | $(Agent.OSArchitecture) | ${{ parameters.buildDirectory }}/pnpm-lock.yaml
33 path: ${{ parameters.pnpmStorePath }}
34 restoreKeys: |
35 pnpm-store | $(Agent.OS) | $(Agent.OSArchitecture)
36
37 # workspace-concurrency 0 means use use the CPU core count. This is better than the default (4) for larger agents.
38 - bash: |
39 echo "Using node $(node --version)"
40 storePath=${{ parameters.pnpmStorePath }}
41 if [[ '$(Agent.OS)' == 'Windows_NT' ]]; then
42 npm install -g corepack@0.31.0 --force
43 corepack enable
44 storePath=$PNPM_STORE_PATH
45 else
46 npm install -g corepack@0.31.0
47 sudo corepack enable
48 fi
49 pnpm config set store-dir $storePath
50 pnpm config set -g workspace-concurrency 0
51 echo "Using pnpm $(pnpm -v)"
52 echo "Using pnpm store path $(pnpm store path)"
53 displayName: Install and configure pnpm
54 workingDirectory: ${{ parameters.buildDirectory }}
55 # The previous task (cache restoration) can timeout, which is classified as canceled, but since it's just cache
56 # restoration, we want to continue even if it timed out.
57 condition: or(succeeded(), canceled())
58 env:
59 PNPM_STORE_PATH: ${{ replace(parameters.pnpmStorePath, '\', '/') }}
60