2020-02-06 14:54:07 +03:00
# Copyright (c) 2020 The DAML Authors. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
2019-04-04 11:33:38 +03:00
# Azure Pipelines file, see https://aka.ms/yaml
# Enable builds on all branches
trigger :
# Build every commit as our release process relies on
# the release process being built alone.
batch : false
branches :
include :
- master
# Enable PR triggers that target the master branch
pr :
autoCancel : true # cancel previous builds on push
branches :
include :
- master
jobs :
2020-02-03 18:29:13 +03:00
- job : git_sha
pool :
name : 'linux-pool'
steps :
- bash : |
set -euo pipefail
2020-02-03 21:25:37 +03:00
if [ "$(Build.Reason)" == "PullRequest" ]; then
echo "##vso[task.setvariable variable=branch;isOutput=true]$(git rev-parse 'HEAD^2')"
echo "##vso[task.setvariable variable=master;isOutput=true]$(git rev-parse 'HEAD^1')"
echo "##vso[task.setvariable variable=fork_point;isOutput=true]$(git merge-base --fork-point 'HEAD^1' 'HEAD^2')"
else
echo "##vso[task.setvariable variable=branch;isOutput=true]$(git rev-parse HEAD)"
echo "##vso[task.setvariable variable=master;isOutput=true]$(git rev-parse HEAD)"
echo "##vso[task.setvariable variable=fork_point;isOutput=true]$(git rev-parse HEAD)"
fi
2020-02-03 18:29:13 +03:00
name : out
2019-11-15 19:46:42 +03:00
- job : check_standard_change_label
2020-01-07 19:19:50 +03:00
condition : eq(variables['Build.Reason'], 'PullRequest')
2019-11-15 19:46:42 +03:00
pool :
name : 'linux-pool'
steps :
- checkout : self
- bash : |
set -euo pipefail
has_changed_infra_folder () {
git diff origin/master --name-only | grep -q '^infra/'
}
fail_if_missing_std_change_label () {
curl https://api.github.com/repos/digital-asset/daml/pulls/$PR -s | jq -r '.labels[].name' | grep -q '^Standard-Change$'
}
if has_changed_infra_folder; then
fail_if_missing_std_change_label
fi
env :
PR : $(System.PullRequest.PullRequestNumber)
2020-01-07 19:19:50 +03:00
- job : check_changelog_entry
condition : eq(variables['Build.Reason'], 'PullRequest')
pool :
name : 'linux-pool'
steps :
- checkout : self
- bash : ci/check-changelog.sh
2019-05-06 03:21:06 +03:00
- job : Linux
2019-04-04 11:33:38 +03:00
timeoutInMinutes : 360
pool :
2019-04-16 12:35:46 +03:00
name : 'linux-pool'
2019-04-04 11:33:38 +03:00
steps :
2019-07-05 14:35:30 +03:00
- template : ci/report-start.yml
2019-07-31 12:23:43 +03:00
- checkout : self
2019-04-04 11:33:38 +03:00
- template : ci/build-unix.yml
2019-04-12 13:30:13 +03:00
parameters :
name : linux
2019-07-04 17:22:22 +03:00
- template : ci/tell-slack-failed.yml
2019-07-05 14:35:30 +03:00
- template : ci/report-end.yml
2019-04-04 11:33:38 +03:00
2019-05-06 03:21:06 +03:00
- job : macOS
2019-04-04 11:33:38 +03:00
timeoutInMinutes : 360
pool :
2019-04-18 18:22:10 +03:00
vmImage : 'macOS-10.14'
2019-07-31 12:23:43 +03:00
variables :
2019-08-07 13:04:49 +03:00
nix-cache-key : $(Build.StagingDirectory)/macos-nix-key
nix-cache-path : /tmp/nix-cache/
bazel-repo-cache-key : $(Build.StagingDirectory)/bazel-repo-cache-key
bazel-repo-cache-path : $(Agent.BuildDirectory)/.bazel-cache/repo
2019-04-04 11:33:38 +03:00
steps :
2019-07-05 14:35:30 +03:00
- template : ci/report-start.yml
2019-07-31 12:23:43 +03:00
- checkout : self
2019-08-07 13:04:49 +03:00
- bash : echo $(git log -n1 --pretty=format:%H dev-env nix azure-pipelines.yml) >> $(nix-cache-key)
displayName : nix cache key
2019-07-31 12:23:43 +03:00
- task : CacheBeta@0
inputs :
2019-11-04 15:30:57 +03:00
key : $(nix-cache-key) | v2
2019-08-07 13:04:49 +03:00
path : $(nix-cache-path)
2019-07-31 12:23:43 +03:00
- bash : |
set -euo pipefail
2019-08-07 13:04:49 +03:00
if [[ -e $(nix-cache-path) ]]; then
2019-07-31 12:23:43 +03:00
DIR=$(pwd)
sudo mkdir /nix && sudo chown $USER /nix
cd /nix
2019-08-07 13:04:49 +03:00
tar xzf $(nix-cache-path)/nix.tar.gz
2019-07-31 12:23:43 +03:00
cd $DIR
2020-02-07 18:05:52 +03:00
curl -sfL https://nixos.org/releases/nix/nix-2.3.2/install | bash
2019-07-31 12:23:43 +03:00
fi
displayName : restore cache
2019-08-07 13:04:49 +03:00
- bash : echo $(git log -n1 --pretty=format:%H azure-pipelines.yml $(find . -name \*.bazel -or -name \*.bzl -or -name WORKSPACE -or -name BUILD)) >> $(bazel-repo-cache-key)
displayName : bazel repo cache key
- task : CacheBeta@0
inputs :
key : $(bazel-repo-cache-key)
path : $(bazel-repo-cache-path)
2019-04-04 11:33:38 +03:00
- template : ci/build-unix.yml
2019-04-12 13:30:13 +03:00
parameters :
name : macos
2019-07-31 12:23:43 +03:00
- bash : |
set -euo pipefail
2019-08-07 13:04:49 +03:00
if [[ ! -e $(nix-cache-path) ]]; then
mkdir -p $(nix-cache-path)
2019-07-31 12:23:43 +03:00
cd /nix
2019-08-07 13:04:49 +03:00
GZIP=-9 tar czf $(nix-cache-path)/nix.tar.gz store var
2019-07-31 12:23:43 +03:00
fi
2019-08-07 13:04:49 +03:00
displayName : create nix cache
- bash : mkdir -p $(bazel-repo-cache-path)
displayName : ensure bazel repo cache exists
2019-07-04 17:22:22 +03:00
- template : ci/tell-slack-failed.yml
2019-07-05 14:35:30 +03:00
- template : ci/report-end.yml
2019-04-04 11:33:38 +03:00
2019-05-06 03:21:06 +03:00
- job : Windows
2019-04-11 15:26:55 +03:00
timeoutInMinutes : 360
pool :
2019-05-13 12:20:21 +03:00
name : 'windows-pool'
2019-04-11 15:26:55 +03:00
steps :
2019-07-05 14:35:30 +03:00
- template : ci/report-start.yml
2019-04-11 15:26:55 +03:00
- template : ci/build-windows.yml
2019-07-04 17:22:22 +03:00
- template : ci/tell-slack-failed.yml
2019-07-05 14:35:30 +03:00
- template : ci/report-end.yml
2019-04-15 15:54:04 +03:00
2019-06-25 10:24:11 +03:00
- job : perf
timeoutInMinutes : 60
pool :
name : 'linux-pool'
steps :
2019-07-05 14:35:30 +03:00
- template : ci/report-start.yml
2019-06-25 10:24:11 +03:00
- checkout : self
- bash : ci/dev-env-install.sh
displayName : 'Build/Install the Developer Environment'
- 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)
- bash : |
set -euo pipefail
eval "$(./dev-env/bin/dade-assist)"
bazel run -- //ledger/sandbox-perf -foe true -i1 -f1 -wi 1 -bm avgt -rf csv -rff "$(Build.StagingDirectory)/sandbox-perf.csv"
- task : PublishBuildArtifacts@1
condition : succeededOrFailed()
inputs :
pathtoPublish : '$(Build.StagingDirectory)'
artifactName : 'Perf test logs'
2019-07-04 17:22:22 +03:00
- template : ci/tell-slack-failed.yml
2019-07-05 14:35:30 +03:00
- template : ci/report-end.yml
2019-04-18 19:46:02 +03:00
2019-05-22 10:26:15 +03:00
- job : Windows_signing
# Signing is a separate job so that we can make sure that we only sign on releases.
# Since the release check is run on Linux, we do not have access to that information
# in the regular Windows step.
dependsOn : [ "Windows" , "Linux" ]
pool :
name : 'windows-pool'
condition : and(succeeded(), eq(dependencies.Linux.outputs['release.has_released'], 'true'))
variables :
unsigned-installer : $[ dependencies.Windows.outputs['publish.artifact-unsigned-windows-installer'] ]
steps :
2019-07-05 14:35:30 +03:00
- template : ci/report-start.yml
2019-05-22 10:26:15 +03:00
- checkout : self
persistCredentials : true
- task : DownloadPipelineArtifact@0
inputs :
artifactName : $(unsigned-installer)
targetPath : $(Build.StagingDirectory)/
- bash : |
set -euo pipefail
INSTALLER=daml-sdk-$(cat VERSION)-windows.exe
mv "$(Build.StagingDirectory)/$(unsigned-installer)" "$(Build.StagingDirectory)/$INSTALLER"
chmod +x "$(Build.StagingDirectory)/$INSTALLER"
2019-09-24 14:02:29 +03:00
cleanup () {
rm -f signing_key.pfx
}
trap cleanup EXIT
2019-05-22 10:26:15 +03:00
echo "$SIGNING_KEY" | base64 -d > signing_key.pfx
MSYS_NO_PATHCONV=1 signtool.exe sign '/f' signing_key.pfx '/fd' sha256 '/tr' "http://timestamp.digicert.com" '/v' "$(Build.StagingDirectory)/$INSTALLER"
rm signing_key.pfx
echo "##vso[task.setvariable variable=artifact-windows-installer;isOutput=true]$INSTALLER"
echo "##vso[task.setvariable variable=has_released;isOutput=true]true"
name : signing
env :
SIGNING_KEY : $(microsoft-code-signing)
- task : PublishPipelineArtifact@0
inputs :
targetPath : $(Build.StagingDirectory)/$(signing.artifact-windows-installer)
artifactName : $(signing.artifact-windows-installer)
2019-07-05 14:35:30 +03:00
- template : ci/tell-slack-failed.yml
- template : ci/report-end.yml
2019-04-15 15:54:04 +03:00
- job : release
2019-06-25 10:24:11 +03:00
dependsOn : [ "Linux" , "macOS" , "Windows" , "Windows_signing" , "perf" ]
2019-04-15 15:54:04 +03:00
pool :
vmImage : "Ubuntu-16.04"
condition : and(succeeded(),
2019-05-06 03:21:06 +03:00
eq( dependencies.Linux.outputs['release.has_released'], 'true' ),
2019-09-26 17:10:25 +03:00
eq( dependencies.Windows.outputs['release.has_released'], 'true' ),
2019-10-04 16:57:49 +03:00
eq( dependencies.Windows_signing.outputs['signing.has_released'], 'true' ),
2019-09-04 21:54:50 +03:00
eq( dependencies.macOS.outputs['release.has_released'], 'true' ))
2019-04-15 15:54:04 +03:00
variables :
2019-05-06 03:21:06 +03:00
artifact-linux : $[ dependencies.Linux.outputs['publish.artifact'] ]
artifact-macos : $[ dependencies.macOS.outputs['publish.artifact'] ]
artifact-windows : $[ dependencies.Windows.outputs['publish.artifact'] ]
2019-05-22 10:26:15 +03:00
artifact-windows-installer : $[ dependencies.Windows_signing.outputs['signing.artifact-windows-installer'] ]
2019-04-15 15:54:04 +03:00
steps :
2019-07-05 14:35:30 +03:00
- template : ci/report-start.yml
2019-04-15 15:54:04 +03:00
- checkout : self
persistCredentials : true
- bash : |
set -euxo pipefail
2019-08-29 17:51:37 +03:00
if git tag v$(cat VERSION); then
git push origin v$(cat VERSION)
mkdir $(Build.StagingDirectory)/release
else
echo "##vso[task.setvariable variable=skip-github]TRUE"
fi
2019-04-15 15:54:04 +03:00
- task : DownloadPipelineArtifact@0
inputs :
2019-04-16 18:56:50 +03:00
artifactName : $(artifact-linux)
2019-04-15 15:54:04 +03:00
targetPath : $(Build.StagingDirectory)/release
2019-08-29 17:51:37 +03:00
condition : not(eq(variables['skip-github'], 'TRUE'))
2019-04-15 15:54:04 +03:00
- task : DownloadPipelineArtifact@0
inputs :
2019-04-16 18:56:50 +03:00
artifactName : $(artifact-macos)
2019-04-15 15:54:04 +03:00
targetPath : $(Build.StagingDirectory)/release
2019-08-29 17:51:37 +03:00
condition : not(eq(variables['skip-github'], 'TRUE'))
2019-04-25 04:57:32 +03:00
- task : DownloadPipelineArtifact@0
inputs :
artifactName : $(artifact-windows)
targetPath : $(Build.StagingDirectory)/release
2019-08-29 17:51:37 +03:00
condition : not(eq(variables['skip-github'], 'TRUE'))
2019-04-30 15:39:28 +03:00
- task : DownloadPipelineArtifact@0
inputs :
artifactName : $(artifact-windows-installer)
targetPath : $(Build.StagingDirectory)/release
2019-08-29 17:51:37 +03:00
condition : not(eq(variables['skip-github'], 'TRUE'))
2019-09-24 14:02:29 +03:00
- bash : |
set -euo pipefail
KEY_FILE=$(mktemp)
GPG_DIR=$(mktemp -d)
cleanup() {
rm -rf $KEY_FILE $GPG_DIR
}
trap cleanup EXIT
2019-09-25 02:24:02 +03:00
echo "$GPG_KEY" | base64 -d > $KEY_FILE
2019-09-24 14:02:29 +03:00
gpg --homedir $GPG_DIR --no-tty --quiet --import $KEY_FILE
cd $(Build.StagingDirectory)/release
# Note: relies on our release artifacts not having spaces in their
# names. Creates a ${f}.asc with the signature for each $f.
for f in *; do
gpg --homedir $GPG_DIR -ab $f
done
env :
GPG_KEY : $(gpg-code-signing)
2019-04-15 15:54:04 +03:00
- task : GitHubRelease@0
inputs :
gitHubConnection : 'garyverhaegen-da'
repositoryName : '$(Build.Repository.Name)'
action : 'create'
target : '$(Build.SourceVersion)'
tagSource : 'auto'
assets : $(Build.StagingDirectory)/release/*
assetUploadMode : 'replace'
addChangeLog : false
isPrerelease : true
2019-08-29 17:51:37 +03:00
condition : not(eq(variables['skip-github'], 'TRUE'))
2019-07-04 17:22:22 +03:00
- template : ci/tell-slack-failed.yml
2019-07-05 14:35:30 +03:00
- template : ci/report-end.yml
2019-11-08 00:55:25 +03:00
- job : write_ledger_dump
dependsOn : [ "Linux" , "macOS" , "Windows" , "Windows_signing" , "perf" ]
pool :
vmImage : "Ubuntu-16.04"
condition : and(succeeded(),
eq( dependencies.Linux.outputs['release.has_released'], 'true' ),
eq( dependencies.Windows.outputs['release.has_released'], 'true' ),
eq( dependencies.Windows_signing.outputs['signing.has_released'], 'true' ),
eq( dependencies.macOS.outputs['release.has_released'], 'true' ))
steps :
- checkout : self
- bash : |
set -euo pipefail
sudo mkdir -p /nix
sudo chown $USER /nix
2020-02-07 18:05:52 +03:00
curl -sfL https://nixos.org/releases/nix/nix-2.3.2/install | bash
2019-11-08 00:55:25 +03:00
eval "$(dev-env/bin/dade-assist)"
GCS_KEY=$(mktemp)
cleanup () {
rm -f $GCS_KEY
}
trap cleanup EXIT
echo "$GOOGLE_APPLICATION_CREDENTIALS_CONTENT" > $GCS_KEY
gcloud auth activate-service-account --key-file=$GCS_KEY
export BOTO_CONFIG=/dev/null
bazel build //ledger/api-server-damlonx/reference-v2:reference-ledger-dump
gsutil cp bazel-bin/ledger/api-server-damlonx/reference-v2/reference-ledger-dump.out \
gs://daml-dumps/release/ledger/api-server-damlonx/reference-v2/reference-ledger-dump-$(cat VERSION)
env :
GOOGLE_APPLICATION_CREDENTIALS_CONTENT : $(GOOGLE_APPLICATION_CREDENTIALS_CONTENT)
- template : ci/tell-slack-failed.yml
2019-07-05 14:35:30 +03:00
- job : collect_build_data
condition : always()
2020-02-03 18:29:13 +03:00
dependsOn :
- Linux
- macOS
- Windows
- Windows_signing
- perf
- release
- check_standard_change_label
- write_ledger_dump
- git_sha
2019-07-05 14:35:30 +03:00
pool :
name : "linux-pool"
variables :
Linux.start : $[ dependencies.Linux.outputs['start.time'] ]
Linux.machine : $[ dependencies.Linux.outputs['start.machine'] ]
Linux.end : $[ dependencies.Linux.outputs['end.time'] ]
Linux.status : $[ dependencies.Linux.result ]
macOS.start : $[ dependencies.macOS.outputs['start.time'] ]
macOS.machine : $[ dependencies.macOS.outputs['start.machine'] ]
macOS.end : $[ dependencies.macOS.outputs['end.time'] ]
macOS.status : $[ dependencies.macOS.result ]
Windows.start : $[ dependencies.Windows.outputs['start.time'] ]
Windows.machine : $[ dependencies.Windows.outputs['start.machine'] ]
Windows.end : $[ dependencies.Windows.outputs['end.time'] ]
Windows.status : $[ dependencies.Windows.result ]
Windows_signing.start : $[ dependencies.Windows_signing.outputs['start.time'] ]
Windows_signing.machine : $[ dependencies.Windows_signing.outputs['start.machine'] ]
Windows_signing.end : $[ dependencies.Windows_signing.outputs['end.time'] ]
Windows_signing.status : $[ dependencies.Windows_signing.result ]
perf.start : $[ dependencies.perf.outputs['start.time'] ]
perf.machine : $[ dependencies.perf.outputs['start.machine'] ]
perf.end : $[ dependencies.perf.outputs['end.time'] ]
perf.status : $[ dependencies.perf.result ]
release.start : $[ dependencies.release.outputs['start.time'] ]
release.machine : $[ dependencies.release.outputs['start.machine'] ]
release.end : $[ dependencies.release.outputs['end.time'] ]
release.status : $[ dependencies.release.result ]
2019-12-13 13:44:39 +03:00
std_change.start : $[ dependencies.check_standard_change_label.outputs['start.time'] ]
std_change.machine : $[ dependencies.check_standard_change_label.outputs['start.machine'] ]
std_change.end : $[ dependencies.check_standard_change_label.outputs['end.time'] ]
std_change.status : $[ dependencies.check_standard_change_label.result ]
dump.start : $[ dependencies.write_ledger_dump.outputs['start.time'] ]
dump.machine : $[ dependencies.write_ledger_dump.outputs['start.machine'] ]
dump.end : $[ dependencies.write_ledger_dump.outputs['end.time'] ]
dump.status : $[ dependencies.write_ledger_dump.result ]
2020-02-03 18:29:13 +03:00
branch_sha : $[ dependencies.git_sha.outputs['out.branch'] ]
master_sha : $[ dependencies.git_sha.outputs['out.master'] ]
fork_sha : $[ dependencies.git_sha.outputs['out.fork_point'] ]
2019-09-24 00:02:33 +03:00
# Using expression syntax so we get an empty string if not set, rather
# than the raw $(VarName) string. Expression syntax works on the
# variables key, but not on the env one, so we need an extra indirection.
# Note: These Azure variables are only set for PR builds.
pr.num : $[ variables['System.PullRequest.PullRequestNumber'] ]
pr.branch : $[ variables['System.PullRequest.SourceBranch'] ]
2019-07-05 14:35:30 +03:00
steps :
2020-01-21 21:14:46 +03:00
# some change in Azure configuration makes this fail recently (2020-01).
# Azure runs PR builds not on the PR commit, but on the GitHub-provided
# commit that would be the result of merging the PR. Recently, it looks
# like when it reaches the point of running this job (which has to run
# after the macOS one, which sometimes takes up to an hour), if master
# has changed in the meantime, Azure cannot find the commit it wants to
# build anymore. Therefore, we tell it not to checkout anything, and
# manually checkout the PR commit.
- checkout : none
2019-07-05 14:35:30 +03:00
- bash : |
set -euo pipefail
2020-02-03 18:29:13 +03:00
# Note: this is going to get the PR branch commit, not the
2020-01-21 21:14:46 +03:00
# result of the merge (i.e. this is not using the same commit as the
2020-02-03 18:29:13 +03:00
# other jobs in this build).
git fetch origin $(branch_sha)
git checkout $(branch_sha)
2019-09-24 00:02:33 +03:00
eval "$(./dev-env/bin/dade-assist)"
2019-07-05 14:35:30 +03:00
REPORT=$(mktemp)
cat >$REPORT <<END
{"jobs": {"Linux": {"start": "$(Linux.start)" ,
"machine": "$(Linux.machine)" ,
"end": "$(Linux.end)" ,
"status": "$(Linux.status)" },
"macOS": {"start": "$(macOS.start)" ,
"machine": "$(macOS.machine)" ,
"end": "$(macOS.end)" ,
"status": "$(macOS.status)" },
"Windows": {"start": "$(Windows.start)" ,
"machine": "$(Windows.machine)" ,
"end": "$(Windows.end)" ,
"status": "$(Windows.status)" },
"Windows_signing": {"start": "$(Windows_signing.start)" ,
"machine": "$(Windows_signing.machine)" ,
"end": "$(Windows_signing.end)" ,
"status": "$(Windows_signing.status)" },
"perf": {"start": "$(perf.start)" ,
"machine": "$(perf.machine)" ,
"end": "$(perf.end)" ,
"status": "$(perf.status)" },
2019-12-13 13:44:39 +03:00
"check_standard_change_label": {"start": "$(std_change.start)" ,
"machine": "$(std_change.machine)" ,
"end": "$(std_change.end)" ,
"status": "$(std_change.status)" },
"write_ledger_dump": {"start": "$(dump.start)" ,
"machine": "$(dump.machine)" ,
"end": "$(dump.end)" ,
"status": "$(dump.status)" },
2019-07-05 14:35:30 +03:00
"release": {"start": "$(release.start)" ,
"machine": "$(release.machine)" ,
"end": "$(release.end)" ,
2019-09-11 09:57:48 +03:00
"status": "$(release.status)" }},
2019-07-05 14:35:30 +03:00
"id": "$(Build.BuildId)" ,
"url": "https://dev.azure.com/digitalasset/daml/_build/results?buildId=$(Build.BuildId)" ,
"name": "$(Build.DefinitionName)" ,
"version": "$(Build.DefinitionVersion)" ,
"queued_by": "$(Build.QueuedBy)" ,
"reason": "$(Build.Reason)" ,
"branch": "$(Build.SourceBranch)" ,
2020-02-03 18:29:13 +03:00
"merge_commit": "$(Build.SourceVersion)" ,
"branch_commit": "$(branch_sha)" ,
"master_commit": "$(master_sha)" ,
"fork_point_commit": "$(fork_sha)" ,
2019-09-24 00:02:33 +03:00
"commit_message": $(echo -n "$COMMIT_MSG" | jq -sR),
2019-07-05 14:35:30 +03:00
"is_fork": "$(System.PullRequest.IsFork)" ,
2019-09-24 00:02:33 +03:00
"pr": "$PR_NUM" ,
"pr_url": "https://github.com/digital-asset/daml/pull/$PR_NUM" ,
"pr_source_branch": "$PR_BRANCH" }
2019-07-05 14:35:30 +03:00
END
2019-09-18 16:00:53 +03:00
# Test above JSON is well formed
cat $REPORT | jq '.'
2019-07-05 14:35:30 +03:00
REPORT_GZ=$(mktemp)
cat $REPORT | gzip -9 > $REPORT_GZ
GCS_KEY=$(mktemp)
2019-09-24 14:02:29 +03:00
cleanup() {
rm -rf $GCS_KEY
}
trap cleanup EXIT
2019-07-18 19:13:29 +03:00
# Application credentials will not be set for forks. We give up on
2019-07-19 14:33:15 +03:00
# tracking those for now. "Not set" in Azure world means set to the
# expression Azure would otherwise substitute, i.e. the literal value
# of the string in the `env:` block below.
2020-01-09 15:03:54 +03:00
if [[ "${GOOGLE_APPLICATION_CREDENTIALS_CONTENT:1:${#GOOGLE_APPLICATION_CREDENTIALS_CONTENT}-1}" != '(GOOGLE_APPLICATION_CREDENTIALS_CONTENT)' ]]; then
2019-07-18 19:13:29 +03:00
echo "$GOOGLE_APPLICATION_CREDENTIALS_CONTENT" > $GCS_KEY
gcloud auth activate-service-account --key-file=$GCS_KEY
BOTO_CONFIG=/dev/null gsutil cp $REPORT_GZ gs://daml-data/builds/$(Build.BuildId)_$(date -u +%Y%m%d_%H%M%SZ).json.gz
else
2020-01-09 15:03:54 +03:00
echo "Could not save build data: no credentials. Data was:"
2019-07-18 19:13:29 +03:00
cat $REPORT
fi
2019-07-10 22:52:50 +03:00
2019-12-13 13:44:39 +03:00
# Linux, macOS, perf, check_std_change_label and Windows are always
# required and should always succeed.
#
# windows_signing, release and write_ledger_dump only run on releases
# and are skipped otherwise.
if [[ "$(Linux.status)" != "Succeeded"
|| "$(macOS.status)" != "Succeeded"
|| "$(Windows.status)" != "Succeeded"
|| "$(perf.status)" != "Succeeded"
|| "$(dump.status)" == "Canceled"
2019-07-10 22:52:50 +03:00
|| "$(Windows_signing.status)" == "Canceled"
fix collect-build-data status (#4001)
The main goal of this job is to fail when other, required jobs are
canceled. The reason for this is that the communication between Azure
and GitHub does not always work very well, particularly around canceled
jobs, so that when a job gets canceled GitHub does not always know about
it, and furthermore GitHub does not provide a "re-run" button for
canceled jobs.
Thus, this one provides a failed job that doe sdisplay a "re-run"
button, which re-runs all the failed/canceled jobs in the current build.
Therefore, this only needs to detect canceled jobs, not failed ones
(because those will have their own "re-run" button).
Additionally, we recently changed the standard-change label check to not
run on master (as it really only makes sense on PRs), resulting in a
Skipped status instead of Succeeded, which made this job fail.
CHANGELOG_BEGIN
CHANGELOG_END
2020-01-09 19:31:32 +03:00
|| "$(release.status)" == "Canceled" ]]; then
2019-07-10 22:52:50 +03:00
exit 1
fi
2019-07-05 14:35:30 +03:00
env :
GOOGLE_APPLICATION_CREDENTIALS_CONTENT : $(GOOGLE_APPLICATION_CREDENTIALS_CONTENT)
2019-09-24 00:02:33 +03:00
# Commit message is always set
COMMIT_MSG : $(Build.SourceVersionMessage)
# Because these variables are always set (in the variables block),
# hopefully these should be set as expected (i.e. either correct
# value or empty string, but not $(Azure.Variable.Name)).
PR_NUM : $(pr.num)
PR_BRANCH : $(pr.branch)
2020-02-03 18:29:13 +03:00
- job : notify_user
2020-02-03 21:25:37 +03:00
condition : eq(variables['Build.Reason'], 'PullRequest')
2020-02-03 18:29:13 +03:00
dependsOn :
- git_sha
- collect_build_data
pool :
name : 'linux-pool'
variables :
pr.num : $[ variables['System.PullRequest.PullRequestNumber'] ]
branch_sha : $[ dependencies.git_sha.outputs['out.branch'] ]
2020-02-04 17:53:39 +03:00
status : $[ dependencies.collect_build_data.result ]
2020-02-03 18:29:13 +03:00
steps :
- checkout : none
- bash : |
set -euo pipefail
git fetch origin $(branch_sha)
git checkout $(branch_sha)
tell_slack() {
local MESSAGE=$1
local USER_ID=$2
curl -XPOST \
-i \
-H 'Content-Type : application/json' \
2020-02-03 21:25:37 +03:00
--data "{\"text\":\"<@${USER_ID}> <https://dev.azure.com/digitalasset/daml/_build/results?buildId=$(Build.BuildId)|Build $(Build.BuildId)> for <https://github.com/digital-asset/daml/pull/$(pr.num)|PR $(pr.num)> has completed with status ${MESSAGE}.\"}" \
2020-02-03 18:29:13 +03:00
$(Slack.team-daml-ci)
}
EMAIL=$(git log -n 1 --format=%ae)
user_registered() {
cat ci/slack_user_ids | grep $EMAIL
}
user_id() {
echo $(cat ci/slack_user_ids | grep $EMAIL | awk '{print $2}')
}
if user_registered; then
2020-02-04 17:53:39 +03:00
tell_slack "$(status)" "$(user_id)"
2020-02-03 18:29:13 +03:00
else
echo "User $(user_id) did not opt in for notifications."
fi