Path: blob/main/build/azure-pipelines/product-copilot.yml
13379 views
jobs:1- job: Copilot2displayName: Copilot3timeoutInMinutes: 604variables:5- name: skipComponentGovernanceDetection6value: true7- name: Codeql.SkipTaskAutoInjection8value: true9templateContext:10outputParentDirectory: $(Build.ArtifactStagingDirectory)11outputs:12- output: pipelineArtifact13targetPath: $(Build.ArtifactStagingDirectory)/copilot-vsix14artifactName: copilot_vsix15displayName: Publish Copilot VSIX16sbomEnabled: false17steps:18- checkout: self19lfs: true20fetchDepth: 121fetchTags: false22displayName: Checkout microsoft/vscode2324- template: copilot/setup-steps.yml25- template: copilot/test-steps.yml26parameters:27runIntegrationTests: false28- template: copilot/build-steps.yml29- template: copilot/l10n-steps.yml3031- task: notice@032inputs:33outputfile: $(Build.SourcesDirectory)/extensions/copilot/ThirdPartyNotices.txt34outputformat: text35continueOnError: true36retryCountOnTaskFailure: 537displayName: Generate NOTICE file3839- script: |40set -e41node << 'EOF'42const pkg = require("./package.json");43const EVENT_PREFIX = pkg.publisher + "." + pkg.name;44const cp = require("child_process");45const output = cp.spawnSync("npx", ["@vscode/telemetry-extractor", "--eventPrefix", EVENT_PREFIX, "-s", ".", "-o", ".", "-f", "telemetry"], { env: process.env, cwd: process.cwd(), shell: true });46if (output.error) {47console.log("stderr", (output.stderr || "").toString());48console.log("stdout", (output.stdout || "").toString());49throw output.error;50}51EOF52workingDirectory: $(Build.SourcesDirectory)/extensions/copilot53displayName: Extract telemetry54env:55npm_config_yes: "true"5657- script: |58set -e59if [ ! -f node_modules/jsonc-parser/package.json ]; then60npm install --location=global jsonc-parser61export NODE_PATH=$(npm root --location=global)62fi63find . -name "*.json" -type f -print0 | while IFS= read -r -d '' file; do64if [[ $file == *"node_modules"* ]]; then65continue66fi67echo "Minifying $file"68node -e "console.log(JSON.stringify(require('jsonc-parser').parse(require('fs').readFileSync('$file', 'utf8')), null, 0));" > "$file.min"69if [ ! -s "$file.min" ]; then70echo "Minification failed for $file"71rm "$file.min"72continue73fi74rm "$file"75mv "$file.min" "$file"76done77workingDirectory: $(Build.SourcesDirectory)/extensions/copilot78displayName: Minify JSON files7980- script: |81set -e82npx vsce package -o copilot-chat.vsix --allow-package-secrets sendgrid83mkdir -p $(Build.ArtifactStagingDirectory)/copilot-vsix84cp copilot-chat.vsix $(Build.ArtifactStagingDirectory)/copilot-vsix/85workingDirectory: $(Build.SourcesDirectory)/extensions/copilot86displayName: Package Copilot VSIX8788- task: AzureCLI@289displayName: Upload source maps to CDN90inputs:91azureSubscription: vscode-cdn92scriptType: bash93addSpnToEnvironment: true94scriptLocation: inlineScript95inlineScript: |96set -e9798WORKING_DIR="$(Build.SourcesDirectory)/extensions/copilot"99SOURCE_MAP_DIR="$WORKING_DIR/dist-sourcemaps"100STORAGE_ACCOUNT="vscodeweb"101102if [ ! -d "$SOURCE_MAP_DIR" ]; then103echo "Source maps directory not found: $SOURCE_MAP_DIR"104echo "Skipping upload."105exit 0106fi107108PUBLISHER=$(node -p "require('$WORKING_DIR/package.json').publisher")109NAME=$(node -p "require('$WORKING_DIR/package.json').name")110VERSION=$(node -p "require('$WORKING_DIR/package.json').version")111EXTENSION_ID=$(echo "${PUBLISHER}.${NAME}" | tr '[:upper:]' '[:lower:]')112113echo "Extension: $EXTENSION_ID"114echo "Version: $VERSION"115116MAP_FILES=$(find "$SOURCE_MAP_DIR" -name "*.map" -type f)117FILE_COUNT=$(echo "$MAP_FILES" | grep -c . || true)118119if [ "$FILE_COUNT" -eq 0 ]; then120echo "No source map files found in $SOURCE_MAP_DIR"121exit 0122fi123124echo "Found $FILE_COUNT source map files"125126BLOB_URL="https://${STORAGE_ACCOUNT}.blob.core.windows.net"127PREFIX="sourcemaps/${EXTENSION_ID}/${VERSION}"128129echo "Uploading to: $BLOB_URL/\$web/$PREFIX/"130131UPLOADED=0132for FILE in $MAP_FILES; do133FILENAME=$(basename "$FILE")134BLOB_NAME="$PREFIX/$FILENAME"135136az storage blob upload \137--account-name "$STORAGE_ACCOUNT" \138--container-name '$web' \139--name "$BLOB_NAME" \140--file "$FILE" \141--content-type "application/json" \142--content-cache-control "max-age=31536000, public" \143--auth-mode login \144--overwrite \145--only-show-errors146147UPLOADED=$((UPLOADED + 1))148done149150echo "Successfully uploaded $UPLOADED source maps"151152# Upload commit-to-version mapping so the deminify service153# can resolve the patched extension version from a VS Code commit hash.154COMMIT_HASH="$(Build.SourceVersion)"155MAPPING_BLOB="sourcemaps/${EXTENSION_ID}/commits/${COMMIT_HASH}.json"156echo "{\"version\":\"${VERSION}\",\"extensionId\":\"${EXTENSION_ID}\"}" > /tmp/commit-version.json157158echo "Uploading commit mapping: $COMMIT_HASH -> $VERSION"159az storage blob upload \160--account-name "$STORAGE_ACCOUNT" \161--container-name '$web' \162--name "$MAPPING_BLOB" \163--file "/tmp/commit-version.json" \164--content-type "application/json" \165--content-cache-control "no-cache, no-store, must-revalidate" \166--auth-mode login \167--overwrite \168--only-show-errors169170echo "Commit mapping uploaded: $MAPPING_BLOB"171172173