product-build-darwin.yml 14.0 KB
Newer Older
J
Joao Moreno 已提交
1
steps:
J
João Moreno 已提交
2 3
  - task: NodeTool@0
    inputs:
R
Robo 已提交
4
      versionSpec: "12.18.3"
J
João Moreno 已提交
5 6 7 8 9 10 11

  - task: AzureKeyVault@1
    displayName: "Azure Key Vault: Get Secrets"
    inputs:
      azureSubscription: "vscode-builds-subscription"
      KeyVaultName: vscode

12 13
  - task: DownloadPipelineArtifact@2
    inputs:
14 15
      artifact: Compilation
      path: $(Build.ArtifactStagingDirectory)
16 17
    displayName: Download compilation output

18 19 20 21 22
  - script: |
      set -e
      tar -xzf $(Build.ArtifactStagingDirectory)/compilation.tar.gz
    displayName: Extract compilation output

J
João Moreno 已提交
23 24 25 26 27 28 29 30 31 32 33 34
  - script: |
      set -e
      cat << EOF > ~/.netrc
      machine github.com
      login vscode
      password $(github-distro-mixin-password)
      EOF

      git config user.email "vscode@microsoft.com"
      git config user.name "VSCode"
    displayName: Prepare tooling

J
João Moreno 已提交
35 36 37 38 39 40
  - script: |
      set -e
      sudo xcode-select -s /Applications/Xcode_12.2.app
    displayName: Switch to Xcode 12
    condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'arm64'))

J
João Moreno 已提交
41 42
  - script: |
      set -e
J
João Moreno 已提交
43
      git pull --no-rebase https://github.com/$(VSCODE_MIXIN_REPO).git $(node -p "require('./package.json').distro")
J
João Moreno 已提交
44 45
    displayName: Merge distro

J
João Moreno 已提交
46
  - script: |
47 48
      mkdir -p .build
      node build/azure-pipelines/common/computeNodeModulesCacheKey.js $VSCODE_ARCH $ENABLE_TERRAPIN > .build/yarnlockhash
J
João Moreno 已提交
49 50
    displayName: Prepare yarn cache flags

51
  - task: Cache@2
J
João Moreno 已提交
52
    inputs:
53 54 55
      key: 'nodeModules | $(Agent.OS) | .build/yarnlockhash'
      path: .build/node_modules_cache
      cacheHitVar: NODE_MODULES_RESTORED
J
rename  
João Moreno 已提交
56
    displayName: Restore node_modules cache
57 58 59 60 61

  - script: |
      set -e
      tar -xzf .build/node_modules_cache/cache.tgz
    condition: and(succeeded(), eq(variables.NODE_MODULES_RESTORED, 'true'))
J
rename  
João Moreno 已提交
62
    displayName: Extract node_modules cache
J
João Moreno 已提交
63 64 65

  - script: |
      set -e
R
Robo 已提交
66
      npm install -g node-gyp@latest
J
João Moreno 已提交
67 68
      node-gyp --version
    displayName: Update node-gyp
J
João Moreno 已提交
69 70 71 72 73 74 75
    condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))

  - script: |
      npx https://aka.ms/enablesecurefeed standAlone
    timeoutInMinutes: 5
    condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), eq(variables['ENABLE_TERRAPIN'], 'true'))
    displayName: Switch to Terrapin packages
J
João Moreno 已提交
76 77 78 79 80 81

  - script: |
      set -e
      export npm_config_arch=$(VSCODE_ARCH)
      export npm_config_node_gyp=$(which node-gyp)
      export SDKROOT=/Applications/Xcode_12.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk
J
João Moreno 已提交
82 83 84

      for i in {1..3}; do # try 3 times, for Terrapin
        yarn --frozen-lockfile && break
J
João Moreno 已提交
85 86 87 88 89
        if [ $i -eq 3 ]; then
          echo "Yarn failed too many times" >&2
          exit 1
        fi
        echo "Yarn failed $i, trying again..."
J
João Moreno 已提交
90
      done
91 92
    env:
      ELECTRON_SKIP_BINARY_DOWNLOAD: 1
93
      PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
J
João Moreno 已提交
94
    displayName: Install dependencies
95
    condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))
J
João Moreno 已提交
96

97 98 99 100 101 102 103
  - script: |
      set -e
      node build/azure-pipelines/common/listNodeModules.js .build/node_modules_list.txt
      mkdir -p .build/node_modules_cache
      tar -czf .build/node_modules_cache/cache.tgz --files-from .build/node_modules_list.txt
    condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))
    displayName: Create node_modules archive
J
João Moreno 已提交
104 105 106

  - script: |
      set -e
