Path: blob/main/extensions/copilot/test/simulation/fixtures/codeMapper/product-build-linux.yml
13399 views
parameters:1- name: VSCODE_QUALITY2type: string3- name: VSCODE_ARCH4type: string5- name: VSCODE_CIBUILD6type: boolean7- name: VSCODE_RUN_ELECTRON_TESTS8type: boolean9default: false10- name: VSCODE_RUN_BROWSER_TESTS11type: boolean12default: false13- name: VSCODE_RUN_REMOTE_TESTS14type: boolean15default: false16- name: VSCODE_TEST_ARTIFACT_NAME17type: string18default: ""1920steps:21- ${{ if eq(parameters.VSCODE_QUALITY, 'oss') }}:22- checkout: self23fetchDepth: 124retryCountOnTaskFailure: 32526- task: NodeTool@027inputs:28versionSource: fromFile29versionFilePath: .nvmrc30nodejsMirror: https://github.com/joaomoreno/node-mirror/releases/download3132- ${{ if ne(parameters.VSCODE_QUALITY, 'oss') }}:33- template: ../distro/download-distro.yml@self3435- task: AzureKeyVault@236displayName: "Azure Key Vault: Get Secrets"37inputs:38azureSubscription: vscode39KeyVaultName: vscode-build-secrets40SecretsFilter: "github-distro-mixin-password"4142- task: DownloadPipelineArtifact@243inputs:44artifact: Compilation45path: $(Build.ArtifactStagingDirectory)46displayName: Download compilation output4748- script: tar -xzf $(Build.ArtifactStagingDirectory)/compilation.tar.gz49displayName: Extract compilation output5051- script: |52set -e53# Start X server54./build/azure-pipelines/linux/apt-retry.sh sudo apt-get update55./build/azure-pipelines/linux/apt-retry.sh sudo apt-get install -y pkg-config \56dbus \57xvfb \58libgtk-3-0 \59libxkbfile-dev \60libkrb5-dev \61libgbm1 \62rpm63sudo cp build/azure-pipelines/linux/xvfb.init /etc/init.d/xvfb64sudo chmod +x /etc/init.d/xvfb65sudo update-rc.d xvfb defaults66sudo service xvfb start67# Start dbus session68sudo mkdir -p /var/run/dbus69DBUS_LAUNCH_RESULT=$(sudo dbus-daemon --config-file=/usr/share/dbus-1/system.conf --print-address)70echo "##vso[task.setvariable variable=DBUS_SESSION_BUS_ADDRESS]$DBUS_LAUNCH_RESULT"71displayName: Setup system services7273- script: node build/setup-npm-registry.js $NPM_REGISTRY74condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'))75displayName: Setup NPM Registry7677- script: mkdir -p .build && node build/azure-pipelines/common/computeNodeModulesCacheKey.js linux $VSCODE_ARCH $(node -p process.arch) > .build/packagelockhash78displayName: Prepare node_modules cache key7980- task: Cache@281inputs:82key: '"node_modules" | .build/packagelockhash'83path: .build/node_modules_cache84cacheHitVar: NODE_MODULES_RESTORED85displayName: Restore node_modules cache8687- script: tar -xzf .build/node_modules_cache/cache.tgz88condition: and(succeeded(), eq(variables.NODE_MODULES_RESTORED, 'true'))89displayName: Extract node_modules cache9091- script: |92set -e93# Set the private NPM registry to the global npmrc file94# so that authentication works for subfolders like build/, remote/, extensions/ etc95# which does not have their own .npmrc file96npm config set registry "$NPM_REGISTRY"97echo "##vso[task.setvariable variable=NPMRC_PATH]$(npm config get userconfig)"98condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))99displayName: Setup NPM100101- task: npmAuthenticate@0102inputs:103workingFile: $(NPMRC_PATH)104condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))105displayName: Setup NPM Authentication106107- script: |108set -e109110for i in {1..5}; do # try 5 times111npm ci && break112if [ $i -eq 5 ]; then113echo "Npm install failed too many times" >&2114exit 1115fi116echo "Npm install failed $i, trying again..."117done118workingDirectory: build119env:120GITHUB_TOKEN: "$(github-distro-mixin-password)"121displayName: Install build dependencies122condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))123124# Step will be used by both Install dependencies and building rpm package,125# hence avoid adding it behind NODE_MODULES_RESTORED condition.126- script: |127set -e128SYSROOT_ARCH=$VSCODE_ARCH129if [ "$SYSROOT_ARCH" == "x64" ]; then130SYSROOT_ARCH="amd64"131fi132export VSCODE_SYSROOT_DIR=$(Build.SourcesDirectory)/.build/sysroots133SYSROOT_ARCH="$SYSROOT_ARCH" node -e '(async () => { const { getVSCodeSysroot } = require("./build/linux/debian/install-sysroot.js"); await getVSCodeSysroot(process.env["SYSROOT_ARCH"]); })()'134env:135VSCODE_ARCH: $(VSCODE_ARCH)136GITHUB_TOKEN: "$(github-distro-mixin-password)"137displayName: Download vscode sysroots138139- ${{ if or(eq(parameters.VSCODE_ARCH, 'arm64'), eq(parameters.VSCODE_ARCH, 'armhf')) }}:140- script: |141set -e142includes=$(cat << 'EOF'143{144"target_defaults": {145"conditions": [146["OS=='linux'", {147'cflags_cc!': [ '-std=gnu++20' ],148'cflags_cc': [ '-std=gnu++2a' ],149}]150]151}152}153EOF154)155if [ ! -d "$HOME/.gyp" ]; then156mkdir -p "$HOME/.gyp"157fi158echo "$includes" > "$HOME/.gyp/include.gypi"159displayName: Override gnu target for arm64 and arm160161- script: |162set -e163164source ./build/azure-pipelines/linux/setup-env.sh165166for i in {1..5}; do # try 5 times167npm ci && break168if [ $i -eq 5 ]; then169echo "Npm install failed too many times" >&2170exit 1171fi172echo "Npm install failed $i, trying again..."173done174env:175npm_config_arch: $(NPM_ARCH)176VSCODE_ARCH: $(VSCODE_ARCH)177ELECTRON_SKIP_BINARY_DOWNLOAD: 1178PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1179GITHUB_TOKEN: "$(github-distro-mixin-password)"180displayName: Install dependencies181condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))182183- ${{ if ne(parameters.VSCODE_QUALITY, 'oss') }}:184- script: node build/azure-pipelines/distro/mixin-npm185condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))186displayName: Mixin distro node modules187188- script: |189set -e190node build/azure-pipelines/common/listNodeModules.js .build/node_modules_list.txt191mkdir -p .build/node_modules_cache192tar -czf .build/node_modules_cache/cache.tgz --files-from .build/node_modules_list.txt193condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))194displayName: Create node_modules archive195196- ${{ if ne(parameters.VSCODE_QUALITY, 'oss') }}:197- script: node build/azure-pipelines/distro/mixin-quality198displayName: Mixin distro quality199200- template: ../common/install-builtin-extensions.yml@self201202- ${{ if ne(parameters.VSCODE_QUALITY, 'oss') }}:203- script: |204set -e205npm run gulp vscode-linux-$(VSCODE_ARCH)-min-ci206ARCHIVE_PATH=".build/linux/client/code-${{ parameters.VSCODE_QUALITY }}-$(VSCODE_ARCH)-$(date +%s).tar.gz"207mkdir -p $(dirname $ARCHIVE_PATH)208echo "##vso[task.setvariable variable=CLIENT_PATH]$ARCHIVE_PATH"209env:210GITHUB_TOKEN: "$(github-distro-mixin-password)"211displayName: Build client212213- ${{ if ne(parameters.VSCODE_CIBUILD, true) }}:214- task: DownloadPipelineArtifact@2215inputs:216artifact: $(ARTIFACT_PREFIX)vscode_cli_linux_$(VSCODE_ARCH)_cli217patterns: "**"218path: $(Build.ArtifactStagingDirectory)/cli219displayName: Download VS Code CLI220221- script: |222set -e223tar -xzvf $(Build.ArtifactStagingDirectory)/cli/*.tar.gz -C $(Build.ArtifactStagingDirectory)/cli224CLI_APP_NAME=$(node -p "require(\"$(agent.builddirectory)/VSCode-linux-$(VSCODE_ARCH)/resources/app/product.json\").tunnelApplicationName")225APP_NAME=$(node -p "require(\"$(agent.builddirectory)/VSCode-linux-$(VSCODE_ARCH)/resources/app/product.json\").applicationName")226mv $(Build.ArtifactStagingDirectory)/cli/$APP_NAME $(agent.builddirectory)/VSCode-linux-$(VSCODE_ARCH)/bin/$CLI_APP_NAME227displayName: Mix in CLI228229- script: |230set -e231tar -czf $CLIENT_PATH -C .. VSCode-linux-$(VSCODE_ARCH)232env:233GITHUB_TOKEN: "$(github-distro-mixin-password)"234displayName: Archive client235236- script: |237set -e238npm run gulp vscode-reh-linux-$(VSCODE_ARCH)-min-ci239mv ../vscode-reh-linux-$(VSCODE_ARCH) ../vscode-server-linux-$(VSCODE_ARCH) # TODO@joaomoreno240ARCHIVE_PATH=".build/linux/server/vscode-server-linux-$(VSCODE_ARCH).tar.gz"241UNARCHIVE_PATH="`pwd`/../vscode-server-linux-$(VSCODE_ARCH)"242mkdir -p $(dirname $ARCHIVE_PATH)243tar --owner=0 --group=0 -czf $ARCHIVE_PATH -C .. vscode-server-linux-$(VSCODE_ARCH)244echo "##vso[task.setvariable variable=SERVER_PATH]$ARCHIVE_PATH"245echo "##vso[task.setvariable variable=SERVER_UNARCHIVE_PATH]$UNARCHIVE_PATH"246env:247GITHUB_TOKEN: "$(github-distro-mixin-password)"248displayName: Build server249250- script: |251set -e252npm run gulp vscode-reh-web-linux-$(VSCODE_ARCH)-min-ci253mv ../vscode-reh-web-linux-$(VSCODE_ARCH) ../vscode-server-linux-$(VSCODE_ARCH)-web # TODO@joaomoreno254ARCHIVE_PATH=".build/linux/web/vscode-server-linux-$(VSCODE_ARCH)-web.tar.gz"255mkdir -p $(dirname $ARCHIVE_PATH)256tar --owner=0 --group=0 -czf $ARCHIVE_PATH -C .. vscode-server-linux-$(VSCODE_ARCH)-web257echo "##vso[task.setvariable variable=WEB_PATH]$ARCHIVE_PATH"258env:259GITHUB_TOKEN: "$(github-distro-mixin-password)"260displayName: Build server (web)261262- ${{ if or(eq(parameters.VSCODE_ARCH, 'x64'), eq(parameters.VSCODE_ARCH, 'arm64')) }}:263- script: |264set -e265266EXPECTED_GLIBC_VERSION="2.28" \267EXPECTED_GLIBCXX_VERSION="3.4.25" \268./build/azure-pipelines/linux/verify-glibc-requirements.sh269env:270SEARCH_PATH: $(SERVER_UNARCHIVE_PATH)271npm_config_arch: $(NPM_ARCH)272VSCODE_ARCH: $(VSCODE_ARCH)273displayName: Check GLIBC and GLIBCXX dependencies in server archive274275- ${{ else }}:276- script: |277set -e278279EXPECTED_GLIBC_VERSION="2.28" \280EXPECTED_GLIBCXX_VERSION="3.4.26" \281./build/azure-pipelines/linux/verify-glibc-requirements.sh282env:283SEARCH_PATH: $(SERVER_UNARCHIVE_PATH)284npm_config_arch: $(NPM_ARCH)285VSCODE_ARCH: $(VSCODE_ARCH)286displayName: Check GLIBC and GLIBCXX dependencies in server archive287288- ${{ else }}:289- script: npm run gulp "transpile-client-esbuild" "transpile-extensions"290env:291GITHUB_TOKEN: "$(github-distro-mixin-password)"292displayName: Transpile client and extensions293294- ${{ if or(eq(parameters.VSCODE_RUN_ELECTRON_TESTS, true), eq(parameters.VSCODE_RUN_BROWSER_TESTS, true), eq(parameters.VSCODE_RUN_REMOTE_TESTS, true)) }}:295- template: product-build-linux-test.yml@self296parameters:297VSCODE_QUALITY: ${{ parameters.VSCODE_QUALITY }}298VSCODE_RUN_ELECTRON_TESTS: ${{ parameters.VSCODE_RUN_ELECTRON_TESTS }}299VSCODE_RUN_BROWSER_TESTS: ${{ parameters.VSCODE_RUN_BROWSER_TESTS }}300VSCODE_RUN_REMOTE_TESTS: ${{ parameters.VSCODE_RUN_REMOTE_TESTS }}301VSCODE_TEST_ARTIFACT_NAME: ${{ parameters.VSCODE_TEST_ARTIFACT_NAME }}302${{ if ne(parameters.VSCODE_QUALITY, 'oss') }}:303PUBLISH_TASK_NAME: 1ES.PublishPipelineArtifact@1304305- ${{ if and(ne(parameters.VSCODE_CIBUILD, true), ne(parameters.VSCODE_QUALITY, 'oss')) }}:306- script: |307set -e308npm run gulp "vscode-linux-$(VSCODE_ARCH)-prepare-deb"309env:310GITHUB_TOKEN: "$(github-distro-mixin-password)"311displayName: Prepare deb package312313- script: |314set -e315npm run gulp "vscode-linux-$(VSCODE_ARCH)-build-deb"316file_output=$(file $(ls .build/linux/deb/*/deb/*.deb))317if [[ "$file_output" != *"data compression xz"* ]]; then318echo "Error: unknown compression. $file_output"319exit 1320fi321echo "##vso[task.setvariable variable=DEB_PATH]$(ls .build/linux/deb/*/deb/*.deb)"322displayName: Build deb package323324- script: |325set -e326TRIPLE=""327if [ "$VSCODE_ARCH" == "x64" ]; then328TRIPLE="x86_64-linux-gnu"329elif [ "$VSCODE_ARCH" == "arm64" ]; then330TRIPLE="aarch64-linux-gnu"331elif [ "$VSCODE_ARCH" == "armhf" ]; then332TRIPLE="arm-rpi-linux-gnueabihf"333fi334export VSCODE_SYSROOT_DIR=$(Build.SourcesDirectory)/.build/sysroots335export STRIP="$VSCODE_SYSROOT_DIR/$TRIPLE/$TRIPLE/bin/strip"336npm run gulp "vscode-linux-$(VSCODE_ARCH)-prepare-rpm"337env:338VSCODE_ARCH: $(VSCODE_ARCH)339displayName: Prepare rpm package340341- script: |342set -e343npm run gulp "vscode-linux-$(VSCODE_ARCH)-build-rpm"344echo "##vso[task.setvariable variable=RPM_PATH]$(ls .build/linux/rpm/*/*.rpm)"345displayName: Build rpm package346347- task: Docker@1348inputs:349azureSubscriptionEndpoint: vscode350azureContainerRegistry: vscodehub.azurecr.io351command: Run an image352imageName: vscodehub.azurecr.io/vscode-linux-build-agent:snapcraft-x64353containerCommand: uname354displayName: Pull snap build image355356- script: |357set -e358npm run gulp "vscode-linux-$(VSCODE_ARCH)-prepare-snap"359360361362363# Get snapcraft version364snapcraft --version365366# Make sure we get latest packages367sudo apt-get update368sudo apt-get upgrade -y369sudo apt-get install -y curl apt-transport-https ca-certificates370371# Define variables372SNAP_ROOT="$(pwd)/.build/linux/snap/$(VSCODE_ARCH)"373374# Unpack snap tarball artifact, in order to preserve file perms375(cd .build/linux && tar -xzf snap-tarball/snap-$(VSCODE_ARCH).tar.gz)376377# Create snap package378BUILD_VERSION="$(date +%s)"379SNAP_FILENAME="code-$VSCODE_QUALITY-$(VSCODE_ARCH)-$BUILD_VERSION.snap"380SNAP_PATH="$SNAP_ROOT/$SNAP_FILENAME"381case $(VSCODE_ARCH) in382x64) SNAPCRAFT_TARGET_ARGS="" ;;383*) SNAPCRAFT_TARGET_ARGS="--target-arch $(VSCODE_ARCH)" ;;384esac385(cd $SNAP_ROOT/code-* && sudo --preserve-env snapcraft snap $SNAPCRAFT_TARGET_ARGS --output "$SNAP_PATH")386387388389390391echo "##vso[task.setvariable variable=SNAP_PATH]$ARCHIVE_PATH"392displayName: Build snap package393394- task: UseDotNet@2395inputs:396version: 6.x397398- task: EsrpCodeSigning@5399inputs:400UseMSIAuthentication: true401ConnectedServiceName: vscode-esrp402AppRegistrationClientId: $(ESRP_CLIENT_ID)403AppRegistrationTenantId: $(ESRP_TENANT_ID)404AuthAKVName: vscode-esrp405AuthSignCertName: esrp-sign406FolderPath: .407Pattern: noop408displayName: 'Install ESRP Tooling'409410- script: node build/azure-pipelines/common/sign $(Agent.RootDirectory)/_tasks/EsrpCodeSigning_*/*/net6.0/esrpcli.dll sign-pgp .build/linux/deb '*.deb'411env:412SYSTEM_ACCESSTOKEN: $(System.AccessToken)413displayName: Codesign deb414415- script: node build/azure-pipelines/common/sign $(Agent.RootDirectory)/_tasks/EsrpCodeSigning_*/*/net6.0/esrpcli.dll sign-pgp .build/linux/rpm '*.rpm'416env:417SYSTEM_ACCESSTOKEN: $(System.AccessToken)418displayName: Codesign rpm419420- script: echo "##vso[task.setvariable variable=ARTIFACT_PREFIX]attempt$(System.JobAttempt)_"421condition: and(succeededOrFailed(), notIn(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues'))422displayName: Generate artifact prefix423424- task: 1ES.PublishPipelineArtifact@1425inputs:426targetPath: $(CLIENT_PATH)427artifactName: $(ARTIFACT_PREFIX)vscode_client_linux_$(VSCODE_ARCH)_archive-unsigned428sbomBuildDropPath: $(Agent.BuildDirectory)/VSCode-linux-$(VSCODE_ARCH)429sbomPackageName: "VS Code Linux $(VSCODE_ARCH) (unsigned)"430sbomPackageVersion: $(Build.SourceVersion)431condition: and(succeededOrFailed(), ne(variables['CLIENT_PATH'], ''))432displayName: Publish client archive433434- task: 1ES.PublishPipelineArtifact@1435inputs:436targetPath: $(SERVER_PATH)437artifactName: $(ARTIFACT_PREFIX)vscode_server_linux_$(VSCODE_ARCH)_archive-unsigned438sbomBuildDropPath: $(Agent.BuildDirectory)/vscode-server-linux-$(VSCODE_ARCH)439sbomPackageName: "VS Code Linux $(VSCODE_ARCH) Server"440sbomPackageVersion: $(Build.SourceVersion)441condition: and(succeededOrFailed(), ne(variables['SERVER_PATH'], ''))442displayName: Publish server archive443444- task: 1ES.PublishPipelineArtifact@1445inputs:446targetPath: $(WEB_PATH)447artifactName: $(ARTIFACT_PREFIX)vscode_web_linux_$(VSCODE_ARCH)_archive-unsigned448sbomBuildDropPath: $(Agent.BuildDirectory)/vscode-server-linux-$(VSCODE_ARCH)-web449sbomPackageName: "VS Code Linux $(VSCODE_ARCH) Web"450sbomPackageVersion: $(Build.SourceVersion)451condition: and(succeededOrFailed(), ne(variables['WEB_PATH'], ''))452displayName: Publish web server archive453454- task: 1ES.PublishPipelineArtifact@1455inputs:456targetPath: $(DEB_PATH)457artifactName: $(ARTIFACT_PREFIX)vscode_client_linux_$(VSCODE_ARCH)_deb-package458sbomBuildDropPath: .build/linux/deb459sbomPackageName: "VS Code Linux $(VSCODE_ARCH) DEB"460sbomPackageVersion: $(Build.SourceVersion)461condition: and(succeededOrFailed(), ne(variables['DEB_PATH'], ''))462displayName: Publish deb package463464- task: 1ES.PublishPipelineArtifact@1465inputs:466targetPath: $(RPM_PATH)467artifactName: $(ARTIFACT_PREFIX)vscode_client_linux_$(VSCODE_ARCH)_rpm-package468sbomBuildDropPath: .build/linux/rpm469sbomPackageName: "VS Code Linux $(VSCODE_ARCH) RPM"470sbomPackageVersion: $(Build.SourceVersion)471condition: and(succeededOrFailed(), ne(variables['RPM_PATH'], ''))472displayName: Publish rpm package473474- task: 1ES.PublishPipelineArtifact@1475inputs:476targetPath: $(SNAP_PATH)477artifactName: vscode_client_linux_$(VSCODE_ARCH)_snap478sbomBuildDropPath: $(SNAP_EXTRACTED_PATH)479sbomPackageName: "VS Code Linux $(VSCODE_ARCH) SNAP"480sbomPackageVersion: $(Build.SourceVersion)481condition: and(succeededOrFailed(), ne(variables['SNAP_PATH'], ''))482displayName: Publish snap package483484