# Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 parameters: test_mode: '' jobs: - job: git_sha pool: name: 'ubuntu_20_04' demands: assignment -equals default steps: - template: bash-lib.yml parameters: var_name: bash-lib - bash: | set -euo pipefail source $(bash-lib) if [ "$(Build.Reason)" == "PullRequest" ]; then setvar branch "$(git rev-parse HEAD^2)" setvar main "$(git rev-parse HEAD^1)" setvar fork_point "$(git merge-base $(git rev-parse HEAD^1) $(git rev-parse HEAD^2))" else setvar branch "$(git rev-parse HEAD)" setvar main "$(git rev-parse HEAD^1)" setvar fork_point "$(git rev-parse HEAD^1)" fi name: out - job: Linux dependsOn: - check_for_release variables: - name: release_sha value: $[ dependencies.check_for_release.outputs['out.release_sha'] ] - name: release_tag value: $[ coalesce(dependencies.check_for_release.outputs['out.release_tag'], '0.0.0') ] - name: trigger_sha value: $[ dependencies.check_for_release.outputs['out.trigger_sha'] ] - name: is_release value: $[ dependencies.check_for_release.outputs['out.is_release'] ] - template: job-variables.yml timeoutInMinutes: 240 strategy: matrix: intel: assignment: default name: linux-intel arm: assignment: arm name: linux-arm pool: name: 'ubuntu_20_04' demands: assignment -equals $(assignment) steps: - template: report-start.yml - checkout: self - bash: | set -euo pipefail git checkout $(release_sha) name: checkout_release condition: and(succeeded(), eq(variables.is_release, 'true')) - template: clean-up.yml - template: build-unix.yml parameters: # The syntax required to inline a variable changes based on context # (`$(var)` in strings, `variables.var` in expressions). Template # parameters are inlined before evaluation. This is a bit like lazy # function arguments, but at the syntax level. # # The result is that we need to know what context the parameter will be # used in, which is why `release_tag` and `is_release` use different # syntaxes, and why we need to passe `name` twice. release_tag: $(release_tag) name_str: $(name) name_exp: variables.name is_release: variables.is_release test_mode: ${{parameters.test_mode}} - template: upload-bazel-metrics.yml - bash: | set -euo pipefail eval "$(./dev-env/bin/dade-assist)" bazel build //release:release ./bazel-bin/release/release --release-dir "$(mktemp -d)" condition: and(succeeded(), ne(variables['is_release'], 'true')) - template: tell-slack-failed.yml parameters: trigger_sha: '$(trigger_sha)' - template: report-end.yml - template: macOS.yml parameters: job_name: macOS name: macos assignment: default test_mode: ${{parameters.test_mode}} - template: macOS.yml parameters: job_name: m1 name: m1 assignment: m1-builds test_mode: ${{parameters.test_mode}} - template: blackduck.yml - job: Windows dependsOn: - check_for_release variables: - name: release_sha value: $[ dependencies.check_for_release.outputs['out.release_sha'] ] - name: release_tag value: $[ coalesce(dependencies.check_for_release.outputs['out.release_tag'], '0.0.0') ] - name: trigger_sha value: $[ dependencies.check_for_release.outputs['out.trigger_sha'] ] - name: is_release value: $[ dependencies.check_for_release.outputs['out.is_release'] ] - name: is_split_release value: $[ dependencies.check_for_release.outputs['out.split_release_process'] ] - name: skip_tests value: $[ and(eq(variables.is_release, 'true'), in(variables['Build.SourceBranchName'], 'main', 'main-2.x')) ] - template: job-variables.yml timeoutInMinutes: 240 pool: name: 'windows-pool' demands: assignment -equals default steps: - template: report-start.yml - checkout: self - bash: | set -euo pipefail for f in $(find /d/a/SourceRootMapping -type f); do echo "-----" echo $f echo "-----" cat $f echo "-----" done name: workdirs - bash: | set -euo pipefail git checkout $(release_sha) name: checkout_release condition: and(succeeded(), eq(variables.is_release, 'true')) - template: build-windows.yml parameters: release_tag: $(release_tag) # Azure pipeline’s variable and parameter expansion is utter garbage. # For whatever reason `env` values only seem to be able to use macro syntax # and not runtime expression. is_release however is a runtime variable # so template conditions won’t work. Therefore we define the variable here # with a runtime expression, set the parameter to the (unexpanded) string "$(skip_tests)" # and then splice that in via a template parameter. skip_tests: $(skip_tests) is_release: variables.is_release is_split_release: $(is_split_release) test_mode: ${{parameters.test_mode}} - template: upload-bazel-metrics.yml - template: tell-slack-failed.yml parameters: trigger_sha: '$(trigger_sha)' - template: report-end.yml - job: platform_independence_test condition: and(succeeded(), eq(dependencies.check_for_release.outputs['out.is_release'], 'false')) dependsOn: - Windows - Linux - macOS pool: name: 'ubuntu_20_04' demands: assignment -equals default steps: - checkout: self - bash: ci/dev-env-install.sh displayName: 'Build/Install the Developer Environment' - task: DownloadPipelineArtifact@2 inputs: artifactName: platform-independence-dar-linux-intel targetPath: $(Build.StagingDirectory)/platform-independence/linux-intel/ - task: DownloadPipelineArtifact@2 inputs: artifactName: platform-independence-dar-linux-arm targetPath: $(Build.StagingDirectory)/platform-independence/linux-arm/ - task: DownloadPipelineArtifact@2 inputs: artifactName: platform-independence-dar-windows targetPath: $(Build.StagingDirectory)/platform-independence/windows/ - task: DownloadPipelineArtifact@2 inputs: artifactName: platform-independence-dar-macos targetPath: $(Build.StagingDirectory)/platform-independence/macos/ - bash: | set -euo pipefail eval "$(./dev-env/bin/dade-assist)" DIR1=$(mktemp -d) DIR2=$(mktemp -d) DIR3=$(mktemp -d) DIR4=$(mktemp -d) trap "rm -rf $DIR1 $DIR2 $DIR3 $DIR4" EXIT unzip -d $DIR1 $(Build.StagingDirectory)/platform-independence/linux-intel/platform-independence.dar unzip -d $DIR2 $(Build.StagingDirectory)/platform-independence/windows/platform-independence.dar unzip -d $DIR3 $(Build.StagingDirectory)/platform-independence/macos/platform-independence.dar unzip -d $DIR4 $(Build.StagingDirectory)/platform-independence/linux-arm/platform-independence.dar # hie/hi files may differ. diff -r --strip-trailing-cr -x '*.hie' -x '*.hi' $DIR1 $DIR2 diff -r --strip-trailing-cr -x '*.hie' -x '*.hi' $DIR1 $DIR3 diff -r --strip-trailing-cr -x '*.hie' -x '*.hi' $DIR1 $DIR4 displayName: 'Compare platform-independence dars of different platforms.' - job: compatibility_ts_libs dependsOn: - check_for_release condition: and(succeeded(), not(eq(dependencies.check_for_release.outputs['out.is_release'], 'true'))) timeoutInMinutes: 240 pool: name: ubuntu_20_04 demands: assignment -equals default steps: - template: report-start.yml - checkout: self - template: clean-up.yml - template: compatibility_ts_libs.yml - template: tell-slack-failed.yml - template: report-end.yml - job: compatibility_linux dependsOn: - check_for_release - compatibility_ts_libs timeoutInMinutes: 240 pool: name: ubuntu_20_04 demands: assignment -equals default steps: - template: report-start.yml - checkout: self - template: clean-up.yml - template: compatibility.yml parameters: test_flags: '--quick' - template: tell-slack-failed.yml - template: report-end.yml # For main and PRs targeting main, we simply check against the most recent stable tag. - job: compatibility_stable_protobuf pool: name: ubuntu_20_04 demands: assignment -equals default steps: - checkout: self fetchTags: true - bash: ci/check-protobuf-stability.sh - template: tell-slack-failed.yml - job: collect_build_data_failed condition: failed() dependsOn: - Linux - macOS - Windows - release - git_sha - compatibility_linux - compatibility_stable_protobuf - check_for_release pool: name: "ubuntu_20_04" demands: assignment -equals default - job: collect_build_data condition: always() dependsOn: - collect_build_data_failed variables: failed_result: $[ dependencies.collect_build_data_failed.result ] pool: name: "ubuntu_20_04" demands: assignment -equals default steps: - bash: "exit 1" # Since 'collect_build_data_failed' only runs when 'failed()', if it was # successful that means at least one of its dependencies failed, so we set # the result of 'collect_build_data' to 'Failed' with 'exit 1' condition: eq(variables.failed_result, 'Succeeded')