D
deepak1556 已提交
107 108 109
      export npm_config_arch=$(VSCODE_ARCH)
      export npm_config_node_gyp=$(which node-gyp)
      export npm_config_build_from_source=true
J
João Moreno 已提交
110 111 112
      export SDKROOT=/Applications/Xcode_12.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk
      ls /Applications/Xcode_12.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
      yarn electron-rebuild
D
deepak1556 已提交
113 114
      cd ./node_modules/keytar
      node-gyp rebuild
J
João Moreno 已提交
115
    displayName: Rebuild native modules for ARM64
J
João Moreno 已提交
116
    condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'arm64'))
J
João Moreno 已提交
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134

  - script: |
      set -e
      node build/azure-pipelines/mixin
    displayName: Mix in quality

  - script: |
      set -e
      VSCODE_MIXIN_PASSWORD="$(github-distro-mixin-password)" \
        yarn gulp vscode-darwin-$(VSCODE_ARCH)-min-ci
    displayName: Build

  - script: |
      set -e
      VSCODE_MIXIN_PASSWORD="$(github-distro-mixin-password)" \
        yarn gulp vscode-reh-darwin-min-ci
      VSCODE_MIXIN_PASSWORD="$(github-distro-mixin-password)" \
        yarn gulp vscode-reh-web-darwin-min-ci
J
João Moreno 已提交
135
    displayName: Build Server
J
João Moreno 已提交
136 137 138 139
    condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'))

  - script: |
      set -e
140 141
      yarn npm-run-all -lp "electron $(VSCODE_ARCH)" "playwright-install"
    displayName: Download Electron and Playwright
J
João Moreno 已提交
142 143 144 145 146 147 148 149 150 151 152 153
    condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false'))

  - script: |
      set -e
      security create-keychain -p pwd $(agent.tempdirectory)/buildagent.keychain
      security default-keychain -s $(agent.tempdirectory)/buildagent.keychain
      security unlock-keychain -p pwd $(agent.tempdirectory)/buildagent.keychain
      echo "$(macos-developer-certificate)" | base64 -D > $(agent.tempdirectory)/cert.p12
      security import $(agent.tempdirectory)/cert.p12 -k $(agent.tempdirectory)/buildagent.keychain -P "$(macos-developer-certificate-key)" -T /usr/bin/codesign
      security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k pwd $(agent.tempdirectory)/buildagent.keychain
      VSCODE_ARCH="$(VSCODE_ARCH)" DEBUG=electron-osx-sign* node build/darwin/sign.js
    displayName: Set Hardened Entitlements
J
João Moreno 已提交
154
    condition: and(succeeded(), ne(variables['VSCODE_PUBLISH'], 'false'))
J
João Moreno 已提交
155 156 157 158 159

  - script: |
      set -e
      ./scripts/test.sh --build --tfs "Unit Tests"
    displayName: Run unit tests (Electron)
J
João Moreno 已提交
160
    timeoutInMinutes: 5
J
João Moreno 已提交
161 162 163 164 165 166
    condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'), eq(variables['VSCODE_STEP_ON_IT'], 'false'))

  - script: |
      set -e
      yarn test-browser --build --browser chromium --browser webkit --browser firefox --tfs "Browser Unit Tests"
    displayName: Run unit tests (Browser)
167
    timeoutInMinutes: 5
J
João Moreno 已提交
168 169
    condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'), eq(variables['VSCODE_STEP_ON_IT'], 'false'))

J
João Moreno 已提交
170 171 172 173
  - script: |
      set -e
      yarn --cwd test/integration/browser compile
    displayName: Compile integration tests
174
    condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'), eq(variables['VSCODE_STEP_ON_IT'], 'false'))
J
João Moreno 已提交
175

J
João Moreno 已提交
176 177 178 179 180 181 182 183 184 185 186
  - script: |
      # Figure out the full absolute path of the product we just built
      # including the remote server and configure the integration tests
      # to run with these builds instead of running out of sources.
      set -e
      APP_ROOT=$(agent.builddirectory)/VSCode-darwin-$(VSCODE_ARCH)
      APP_NAME="`ls $APP_ROOT | head -n 1`"
      INTEGRATION_TEST_ELECTRON_PATH="$APP_ROOT/$APP_NAME/Contents/MacOS/Electron" \
      VSCODE_REMOTE_SERVER_PATH="$(agent.builddirectory)/vscode-reh-darwin" \
      ./scripts/test-integration.sh --build --tfs "Integration Tests"
    displayName: Run integration tests (Electron)
J
João Moreno 已提交
187
    timeoutInMinutes: 5
J
João Moreno 已提交
188
    condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'), eq(variables['VSCODE_STEP_ON_IT'], 'false'))
