mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 09:17:43 +03:00
65f9395cdd
This took me embarassingly long to understand and debug (partially because afaict Azure is broken): The issue is that in the current state, parameters.is_release is not expanded when setting the env var. That makes sense. The variable is only set at runtime but the ${{}} template expressions are expanded before that (it works below in the condition since that’s not in a ${{}} and is evaluated at runtime). Now if we look at the other env var that does work (the release tag) we can see something interesting. We set it to the macro $(release_tag) in build.yml. However, that is not expanded since template expansion happens way earlier. So the template parameter is set to the literal string "$(release_tag)". We then splice that in via template expansion ${{parameters.release_tag}} and then at runtime azure will expand the macro. Just changing is_release to a macro however would break the use in the condition (I think you might be able to fix that if you put it in a string but that just seems even more hacky). So this PR instead defines a new variable skip_tests which we define in the job and the splice it in via a macro. Confusingly, `$[variables.is_release]` is not expanded in an env definition. Afaict this is simply a bug. The only difference between macros and runtime expressions according to the docs is that runtime expressions need to replace the full RHs and that macros can only reference a single variable. Wouldn’t help much here either anyway if we want to stick to the parameter instead of referencing a variable directly (which maybe we don’t, it doesn’t seem to help much but that’s a separate question). changelog_begin changelog_end
69 lines
2.5 KiB
YAML
69 lines
2.5 KiB
YAML
# Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
parameters:
|
|
release_tag: ''
|
|
is_release: ''
|
|
skip_tests: ''
|
|
|
|
steps:
|
|
- bash: ci/configure-bazel.sh
|
|
displayName: 'Configure Bazel'
|
|
env:
|
|
IS_FORK: $(System.PullRequest.IsFork)
|
|
# to upload to the bazel cache
|
|
GOOGLE_APPLICATION_CREDENTIALS_CONTENT: $(GOOGLE_APPLICATION_CREDENTIALS_CONTENT)
|
|
|
|
- powershell: '.\ci\windows-diagnostics.ps1'
|
|
displayName: 'Agent diagnostics'
|
|
|
|
- powershell: '.\build.ps1'
|
|
displayName: 'Build'
|
|
env:
|
|
DAML_SDK_RELEASE_VERSION: ${{parameters.release_tag}}
|
|
# On release, we want to skip testing because:
|
|
# - Caching on Windows is keyed on full path, and full path is somewhat
|
|
# random (for a given machine, each pipeline has a its own workdir, but
|
|
# they are not the same across machines).
|
|
# - In the specific case of a release commit on `main`, the exact same
|
|
# code has already been tested twice: once as part of the target
|
|
# commit's own build (albeit with 0.0.0 as version number), and once as
|
|
# part of the release PR that triggered the build (with correct version
|
|
# number).
|
|
SKIP_TESTS: ${{parameters.skip_tests}}
|
|
|
|
- task: PublishBuildArtifacts@1
|
|
condition: failed()
|
|
displayName: 'Publish the bazel test logs'
|
|
inputs:
|
|
pathtoPublish: 'bazel-testlogs/'
|
|
artifactName: 'Test logs Windows'
|
|
|
|
- template: bash-lib.yml
|
|
parameters:
|
|
var_name: bash-lib
|
|
|
|
- bash: |
|
|
set -euo pipefail
|
|
mkdir -p '$(Build.StagingDirectory)'/release
|
|
./ci/copy-windows-release-artifacts.sh ${{parameters.release_tag}} '$(Build.StagingDirectory)'/release
|
|
name: publish
|
|
env:
|
|
AZURE_KEY_VAULT_URL: $(AZURE_KEY_VAULT_URL)
|
|
AZURE_CLIENT_ID: $(AZURE_CLIENT_ID)
|
|
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
|
|
AZURE_TENANT_ID: $(AZURE_TENANT_ID)
|
|
AZURE_KEY_VAULT_CERTIFICATE: $(AZURE_KEY_VAULT_CERTIFICATE)
|
|
DAML_SDK_RELEASE_VERSION: ${{parameters.release_tag}}
|
|
condition: and(succeeded(),
|
|
eq(${{parameters.is_release}}, 'true'),
|
|
eq(variables['Build.SourceBranchName'], 'main'))
|
|
|
|
- task: PublishPipelineArtifact@0
|
|
condition: and(succeeded(),
|
|
eq(${{parameters.is_release}}, 'true'),
|
|
eq(variables['Build.SourceBranchName'], 'main'))
|
|
inputs:
|
|
targetPath: $(Build.StagingDirectory)/release
|
|
artifactName: windows-release
|