Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/build/azure-pipelines/product-npm-package-validate.yml
5366 views
1
trigger: none
2
3
pr:
4
branches:
5
include: ["main"]
6
7
variables:
8
- name: NPM_REGISTRY
9
value: "https://pkgs.dev.azure.com/monacotools/Monaco/_packaging/vscode/npm/registry/"
10
- name: VSCODE_QUALITY
11
value: oss
12
13
jobs:
14
- job: ValidateNpmPackages
15
displayName: Valiate NPM packages against Terrapin
16
pool:
17
name: 1es-ubuntu-22.04-x64
18
os: linux
19
timeoutInMinutes: 40000
20
variables:
21
VSCODE_ARCH: x64
22
steps:
23
- task: NodeTool@0
24
inputs:
25
versionSource: fromFile
26
versionFilePath: .nvmrc
27
28
- script: |
29
set -e
30
echo "Checking if package.json or package-lock.json files were modified..."
31
32
# Get the list of changed files in the PR
33
git fetch origin main
34
CHANGED_FILES=$(git diff --name-only origin/main...HEAD)
35
echo "Changed files:"
36
echo "$CHANGED_FILES"
37
38
# Check if package.json or package-lock.json are in the changed files
39
if echo "$CHANGED_FILES" | grep -E '(^|/)package(-lock)?\.json$'; then
40
echo "##vso[task.setvariable variable=SHOULD_VALIDATE]true"
41
echo "Package files were modified, proceeding with validation"
42
else
43
echo "##vso[task.setvariable variable=SHOULD_VALIDATE]false"
44
echo "No package files were modified, skipping validation"
45
echo "##vso[task.complete result=Succeeded;]Pipeline completed successfully - no package validation needed"
46
fi
47
displayName: Check if package files were modified
48
49
- script: node build/setup-npm-registry.ts $NPM_REGISTRY
50
condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'), eq(variables['SHOULD_VALIDATE'], 'true'))
51
displayName: Setup NPM Registry
52
53
- script: |
54
set -e
55
# Set the private NPM registry to the global npmrc file
56
# so that authentication works for subfolders like build/, remote/, extensions/ etc
57
# which does not have their own .npmrc file
58
echo "NPMRC Path: $(npm config get userconfig)"
59
echo "NPM Registry: $(npm config get registry)"
60
npm config set registry "$NPM_REGISTRY"
61
echo "##vso[task.setvariable variable=NPMRC_PATH]$(npm config get userconfig)"
62
condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'), eq(variables['SHOULD_VALIDATE'], 'true'))
63
displayName: Setup NPM
64
65
- task: npmAuthenticate@0
66
inputs:
67
workingFile: $(NPMRC_PATH)
68
condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'), eq(variables['SHOULD_VALIDATE'], 'true'))
69
displayName: Setup NPM Authentication
70
71
- script: sudo apt update -y && sudo apt install -y build-essential pkg-config libx11-dev libx11-xcb-dev libxkbfile-dev libnotify-bin libkrb5-dev
72
displayName: Install build tools
73
condition: and(succeeded(), eq(variables['SHOULD_VALIDATE'], 'true'))
74
75
- script: |
76
set -e
77
78
for attempt in {1..12}; do
79
if [ $attempt -gt 1 ]; then
80
echo "Attempt $attempt: Waiting for 30 minutes before retrying..."
81
sleep 1800
82
fi
83
84
echo "Attempt $attempt: Running npm ci"
85
if npm i --ignore-scripts; then
86
if node build/npm/postinstall.ts; then
87
echo "npm i succeeded on attempt $attempt"
88
exit 0
89
else
90
echo "node build/npm/postinstall.ts failed on attempt $attempt"
91
fi
92
else
93
echo "npm i failed on attempt $attempt"
94
fi
95
done
96
97
echo "npm i failed after 12 attempts"
98
exit 1
99
env:
100
npm_command: 'install --ignore-scripts'
101
ELECTRON_SKIP_BINARY_DOWNLOAD: 1
102
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
103
GITHUB_TOKEN: "$(github-distro-mixin-password)"
104
displayName: Install dependencies with retries
105
timeoutInMinutes: 400
106
condition: and(succeeded(), eq(variables['SHOULD_VALIDATE'], 'true'))
107
108
- script: |
109
set -e
110
find . -name 'package-lock.json' -exec sed -i "s|$NPM_REGISTRY|https://registry.npmjs.org/|g" {} \;
111
displayName: Restore registry URLs in package-lock.json
112
condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'), eq(variables['SHOULD_VALIDATE'], 'true'))
113
114
- script: .github/workflows/check-clean-git-state.sh
115
displayName: Check clean git state
116
condition: and(succeeded(), eq(variables['SHOULD_VALIDATE'], 'true'))
117
118