J
João Moreno 已提交
189 190 191 192 193 194

  - script: |
      set -e
      VSCODE_REMOTE_SERVER_PATH="$(agent.builddirectory)/vscode-reh-web-darwin" \
      ./resources/server/test/test-web-integration.sh --browser webkit
    displayName: Run integration tests (Browser)
J
João Moreno 已提交
195
    timeoutInMinutes: 5
J
João Moreno 已提交
196 197 198 199 200 201 202 203 204 205
    condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'), eq(variables['VSCODE_STEP_ON_IT'], 'false'))

  - script: |
      set -e
      APP_ROOT=$(agent.builddirectory)/VSCode-darwin-$(VSCODE_ARCH)
      APP_NAME="`ls $APP_ROOT | head -n 1`"
      INTEGRATION_TEST_ELECTRON_PATH="$APP_ROOT/$APP_NAME/Contents/MacOS/Electron" \
      VSCODE_REMOTE_SERVER_PATH="$(agent.builddirectory)/vscode-reh-darwin" \
      ./resources/server/test/test-remote-integration.sh
    displayName: Run remote integration tests (Electron)
J
João Moreno 已提交
206
    timeoutInMinutes: 5
J
João Moreno 已提交
207
    condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'), eq(variables['VSCODE_STEP_ON_IT'], 'false'))
J
João Moreno 已提交
208 209 210 211 212

  - script: |
      set -e
      yarn --cwd test/smoke compile
    displayName: Compile smoke tests
213
    condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'), eq(variables['VSCODE_STEP_ON_IT'], 'false'))
J
João Moreno 已提交
214 215 216 217 218

  - script: |
      set -e
      APP_ROOT=$(agent.builddirectory)/VSCode-darwin-$(VSCODE_ARCH)
      APP_NAME="`ls $APP_ROOT | head -n 1`"
A
Alexandru Dima 已提交
219
      yarn smoketest-no-compile --build "$APP_ROOT/$APP_NAME"
J
João Moreno 已提交
220
    timeoutInMinutes: 5
J
João Moreno 已提交
221 222 223 224 225 226
    displayName: Run smoke tests (Electron)
    condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'), eq(variables['VSCODE_STEP_ON_IT'], 'false'))

  - script: |
      set -e
      VSCODE_REMOTE_SERVER_PATH="$(agent.builddirectory)/vscode-reh-web-darwin" \
A
Alexandru Dima 已提交
227
      yarn smoketest-no-compile --web --headless
J
João Moreno 已提交
228
    timeoutInMinutes: 5
J
João Moreno 已提交
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
    displayName: Run smoke tests (Browser)
    condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'), eq(variables['VSCODE_STEP_ON_IT'], 'false'))

  - task: PublishPipelineArtifact@0
    inputs:
      artifactName: crash-dump-macos-$(VSCODE_ARCH)
      targetPath: .build/crashes
    displayName: "Publish Crash Reports"
    continueOnError: true
    condition: failed()

  - task: PublishTestResults@2
    displayName: Publish Tests Results
    inputs:
      testResultsFiles: "*-results.xml"
      searchFolder: "$(Build.ArtifactStagingDirectory)/test-results"
245
    condition: and(succeededOrFailed(), eq(variables['VSCODE_ARCH'], 'x64'), eq(variables['VSCODE_STEP_ON_IT'], 'false'))
J
João Moreno 已提交
246 247 248 249 250

  - script: |
      set -e
      pushd $(agent.builddirectory)/VSCode-darwin-$(VSCODE_ARCH) && zip -r -X -y $(agent.builddirectory)/VSCode-darwin-$(VSCODE_ARCH).zip * && popd
    displayName: Archive build
J
João Moreno 已提交
251
    condition: and(succeeded(), ne(variables['VSCODE_PUBLISH'], 'false'))
J
João Moreno 已提交
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275

  - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
    inputs:
      ConnectedServiceName: "ESRP CodeSign"
      FolderPath: "$(agent.builddirectory)"
      Pattern: "VSCode-darwin-$(VSCODE_ARCH).zip"
      signConfigType: inlineSignParams
      inlineOperation: |
        [
          {
            "keyCode": "CP-401337-Apple",
            "operationSetCode": "MacAppDeveloperSign",
            "parameters": [
              {
                "parameterName": "Hardening",
                "parameterValue": "--options=runtime"
              }
            ],
            "toolName": "sign",
            "toolVersion": "1.0"
          }
        ]
      SessionTimeout: 60
    displayName: Codesign
J
João Moreno 已提交
276
    condition: and(succeeded(), ne(variables['VSCODE_PUBLISH'], 'false'))
J
João Moreno 已提交
277 278 279

  - script: |
      zip -d $(agent.builddirectory)/VSCode-darwin-$(VSCODE_ARCH).zip "*.pkg"
