Path: blob/main/build/azure-pipelines/product-npm-package-validate.yml
3520 views
trigger: none12pr:3branches:4include: ["main"]56variables:7- name: NPM_REGISTRY8value: "https://pkgs.dev.azure.com/monacotools/Monaco/_packaging/vscode/npm/registry/"9- name: VSCODE_QUALITY10value: oss1112jobs:13- job: ValidateNpmPackages14displayName: Valiate NPM packages against Terrapin15pool:16name: 1es-ubuntu-22.04-x6417os: linux18timeoutInMinutes: 4000019continueOnError: true20variables:21VSCODE_ARCH: x6422steps:23- task: NodeTool@024inputs:25versionSource: fromFile26versionFilePath: .nvmrc2728- script: |29set -e30echo "Checking if package.json or package-lock.json files were modified..."3132# Get the list of changed files in the PR33git fetch origin main34CHANGED_FILES=$(git diff --name-only origin/main...HEAD)35echo "Changed files:"36echo "$CHANGED_FILES"3738# Check if package.json or package-lock.json are in the changed files39if echo "$CHANGED_FILES" | grep -E '^(package\.json|package-lock\.json)$'; then40echo "##vso[task.setvariable variable=SHOULD_VALIDATE]true"41echo "Package files were modified, proceeding with validation"42else43echo "##vso[task.setvariable variable=SHOULD_VALIDATE]false"44echo "No package files were modified, skipping validation"45echo "##vso[task.complete result=Succeeded;]Pipeline completed successfully - no package validation needed"46fi47displayName: Check if package files were modified4849- script: node build/setup-npm-registry.js $NPM_REGISTRY50condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'), eq(variables['SHOULD_VALIDATE'], 'true'))51displayName: Setup NPM Registry5253- script: |54set -e55# Set the private NPM registry to the global npmrc file56# so that authentication works for subfolders like build/, remote/, extensions/ etc57# which does not have their own .npmrc file58echo "NPMRC Path: $(npm config get userconfig)"59echo "NPM Registry: $(npm config get registry)"60npm config set registry "$NPM_REGISTRY"61echo "##vso[task.setvariable variable=NPMRC_PATH]$(npm config get userconfig)"62condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'), eq(variables['SHOULD_VALIDATE'], 'true'))63displayName: Setup NPM6465- task: npmAuthenticate@066inputs:67workingFile: $(NPMRC_PATH)68condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'), eq(variables['SHOULD_VALIDATE'], 'true'))69displayName: Setup NPM Authentication7071- script: sudo apt update -y && sudo apt install -y build-essential pkg-config libx11-dev libx11-xcb-dev libxkbfile-dev libnotify-bin libkrb5-dev72displayName: Install build tools73condition: and(succeeded(), eq(variables['SHOULD_VALIDATE'], 'true'))7475- script: |76set -e7778for attempt in {1..12}; do79if [ $attempt -gt 1 ]; then80echo "Attempt $attempt: Waiting for 30 minutes before retrying..."81sleep 180082fi8384echo "Attempt $attempt: Running npm ci"85if npm i --ignore-scripts; then86if node build/npm/postinstall.js; then87echo "npm i succeeded on attempt $attempt"88exit 089else90echo "node build/npm/postinstall.js failed on attempt $attempt"91fi92else93echo "npm i failed on attempt $attempt"94fi95done9697echo "npm i failed after 12 attempts"98exit 199env:100npm_command: 'install --ignore-scripts'101ELECTRON_SKIP_BINARY_DOWNLOAD: 1102PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1103GITHUB_TOKEN: "$(github-distro-mixin-password)"104displayName: Install dependencies with retries105timeoutInMinutes: 400106condition: and(succeeded(), eq(variables['SHOULD_VALIDATE'], 'true'))107108- script: .github/workflows/check-clean-git-state.sh109displayName: Check clean git state110condition: and(succeeded(), eq(variables['SHOULD_VALIDATE'], 'true'))111112113