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
3520 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
continueOnError: true
21
variables:
22
VSCODE_ARCH: x64
23
steps:
24
- task: NodeTool@0
25
inputs:
26
versionSource: fromFile
27
versionFilePath: .nvmrc
28
29
- script: |
30
set -e
31
echo "Checking if package.json or package-lock.json files were modified..."
32
33
# Get the list of changed files in the PR
34
git fetch origin main
35
CHANGED_FILES=$(git diff --name-only origin/main...HEAD)
36
echo "Changed files:"
37
echo "$CHANGED_FILES"
38
39
# Check if package.json or package-lock.json are in the changed files
40
if echo "$CHANGED_FILES" | grep -E '^(package\.json|package-lock\.json)$'; then
41
echo "##vso[task.setvariable variable=SHOULD_VALIDATE]true"
42
echo "Package files were modified, proceeding with validation"
43
else
44
echo "##vso[task.setvariable variable=SHOULD_VALIDATE]false"
45
echo "No package files were modified, skipping validation"
46
echo "##vso[task.complete result=Succeeded;]Pipeline completed successfully - no package validation needed"
47
fi
48
displayName: Check if package files were modified
49
50
- script: node build/setup-npm-registry.js $NPM_REGISTRY
51
condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'), eq(variables['SHOULD_VALIDATE'], 'true'))
52
displayName: Setup NPM Registry
53
54
- script: |
55
set -e
56
# Set the private NPM registry to the global npmrc file
57
# so that authentication works for subfolders like build/, remote/, extensions/ etc
58
# which does not have their own .npmrc file
59
echo "NPMRC Path: $(npm config get userconfig)"
60
echo "NPM Registry: $(npm config get registry)"
61
npm config set registry "$NPM_REGISTRY"
62
echo "##vso[task.setvariable variable=NPMRC_PATH]$(npm config get userconfig)"
63
condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'), eq(variables['SHOULD_VALIDATE'], 'true'))
64
displayName: Setup NPM
65
66
- task: npmAuthenticate@0
67
inputs:
68
workingFile: $(NPMRC_PATH)
69
condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'), eq(variables['SHOULD_VALIDATE'], 'true'))
70
displayName: Setup NPM Authentication
71
72
- script: sudo apt update -y && sudo apt install -y build-essential pkg-config libx11-dev libx11-xcb-dev libxkbfile-dev libnotify-bin libkrb5-dev
73
displayName: Install build tools
74
condition: and(succeeded(), eq(variables['SHOULD_VALIDATE'], 'true'))
75
76
- script: |
77
set -e
78
79
for attempt in {1..12}; do
80
if [ $attempt -gt 1 ]; then
81
echo "Attempt $attempt: Waiting for 30 minutes before retrying..."
82
sleep 1800
83
fi
84
85
echo "Attempt $attempt: Running npm ci"
86
if npm i --ignore-scripts; then
87
if node build/npm/postinstall.js; then
88
echo "npm i succeeded on attempt $attempt"
89
exit 0
90
else
91
echo "node build/npm/postinstall.js failed on attempt $attempt"
92
fi
93
else
94
echo "npm i failed on attempt $attempt"
95
fi
96
done
97
98
echo "npm i failed after 12 attempts"
99
exit 1
100
env:
101
npm_command: 'install --ignore-scripts'
102
ELECTRON_SKIP_BINARY_DOWNLOAD: 1
103
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
104
GITHUB_TOKEN: "$(github-distro-mixin-password)"
105
displayName: Install dependencies with retries
106
timeoutInMinutes: 400
107
condition: and(succeeded(), eq(variables['SHOULD_VALIDATE'], 'true'))
108
109
- script: .github/workflows/check-clean-git-state.sh
110
displayName: Check clean git state
111
condition: and(succeeded(), eq(variables['SHOULD_VALIDATE'], 'true'))
112
113