J
João Moreno 已提交
280 281
    displayName: Clean
    condition: and(succeeded(), ne(variables['VSCODE_PUBLISH'], 'false'))
J
João Moreno 已提交
282 283 284 285 286 287 288

  - script: |
      APP_ROOT=$(agent.builddirectory)/VSCode-darwin-$(VSCODE_ARCH)
      APP_NAME="`ls $APP_ROOT | head -n 1`"
      BUNDLE_IDENTIFIER=$(node -p "require(\"$APP_ROOT/$APP_NAME/Contents/Resources/app/product.json\").darwinBundleIdentifier")
      echo "##vso[task.setvariable variable=BundleIdentifier]$BUNDLE_IDENTIFIER"
    displayName: Export bundle identifier
J
João Moreno 已提交
289
    condition: and(succeeded(), ne(variables['VSCODE_PUBLISH'], 'false'))
J
João Moreno 已提交
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313

  - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
    inputs:
      ConnectedServiceName: "ESRP CodeSign"
      FolderPath: "$(agent.builddirectory)"
      Pattern: "VSCode-darwin-$(VSCODE_ARCH).zip"
      signConfigType: inlineSignParams
      inlineOperation: |
        [
          {
            "keyCode": "CP-401337-Apple",
            "operationSetCode": "MacAppNotarize",
            "parameters": [
              {
                "parameterName": "BundleId",
                "parameterValue": "$(BundleIdentifier)"
              }
            ],
            "toolName": "sign",
            "toolVersion": "1.0"
          }
        ]
      SessionTimeout: 60
    displayName: Notarization
J
João Moreno 已提交
314
    condition: and(succeeded(), ne(variables['VSCODE_PUBLISH'], 'false'))
J
João Moreno 已提交
315 316 317 318 319 320 321

  - script: |
      set -e
      APP_ROOT=$(agent.builddirectory)/VSCode-darwin-$(VSCODE_ARCH)
      APP_NAME="`ls $APP_ROOT | head -n 1`"
      "$APP_ROOT/$APP_NAME/Contents/Resources/app/bin/code" --export-default-configuration=.build
    displayName: Verify start after signing (export configuration)
J
João Moreno 已提交
322
    condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'), ne(variables['VSCODE_PUBLISH'], 'false'))
J
João Moreno 已提交
323 324 325 326 327 328 329 330 331 332

  - script: |
      set -e
      VSCODE_MIXIN_PASSWORD="$(github-distro-mixin-password)" \
      AZURE_DOCUMENTDB_MASTERKEY="$(builds-docdb-key-readwrite)" \
      AZURE_STORAGE_ACCESS_KEY="$(ticino-storage-key)" \
      AZURE_STORAGE_ACCESS_KEY_2="$(vscode-storage-key)" \
      VSCODE_ARCH="$(VSCODE_ARCH)" \
      ./build/azure-pipelines/darwin/publish.sh
    displayName: Publish
J
João Moreno 已提交
333
    condition: and(succeeded(), ne(variables['VSCODE_PUBLISH'], 'false'))
J
João Moreno 已提交
334

335 336 337 338 339 340 341 342 343 344 345 346 347 348 349
  - publish: $(Agent.BuildDirectory)/VSCode-darwin-$(VSCODE_ARCH).zip
    artifact: vscode-darwin-$(VSCODE_ARCH)
    displayName: Publish archive
    condition: and(succeeded(), ne(variables['VSCODE_PUBLISH'], 'false'))

  - publish: $(Agent.BuildDirectory)/vscode-server-darwin.zip
    artifact: vscode-server-darwin-$(VSCODE_ARCH)
    displayName: Publish server archive
    condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'), ne(variables['VSCODE_PUBLISH'], 'false'))

  - publish: $(Agent.BuildDirectory)/vscode-server-darwin-web.zip
    artifact: vscode-server-darwin-$(VSCODE_ARCH)-web
    displayName: Publish web server archive
    condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'), ne(variables['VSCODE_PUBLISH'], 'false'))

J
João Moreno 已提交
350 351
  - script: |
      AZURE_STORAGE_ACCESS_KEY="$(ticino-storage-key)" \
352
      VSCODE_ARCH="$(VSCODE_ARCH)" \
J
João Moreno 已提交
353 354
      yarn gulp upload-vscode-configuration
    displayName: Upload configuration (for Bing settings search)
J
João Moreno 已提交
355
    condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'), ne(variables['VSCODE_PUBLISH'], 'false'))
J
João Moreno 已提交
356 357 358 359 360
    continueOnError: true

  - task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
    displayName: "Component Detection"
    continueOnError: true