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