Path: blob/main/build/azure-pipelines/dependencies-check.yml
13379 views
trigger: none12pr: none34parameters:5- name: GITHUB_APP_ID6type: string7- name: GITHUB_APP_INSTALLATION_ID8type: string9- name: GITHUB_APP_PRIVATE_KEY10type: string11- name: GITHUB_CHECK_RUN_ID12type: string1314variables:15- name: NPM_REGISTRY16value: "https://pkgs.dev.azure.com/monacotools/Monaco/_packaging/vscode/npm/registry/"17- name: VSCODE_QUALITY18value: oss1920jobs:21- job: ValidateNpmPackages22displayName: Validate package-lock.json, Cargo.lock changes via Azure DevOps pipeline23pool:24name: 1es-ubuntu-22.04-x6425os: linux26timeoutInMinutes: 130027variables:28VSCODE_ARCH: x6429steps:30- task: NodeTool@031inputs:32versionSource: fromFile33versionFilePath: .nvmrc3435- script: |36set -e37echo "Checking if package.json or package-lock.json files were modified..."3839# Get the list of changed files in the PR40git fetch origin main41CHANGED_FILES=$(git diff --name-only origin/main...HEAD)42echo "Changed files:"43echo "$CHANGED_FILES"4445# Check if package.json or package-lock.json are in the changed files46if echo "$CHANGED_FILES" | grep -E '(^|/)package(-lock)?\.json$'; then47echo "##vso[task.setvariable variable=SHOULD_VALIDATE]true"48echo "Package files were modified, proceeding with validation"49else50echo "##vso[task.setvariable variable=SHOULD_VALIDATE]false"51echo "No package files were modified, skipping validation"52echo "##vso[task.complete result=Succeeded;]Pipeline completed successfully - no package validation needed"53fi54displayName: Check if package files were modified5556- script: node build/setup-npm-registry.ts $NPM_REGISTRY57condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'), eq(variables['SHOULD_VALIDATE'], 'true'))58displayName: Setup NPM Registry5960- script: |61set -e62# Set the private NPM registry to the global npmrc file63# so that authentication works for subfolders like build/, remote/, extensions/ etc64# which does not have their own .npmrc file65echo "NPMRC Path: $(npm config get userconfig)"66echo "NPM Registry: $(npm config get registry)"67npm config set registry "$NPM_REGISTRY"68echo "##vso[task.setvariable variable=NPMRC_PATH]$(npm config get userconfig)"69condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'), eq(variables['SHOULD_VALIDATE'], 'true'))70displayName: Setup NPM7172- task: npmAuthenticate@073inputs:74workingFile: $(NPMRC_PATH)75condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'), eq(variables['SHOULD_VALIDATE'], 'true'))76displayName: Setup NPM Authentication7778- script: sudo apt update -y && sudo apt install -y build-essential pkg-config libx11-dev libx11-xcb-dev libxkbfile-dev libnotify-bin libkrb5-dev79displayName: Install build tools80condition: and(succeeded(), eq(variables['SHOULD_VALIDATE'], 'true'))8182- script: |83set -e8485for attempt in {1..120}; do86if [ $attempt -gt 1 ]; then87echo "Attempt $attempt: Waiting for 10 minutes before retrying..."88sleep 60089fi9091echo "Attempt $attempt: Running npm ci"92if npm i --ignore-scripts; then93if node build/npm/postinstall.ts; then94echo "npm i succeeded on attempt $attempt"95exit 096else97echo "node build/npm/postinstall.ts failed on attempt $attempt"98fi99else100echo "npm i failed on attempt $attempt"101fi102done103104echo "giving up after 120 attempts (20 hours)"105exit 1106env:107npm_command: 'install --ignore-scripts'108ELECTRON_SKIP_BINARY_DOWNLOAD: 1109PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1110GITHUB_TOKEN: "$(github-distro-mixin-password)"111displayName: Install dependencies with retries112timeoutInMinutes: 1300113condition: and(succeeded(), eq(variables['SHOULD_VALIDATE'], 'true'))114115- script: |116set -e117find . -name 'package-lock.json' -exec sed -i "s|$NPM_REGISTRY|https://registry.npmjs.org/|g" {} \;118displayName: Restore registry URLs in package-lock.json119condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'), eq(variables['SHOULD_VALIDATE'], 'true'))120121- script: .github/workflows/check-clean-git-state.sh122displayName: Check clean git state123condition: and(succeeded(), eq(variables['SHOULD_VALIDATE'], 'true'))124125- script: node build/azure-pipelines/update-dependencies-check.ts126displayName: Update GitHub check run127condition: always()128env:129GITHUB_APP_ID: ${{ parameters.GITHUB_APP_ID }}130GITHUB_APP_INSTALLATION_ID: ${{ parameters.GITHUB_APP_INSTALLATION_ID }}131GITHUB_APP_PRIVATE_KEY: ${{ parameters.GITHUB_APP_PRIVATE_KEY }}132CHECK_RUN_ID: ${{ parameters.GITHUB_CHECK_RUN_ID }}133AGENT_JOBSTATUS: $(Agent.JobStatus)134135136