pr: none

schedules:
  - cron: "0 5 * * Mon-Fri"
    displayName: Mon-Fri at 7:00
    branches:
      include:
        - main
  - cron: "0 17 * * Mon-Fri"
    displayName: Mon-Fri at 19:00
    branches:
      include:
        - main

trigger:
  batch: true
  branches:
    include: ["main", "release/*"]

parameters:
  - name: VSCODE_QUALITY
    displayName: Quality
    type: string
    default: insider
    values:
      - exploration
      - insider
      - stable
  - name: VSCODE_BUILD_TYPE
    displayName: Build Type
    type: string
    default: Product
    values:
      - Product
      - CI
  - name: NPM_REGISTRY
    displayName: "Custom NPM Registry"
    type: string
    default: 'https://pkgs.dev.azure.com/monacotools/Monaco/_packaging/vscode/npm/registry/'
  - name: CARGO_REGISTRY
    displayName: "Custom Cargo Registry"
    type: string
    default: 'sparse+https://pkgs.dev.azure.com/monacotools/Monaco/_packaging/vscode/Cargo/index/'
  - name: VSCODE_BUILD_WIN32
    displayName: "🎯 Windows x64"
    type: boolean
    default: true
  - name: VSCODE_BUILD_WIN32_ARM64
    displayName: "🎯 Windows arm64"
    type: boolean
    default: true
  - name: VSCODE_BUILD_LINUX
    displayName: "🎯 Linux x64"
    type: boolean
    default: true
  - name: VSCODE_BUILD_LINUX_SNAP
    displayName: "🎯 Linux x64 Snap"
    type: boolean
    default: true
  - name: VSCODE_BUILD_LINUX_ARM64
    displayName: "🎯 Linux arm64"
    type: boolean
    default: true
  - name: VSCODE_BUILD_LINUX_ARMHF
    displayName: "🎯 Linux armhf"
    type: boolean
    default: true
  - name: VSCODE_BUILD_ALPINE
    displayName: "🎯 Alpine x64"
    type: boolean
    default: true
  - name: VSCODE_BUILD_ALPINE_ARM64
    displayName: "🎯 Alpine arm64"
    type: boolean
    default: true
  - name: VSCODE_BUILD_MACOS
    displayName: "🎯 macOS x64"
    type: boolean
    default: true
  - name: VSCODE_BUILD_MACOS_ARM64
    displayName: "🎯 macOS arm64"
    type: boolean
    default: true
  - name: VSCODE_BUILD_MACOS_UNIVERSAL
    displayName: "🎯 macOS universal"
    type: boolean
    default: true
  - name: VSCODE_BUILD_WEB
    displayName: "🎯 Web"
    type: boolean
    default: true
  - name: VSCODE_PUBLISH
    displayName: "Publish to builds.code.visualstudio.com"
    type: boolean
    default: true
  - name: VSCODE_RELEASE
    displayName: "Release build if successful"
    type: boolean
    default: false
  - name: VSCODE_STEP_ON_IT
    displayName: "Skip tests"
    type: boolean
    default: false

variables:
  - name: VSCODE_PRIVATE_BUILD
    value: ${{ ne(variables['Build.Repository.Uri'], 'https://github.com/microsoft/vscode.git') }}
  - name: NPM_REGISTRY
    value: ${{ parameters.NPM_REGISTRY }}
  - name: CARGO_REGISTRY
    value: ${{ parameters.CARGO_REGISTRY }}
  - name: VSCODE_QUALITY
    value: ${{ parameters.VSCODE_QUALITY }}
  - name: VSCODE_BUILD_STAGE_WINDOWS
    value: ${{ or(eq(parameters.VSCODE_BUILD_WIN32, true), eq(parameters.VSCODE_BUILD_WIN32_ARM64, true)) }}
  - name: VSCODE_BUILD_STAGE_LINUX
    value: ${{ or(eq(parameters.VSCODE_BUILD_LINUX, true), eq(parameters.VSCODE_BUILD_LINUX_SNAP, true), eq(parameters.VSCODE_BUILD_LINUX_ARMHF, true), eq(parameters.VSCODE_BUILD_LINUX_ARM64, true)) }}
  - name: VSCODE_BUILD_STAGE_ALPINE
    value: ${{ or(eq(parameters.VSCODE_BUILD_ALPINE, true), eq(parameters.VSCODE_BUILD_ALPINE_ARM64, true)) }}
  - name: VSCODE_BUILD_STAGE_MACOS
    value: ${{ or(eq(parameters.VSCODE_BUILD_MACOS, true), eq(parameters.VSCODE_BUILD_MACOS_ARM64, true)) }}
  - name: VSCODE_BUILD_STAGE_WEB
    value: ${{ eq(parameters.VSCODE_BUILD_WEB, true) }}
  - name: VSCODE_CIBUILD
    value: ${{ or(in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI'), eq(parameters.VSCODE_BUILD_TYPE, 'CI')) }}
  - name: VSCODE_PUBLISH
    value: ${{ and(eq(parameters.VSCODE_PUBLISH, true), eq(variables.VSCODE_CIBUILD, false)) }}
  - name: VSCODE_SCHEDULEDBUILD
    value: ${{ eq(variables['Build.Reason'], 'Schedule') }}
  - name: VSCODE_STEP_ON_IT
    value: ${{ eq(parameters.VSCODE_STEP_ON_IT, true) }}
  - name: VSCODE_BUILD_MACOS_UNIVERSAL
    value: ${{ and(eq(parameters.VSCODE_BUILD_MACOS, true), eq(parameters.VSCODE_BUILD_MACOS_ARM64, true), eq(parameters.VSCODE_BUILD_MACOS_UNIVERSAL, true)) }}
  - name: VSCODE_STAGING_BLOB_STORAGE_ACCOUNT_NAME
    value: vscodeesrp
  - name: PRSS_CDN_URL
    value: https://vscode.download.prss.microsoft.com/dbazure/download
  - name: VSCODE_ESRP_SERVICE_CONNECTION_ID
    value: fe07e6ce-6ffb-4df9-8d27-d129523a3f3e
  - name: VSCODE_ESRP_TENANT_ID
    value: 975f013f-7f24-47e8-a7d3-abc4752bf346
  - name: VSCODE_ESRP_CLIENT_ID
    value: 4ac7ed59-b5e9-4f66-9c30-8d1afa72d32d
  - name: ESRP_TENANT_ID
    value: 975f013f-7f24-47e8-a7d3-abc4752bf346
  - name: ESRP_CLIENT_ID
    value: c24324f7-e65f-4c45-8702-ed2d4c35df99
  - name: AZURE_DOCUMENTDB_ENDPOINT
    value: https://vscode.documents.azure.com/
  - name: VSCODE_MIXIN_REPO
    value: microsoft/vscode-distro
  - name: skipComponentGovernanceDetection
    value: true
  - name: ComponentDetection.Timeout
    value: 600
  - name: Codeql.SkipTaskAutoInjection
    value: true
  - name: ARTIFACT_PREFIX
    value: ''

name: "$(Date:yyyyMMdd).$(Rev:r) (${{ parameters.VSCODE_QUALITY }})"

resources:
  repositories:
    - repository: 1esPipelines
      type: git
      name: 1ESPipelineTemplates/1ESPipelineTemplates
      ref: refs/tags/release

extends:
  template: v1/1ES.Official.PipelineTemplate.yml@1esPipelines
  parameters:
    sdl:
      tsa:
        enabled: true
        configFile: $(Build.SourcesDirectory)/build/azure-pipelines/config/tsaoptions.json
      binskim:
        analyzeTargetGlob: '+:file|$(Agent.BuildDirectory)/VSCode-*/**/*.exe;+:file|$(Agent.BuildDirectory)/VSCode-*/**/*.dll;+:file|$(Agent.BuildDirectory)/VSCode-*/**/*.node;-:file|$(Agent.BuildDirectory)/VSCode-*/**/resources/**/*.exe;-:file|$(Agent.BuildDirectory)/VSCode-*/**/resources/**/*.node;-:file|$(Build.SourcesDirectory)/.build/**/system-setup/VSCodeSetup*.exe;-:file|$(Build.SourcesDirectory)/.build/**/user-setup/VSCodeUserSetup*.exe'
      codeql:
        runSourceLanguagesInSourceAnalysis: true
        compiled:
          enabled: false
          justificationForDisabling: "CodeQL breaks ESRP CodeSign on macOS (ICM #520035761, githubcustomers/microsoft-codeql-support#198)"
      credscan:
        suppressionsFile: $(Build.SourcesDirectory)/build/azure-pipelines/config/CredScanSuppressions.json
      eslint:
        enabled: true
        enableExclusions: true
        exclusionsFilePath: $(Build.SourcesDirectory)/.eslint-ignore
      sourceAnalysisPool: 1es-windows-2022-x64
      createAdoIssuesForJustificationsForDisablement: false
    containers:
      ubuntu-2004-arm64:
        image: onebranch.azurecr.io/linux/ubuntu-2004-arm64:latest
    stages:

      - stage: Quality
        dependsOn: []
        pool:
          name: 1es-ubuntu-22.04-x64
          os: linux
        jobs:
          - template: build/azure-pipelines/product-quality-checks.yml@self

      - ${{ if eq(variables['VSCODE_BUILD_STAGE_WINDOWS'], true) }}:
        - stage: Windows
          dependsOn: []
          pool:
            name: 1es-windows-2022-x64
            os: windows
          jobs:
            - ${{ if eq(parameters.VSCODE_BUILD_WIN32, true) }}:
              - template: build/azure-pipelines/win32/product-build-win32-cli.yml@self
                parameters:
                  VSCODE_ARCH: x64
                  VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }}
                  VSCODE_CHECK_ONLY: ${{ variables.VSCODE_CIBUILD }}

            - ${{ if and(eq(variables['VSCODE_CIBUILD'], false), eq(parameters.VSCODE_BUILD_WIN32_ARM64, true)) }}:
              - template: build/azure-pipelines/win32/product-build-win32-cli.yml@self
                parameters:
                  VSCODE_ARCH: arm64
                  VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }}

            - ${{ if eq(variables['VSCODE_CIBUILD'], true) }}:
              - template: build/azure-pipelines/win32/product-build-win32-ci.yml@self
                parameters:
                  VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }}
                  VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }}
                  VSCODE_TEST_SUITE: Electron
              - template: build/azure-pipelines/win32/product-build-win32-ci.yml@self
                parameters:
                  VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }}
                  VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }}
                  VSCODE_TEST_SUITE: Browser
              - template: build/azure-pipelines/win32/product-build-win32-ci.yml@self
                parameters:
                  VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }}
                  VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }}
                  VSCODE_TEST_SUITE: Remote

            - ${{ if and(eq(variables['VSCODE_CIBUILD'], false), eq(parameters.VSCODE_BUILD_WIN32, true)) }}:
              - template: build/azure-pipelines/win32/product-build-win32.yml@self
                parameters:
                  VSCODE_ARCH: x64
                  VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }}
                  VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }}
                  VSCODE_RUN_ELECTRON_TESTS: ${{ eq(parameters.VSCODE_STEP_ON_IT, false) }}
                  VSCODE_RUN_BROWSER_TESTS: ${{ eq(parameters.VSCODE_STEP_ON_IT, false) }}
                  VSCODE_RUN_REMOTE_TESTS: ${{ eq(parameters.VSCODE_STEP_ON_IT, false) }}

            - ${{ if and(eq(variables['VSCODE_CIBUILD'], false), eq(parameters.VSCODE_BUILD_WIN32_ARM64, true)) }}:
              - template: build/azure-pipelines/win32/product-build-win32.yml@self
                parameters:
                  VSCODE_ARCH: arm64
                  VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }}
                  VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }}

      - ${{ if eq(variables['VSCODE_BUILD_STAGE_LINUX'], true) }}:
        - stage: Linux
          dependsOn: []
          pool:
            name: 1es-ubuntu-22.04-x64
            os: linux
          jobs:
            - ${{ if eq(parameters.VSCODE_BUILD_LINUX, true) }}:
              - template: build/azure-pipelines/linux/product-build-linux-cli.yml@self
                parameters:
                  VSCODE_ARCH: x64
                  VSCODE_CHECK_ONLY: ${{ variables.VSCODE_CIBUILD }}
                  VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }}

            - ${{ if and(eq(variables['VSCODE_CIBUILD'], false), eq(parameters.VSCODE_BUILD_LINUX_ARM64, true)) }}:
              - template: build/azure-pipelines/linux/product-build-linux-cli.yml@self
                parameters:
                  VSCODE_ARCH: arm64
                  VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }}

            - ${{ if and(eq(variables['VSCODE_CIBUILD'], false), eq(parameters.VSCODE_BUILD_LINUX_ARMHF, true)) }}:
              - template: build/azure-pipelines/linux/product-build-linux-cli.yml@self
                parameters:
                  VSCODE_ARCH: armhf
                  VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }}

            - ${{ if eq(variables['VSCODE_CIBUILD'], true) }}:
              - template: build/azure-pipelines/linux/product-build-linux-ci.yml@self
                parameters:
                  VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }}
                  VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }}
                  VSCODE_TEST_SUITE: Electron
              - template: build/azure-pipelines/linux/product-build-linux-ci.yml@self
                parameters:
                  VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }}
                  VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }}
                  VSCODE_TEST_SUITE: Browser
              - template: build/azure-pipelines/linux/product-build-linux-ci.yml@self
                parameters:
                  VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }}
                  VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }}
                  VSCODE_TEST_SUITE: Remote

            - ${{ if and(eq(variables['VSCODE_CIBUILD'], false), or(eq(parameters.VSCODE_BUILD_LINUX, true), eq(parameters.VSCODE_BUILD_LINUX_SNAP, true))) }}:
              - template: build/azure-pipelines/linux/product-build-linux.yml@self
                parameters:
                  NPM_ARCH: x64
                  VSCODE_ARCH: x64
                  VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }}
                  VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }}
                  VSCODE_RUN_ELECTRON_TESTS: ${{ eq(parameters.VSCODE_STEP_ON_IT, false) }}
                  VSCODE_RUN_BROWSER_TESTS: ${{ eq(parameters.VSCODE_STEP_ON_IT, false) }}
                  VSCODE_RUN_REMOTE_TESTS: ${{ eq(parameters.VSCODE_STEP_ON_IT, false) }}
                  VSCODE_BUILD_LINUX_SNAP: ${{ parameters.VSCODE_BUILD_LINUX_SNAP }}

            - ${{ if and(eq(variables['VSCODE_CIBUILD'], false), eq(parameters.VSCODE_BUILD_LINUX_ARMHF, true)) }}:
              - template: build/azure-pipelines/linux/product-build-linux.yml@self
                parameters:
                  NPM_ARCH: arm
                  VSCODE_ARCH: armhf
                  VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }}
                  VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }}

            - ${{ if and(eq(variables['VSCODE_CIBUILD'], false), eq(parameters.VSCODE_BUILD_LINUX_ARM64, true)) }}:
              - template: build/azure-pipelines/linux/product-build-linux.yml@self
                parameters:
                  NPM_ARCH: arm64
                  VSCODE_ARCH: arm64
                  VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }}
                  VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }}

      - ${{ if and(eq(variables['VSCODE_CIBUILD'], false), eq(variables['VSCODE_BUILD_STAGE_ALPINE'], true)) }}:
        - stage: Alpine
          dependsOn: []
          jobs:
            - ${{ if eq(parameters.VSCODE_BUILD_ALPINE, true) }}:
              - template: build/azure-pipelines/alpine/product-build-alpine.yml@self
                parameters:
                  VSCODE_ARCH: x64
              - template: build/azure-pipelines/alpine/product-build-alpine-cli.yml@self
                parameters:
                  VSCODE_ARCH: x64
                  VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }}
            - ${{ if eq(parameters.VSCODE_BUILD_ALPINE_ARM64, true) }}:
              - template: build/azure-pipelines/alpine/product-build-alpine.yml@self
                parameters:
                  VSCODE_ARCH: arm64
              - template: build/azure-pipelines/alpine/product-build-alpine-cli.yml@self
                parameters:
                  VSCODE_ARCH: arm64
                  VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }}

      - ${{ if eq(variables['VSCODE_BUILD_STAGE_MACOS'], true) }}:
        - stage: macOS
          dependsOn: []
          pool:
            name: AcesShared
            os: macOS
            demands:
              - ImageOverride -equals ACES_VM_SharedPool_Sequoia
          variables:
            BUILDSECMON_OPT_IN: true
          jobs:
            - ${{ if eq(parameters.VSCODE_BUILD_MACOS, true) }}:
              - template: build/azure-pipelines/darwin/product-build-darwin-cli.yml@self
                parameters:
                  VSCODE_ARCH: x64
                  VSCODE_CHECK_ONLY: ${{ variables.VSCODE_CIBUILD }}
                  VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }}

            - ${{ if and(eq(variables['VSCODE_CIBUILD'], false), eq(parameters.VSCODE_BUILD_MACOS_ARM64, true)) }}:
              - template: build/azure-pipelines/darwin/product-build-darwin-cli.yml@self
                parameters:
                  VSCODE_ARCH: arm64
                  VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }}

            - ${{ if eq(variables['VSCODE_CIBUILD'], true) }}:
              - template: build/azure-pipelines/darwin/product-build-darwin-ci.yml@self
                parameters:
                  VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }}
                  VSCODE_TEST_SUITE: Electron
              - template: build/azure-pipelines/darwin/product-build-darwin-ci.yml@self
                parameters:
                  VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }}
                  VSCODE_TEST_SUITE: Browser
              - template: build/azure-pipelines/darwin/product-build-darwin-ci.yml@self
                parameters:
                  VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }}
                  VSCODE_TEST_SUITE: Remote

            - ${{ if and(eq(variables['VSCODE_CIBUILD'], false), eq(parameters.VSCODE_BUILD_MACOS, true)) }}:
              - template: build/azure-pipelines/darwin/product-build-darwin.yml@self
                parameters:
                  VSCODE_ARCH: x64
                  VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }}

            - ${{ if and(eq(variables['VSCODE_CIBUILD'], false), eq(parameters.VSCODE_BUILD_MACOS_ARM64, true)) }}:
              - template: build/azure-pipelines/darwin/product-build-darwin.yml@self
                parameters:
                  VSCODE_ARCH: arm64
                  VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }}
                  VSCODE_RUN_ELECTRON_TESTS: ${{ eq(parameters.VSCODE_STEP_ON_IT, false) }}
                  VSCODE_RUN_BROWSER_TESTS: ${{ eq(parameters.VSCODE_STEP_ON_IT, false) }}
                  VSCODE_RUN_REMOTE_TESTS: ${{ eq(parameters.VSCODE_STEP_ON_IT, false) }}

            - ${{ if and(eq(variables['VSCODE_CIBUILD'], false), eq(variables['VSCODE_BUILD_MACOS_UNIVERSAL'], true)) }}:
              - template: build/azure-pipelines/darwin/product-build-darwin-universal.yml@self

      - ${{ if and(eq(variables['VSCODE_CIBUILD'], false), eq(variables['VSCODE_BUILD_STAGE_WEB'], true)) }}:
        - stage: Web
          dependsOn: []
          jobs:
            - template: build/azure-pipelines/web/product-build-web.yml@self

      - ${{ if eq(variables['VSCODE_PUBLISH'], true) }}:
        - stage: Publish
          dependsOn: []
          jobs:
            - template: build/azure-pipelines/product-publish.yml@self
              parameters:
                VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }}
                VSCODE_SCHEDULEDBUILD: ${{ variables.VSCODE_SCHEDULEDBUILD }}

      - ${{ if and(eq(variables['VSCODE_PUBLISH'], 'true'), eq(variables['VSCODE_STEP_ON_IT'], false)) }}:
        - stage: SanityTests
          displayName: Sanity Tests
          dependsOn:
            - Publish
          variables:
            - name: BUILD_COMMIT
              value: $(Build.SourceVersion)
            - name: BUILD_QUALITY
              value: ${{ variables.VSCODE_QUALITY }}
          jobs:
            # macOS
            - ${{ if eq(parameters.VSCODE_BUILD_MACOS, true) }}:
              - template: build/azure-pipelines/common/sanity-tests.yml@self
                parameters:
                  name: macos_x64
                  displayName: macOS x64 (no runtime)
                  poolName: AcesShared
                  os: macOS
                  args: --no-detection --grep "darwin-x64"

            - ${{ if eq(parameters.VSCODE_BUILD_MACOS_ARM64, true) }}:
              - template: build/azure-pipelines/common/sanity-tests.yml@self
                parameters:
                  name: macos_arm64
                  displayName: macOS arm64
                  poolName: AcesShared
                  os: macOS

            # Windows
            - ${{ if eq(parameters.VSCODE_BUILD_WIN32, true) }}:
              - template: build/azure-pipelines/common/sanity-tests.yml@self
                parameters:
                  name: windows_x64
                  displayName: Windows x64
                  poolName: 1es-windows-2022-x64
                  os: windows

            - ${{ if eq(parameters.VSCODE_BUILD_WIN32_ARM64, true) }}:
              - template: build/azure-pipelines/common/sanity-tests.yml@self
                parameters:
                  name: windows_arm64
                  displayName: Windows arm64
                  poolName: 1es-windows-2022-arm64
                  os: windows

            # Alpine 3.22
            - ${{ if eq(parameters.VSCODE_BUILD_ALPINE, true) }}:
              - template: build/azure-pipelines/common/sanity-tests.yml@self
                parameters:
                  name: alpine_amd64
                  displayName: Alpine 3.22 amd64
                  poolName: 1es-ubuntu-22.04-x64
                  container: alpine
                  arch: amd64

            - ${{ if eq(parameters.VSCODE_BUILD_ALPINE_ARM64, true) }}:
              - template: build/azure-pipelines/common/sanity-tests.yml@self
                parameters:
                  name: alpine_arm64
                  displayName: Alpine 3.22 arm64
                  poolName: 1es-azure-linux-3-arm64
                  container: alpine
                  arch: arm64

            # CentOS Stream 9
            - ${{ if eq(parameters.VSCODE_BUILD_LINUX, true) }}:
              - template: build/azure-pipelines/common/sanity-tests.yml@self
                parameters:
                  name: centos_stream9_amd64
                  displayName: CentOS Stream 9 amd64
                  poolName: 1es-ubuntu-22.04-x64
                  container: centos
                  arch: amd64

            - ${{ if eq(parameters.VSCODE_BUILD_LINUX_ARM64, true) }}:
              - template: build/azure-pipelines/common/sanity-tests.yml@self
                parameters:
                  name: centos_stream9_arm64
                  displayName: CentOS Stream 9 arm64
                  poolName: 1es-azure-linux-3-arm64
                  container: centos
                  arch: arm64

            # Debian 10
            - ${{ if eq(parameters.VSCODE_BUILD_LINUX, true) }}:
              - template: build/azure-pipelines/common/sanity-tests.yml@self
                parameters:
                  name: debian_10_amd64
                  displayName: Debian 10 amd64
                  poolName: 1es-ubuntu-22.04-x64
                  container: debian-10
                  arch: amd64

            - ${{ if eq(parameters.VSCODE_BUILD_LINUX_ARMHF, true) }}:
              - template: build/azure-pipelines/common/sanity-tests.yml@self
                parameters:
                  name: debian_10_arm32
                  displayName: Debian 10 arm32
                  poolName: 1es-azure-linux-3-arm64
                  container: debian-10
                  arch: arm

            - ${{ if eq(parameters.VSCODE_BUILD_LINUX_ARM64, true) }}:
              - template: build/azure-pipelines/common/sanity-tests.yml@self
                parameters:
                  name: debian_10_arm64
                  displayName: Debian 10 arm64
                  poolName: 1es-azure-linux-3-arm64
                  container: debian-10
                  arch: arm64

            # Debian 12
            - ${{ if eq(parameters.VSCODE_BUILD_LINUX, true) }}:
              - template: build/azure-pipelines/common/sanity-tests.yml@self
                parameters:
                  name: debian_12_amd64
                  displayName: Debian 12 amd64
                  poolName: 1es-ubuntu-22.04-x64
                  container: debian-12
                  arch: amd64

            - ${{ if eq(parameters.VSCODE_BUILD_LINUX_ARMHF, true) }}:
              - template: build/azure-pipelines/common/sanity-tests.yml@self
                parameters:
                  name: debian_12_arm32
                  displayName: Debian 12 arm32
                  poolName: 1es-azure-linux-3-arm64
                  container: debian-12
                  arch: arm

            - ${{ if eq(parameters.VSCODE_BUILD_LINUX_ARM64, true) }}:
              - template: build/azure-pipelines/common/sanity-tests.yml@self
                parameters:
                  name: debian_12_arm64
                  displayName: Debian 12 arm64
                  poolName: 1es-azure-linux-3-arm64
                  container: debian-12
                  arch: arm64

            # Fedora 36
            - ${{ if eq(parameters.VSCODE_BUILD_LINUX, true) }}:
              - template: build/azure-pipelines/common/sanity-tests.yml@self
                parameters:
                  name: fedora_36_amd64
                  displayName: Fedora 36 amd64
                  poolName: 1es-ubuntu-22.04-x64
                  container: fedora
                  baseImage: fedora:36
                  arch: amd64

            - ${{ if eq(parameters.VSCODE_BUILD_LINUX_ARM64, true) }}:
              - template: build/azure-pipelines/common/sanity-tests.yml@self
                parameters:
                  name: fedora_36_arm64
                  displayName: Fedora 36 arm64
                  poolName: 1es-azure-linux-3-arm64
                  container: fedora
                  baseImage: fedora:36
                  arch: arm64

            # Fedora 40
            - ${{ if eq(parameters.VSCODE_BUILD_LINUX, true) }}:
              - template: build/azure-pipelines/common/sanity-tests.yml@self
                parameters:
                  name: fedora_40_amd64
                  displayName: Fedora 40 amd64
                  poolName: 1es-ubuntu-22.04-x64
                  container: fedora
                  baseImage: fedora:40
                  arch: amd64

            - ${{ if eq(parameters.VSCODE_BUILD_LINUX_ARM64, true) }}:
              - template: build/azure-pipelines/common/sanity-tests.yml@self
                parameters:
                  name: fedora_40_arm64
                  displayName: Fedora 40 arm64
                  poolName: 1es-azure-linux-3-arm64
                  container: fedora
                  baseImage: fedora:40
                  arch: arm64

            # openSUSE Leap 16.0
            - ${{ if eq(parameters.VSCODE_BUILD_LINUX, true) }}:
              - template: build/azure-pipelines/common/sanity-tests.yml@self
                parameters:
                  name: opensuse_leap_amd64
                  displayName: openSUSE Leap 16.0 amd64
                  poolName: 1es-ubuntu-22.04-x64
                  container: opensuse
                  arch: amd64

            - ${{ if eq(parameters.VSCODE_BUILD_LINUX_ARM64, true) }}:
              - template: build/azure-pipelines/common/sanity-tests.yml@self
                parameters:
                  name: opensuse_leap_arm64
                  displayName: openSUSE Leap 16.0 arm64
                  poolName: 1es-azure-linux-3-arm64
                  container: opensuse
                  arch: arm64

            # Red Hat UBI 9
            - ${{ if eq(parameters.VSCODE_BUILD_LINUX, true) }}:
              - template: build/azure-pipelines/common/sanity-tests.yml@self
                parameters:
                  name: redhat_ubi9_amd64
                  displayName: Red Hat UBI 9 amd64
                  poolName: 1es-ubuntu-22.04-x64
                  container: redhat
                  arch: amd64

            - ${{ if eq(parameters.VSCODE_BUILD_LINUX_ARM64, true) }}:
              - template: build/azure-pipelines/common/sanity-tests.yml@self
                parameters:
                  name: redhat_ubi9_arm64
                  displayName: Red Hat UBI 9 arm64
                  poolName: 1es-azure-linux-3-arm64
                  container: redhat
                  arch: arm64

            # Ubuntu 22.04 Native (Snap coverage)
            - ${{ if eq(parameters.VSCODE_BUILD_LINUX, true) }}:
              - template: build/azure-pipelines/common/sanity-tests.yml@self
                parameters:
                  name: ubuntu_native_x64
                  displayName: Ubuntu 22.04 x64 Native
                  poolName: 1es-ubuntu-22.04-x64
                  os: linux

            # Ubuntu 22.04
            - ${{ if eq(parameters.VSCODE_BUILD_LINUX, true) }}:
              - template: build/azure-pipelines/common/sanity-tests.yml@self
                parameters:
                  name: ubuntu_22_04_amd64
                  displayName: Ubuntu 22.04 amd64
                  poolName: 1es-ubuntu-22.04-x64
                  container: ubuntu
                  baseImage: ubuntu:22.04
                  arch: amd64

            - ${{ if eq(parameters.VSCODE_BUILD_LINUX_ARMHF, true) }}:
              - template: build/azure-pipelines/common/sanity-tests.yml@self
                parameters:
                  name: ubuntu_22_04_arm32
                  displayName: Ubuntu 22.04 arm32
                  poolName: 1es-azure-linux-3-arm64
                  container: ubuntu
                  baseImage: ubuntu:22.04
                  arch: arm

            - ${{ if eq(parameters.VSCODE_BUILD_LINUX_ARM64, true) }}:
              - template: build/azure-pipelines/common/sanity-tests.yml@self
                parameters:
                  name: ubuntu_22_04_arm64
                  displayName: Ubuntu 22.04 arm64
                  poolName: 1es-azure-linux-3-arm64
                  container: ubuntu
                  baseImage: ubuntu:22.04
                  arch: arm64

            # Ubuntu 24.04
            - ${{ if eq(parameters.VSCODE_BUILD_LINUX, true) }}:
              - template: build/azure-pipelines/common/sanity-tests.yml@self
                parameters:
                  name: ubuntu_24_04_amd64
                  displayName: Ubuntu 24.04 amd64
                  poolName: 1es-ubuntu-22.04-x64
                  container: ubuntu
                  baseImage: ubuntu:24.04
                  arch: amd64

            - ${{ if eq(parameters.VSCODE_BUILD_LINUX_ARMHF, true) }}:
              - template: build/azure-pipelines/common/sanity-tests.yml@self
                parameters:
                  name: ubuntu_24_04_arm32
                  displayName: Ubuntu 24.04 arm32
                  poolName: 1es-azure-linux-3-arm64
                  container: ubuntu
                  baseImage: ubuntu:24.04
                  arch: arm

            - ${{ if eq(parameters.VSCODE_BUILD_LINUX_ARM64, true) }}:
              - template: build/azure-pipelines/common/sanity-tests.yml@self
                parameters:
                  name: ubuntu_24_04_arm64
                  displayName: Ubuntu 24.04 arm64
                  poolName: 1es-azure-linux-3-arm64
                  container: ubuntu
                  baseImage: ubuntu:24.04
                  arch: arm64

        - ${{ if and(parameters.VSCODE_RELEASE, eq(variables['VSCODE_PRIVATE_BUILD'], false)) }}:
          - stage: ApproveRelease
            dependsOn: [] # run in parallel to compile stage
            pool:
              name: 1es-ubuntu-22.04-x64
              os: linux
            jobs:
              - job: ApproveRelease
                displayName: "Approve Release"
                variables:
                  - group: VSCodePeerApproval
                  - name: skipComponentGovernanceDetection
                    value: true

          - stage: Release
            dependsOn:
              - Publish
              - ApproveRelease
            pool:
              name: 1es-ubuntu-22.04-x64
              os: linux
            jobs:
              - job: ReleaseBuild
                displayName: Release Build
                steps:
                  - template: build/azure-pipelines/product-release.yml@self
                    parameters:
                      VSCODE_RELEASE: ${{ parameters.VSCODE_RELEASE }}

      - ${{ if eq(variables['VSCODE_CIBUILD'], true) }}:
        - stage: node_modules
          dependsOn: []
          jobs:
            - template: build/azure-pipelines/win32/product-build-win32-node-modules.yml@self
              parameters:
                VSCODE_ARCH: arm64
            - template: build/azure-pipelines/linux/product-build-linux-node-modules.yml@self
              parameters:
                NPM_ARCH: arm64
                VSCODE_ARCH: arm64
            - template: build/azure-pipelines/linux/product-build-linux-node-modules.yml@self
              parameters:
                NPM_ARCH: arm
                VSCODE_ARCH: armhf
            - template: build/azure-pipelines/alpine/product-build-alpine-node-modules.yml@self
              parameters:
                VSCODE_ARCH: x64
            - template: build/azure-pipelines/alpine/product-build-alpine-node-modules.yml@self
              parameters:
                VSCODE_ARCH: arm64
            - template: build/azure-pipelines/darwin/product-build-darwin-node-modules.yml@self
              parameters:
                VSCODE_ARCH: x64
            - template: build/azure-pipelines/web/product-build-web-node-modules.yml@self

      - ${{ if eq(variables['VSCODE_CIBUILD'], false) }}:
        - stage: APIScan
          dependsOn: []
          pool:
            name: 1es-windows-2022-x64
            os: windows
          jobs:
            - job: WindowsAPIScan
              steps:
                - template: build/azure-pipelines/win32/sdl-scan-win32.yml@self
                  parameters:
                    VSCODE_ARCH: x64
                    VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }}
