daml/ci/patch_bazel_windows/compile.yml
Moritz Kiefer e40f62f88a
Revert "Switch to Bazel 5 (#12935)" (#12974)
This reverts commit 4c0118df4d.

This breaks passing -p to bazel test for Haskell tests, e.g.,

bazel test //compiler/damlc/tests:integration-v1dev --test_arg -p
--test_arg InterfaceEq

which breaks with something horrifying like

moritz@adjunction ~/daml (main)> bazel test //compiler/damlc/tests:integration-v1dev --test_arg -p --test_arg InterfaceEq
[dev-env] Building tools.bazel...
[dev-env] Built tools.bazel in /nix/store/m7gzlmr0pqjpl01ihgvazxgfs3sfwl61-bazel and linked to /home/moritz/daml/dev-env/var/gc-roots/bazel
[dev-env] Building tools.find...
[dev-env] Built tools.find in /nix/store/645v3545lcbx77wq7355rgdrgbhn5wx7-findutils-4.8.0 and linked to /home/moritz/daml/dev-env/var/gc-roots/find
INFO: Invocation ID: 034b3e45-851f-472e-ab71-b7f718829582
DEBUG: /home/moritz/.cache/bazel/_bazel_moritz/bb4e4404f889dc1b816f246b08c0d9ea/external/rules_haskell/haskell/private/versions.bzl:60:10: WARNING: bazel version is too recent. Supported versions range from 4.0.0 to 4.2.1, but found: 5.0.0- (@non-git)
/nix/store/dadkhf8vch2i2kvig962ilfr5j3chshr-go-1.17.6
/nix/store/pzh24n543i6jqa01hdmgqknlyf294bn1-bazel-nixpkgs-posix-toolchain
/nix/store/2hfwndk47wpvaib06qyhcdp83b423xvh-jq-1.6-bin
/nix/store/hjggs9s82qh7r5j8sgapn389hf24wdx8-bazel-nixpkgs-cc-toolchain
/nix/store/yxgg3bn4v288sc00kf09svrwz2r461c9-ghc-native-bignum-9.0.2
/nix/store/2hwx0jhcdsx3wfvmb50ih19jkh2ra4jh-glibc-locales-2.33-108
/nix/store/8wpmx049z8m0ffhy3jyi41qb6pbxwvy8-bazel-nixpkgs-java-runtime
ERROR: file 'external/bazel_tools/src/tools/launcher/_objs/launcher/dummy.pic.o' is generated by these conflicting actions:
Label: @bazel_tools//src/tools/launcher:launcher
RuleClass: cc_binary rule
Configuration: 869f6bbd14d2ac66dcacb164312d88fa059b017e3c17513cb5051b23879ac7f9, 8c138cc79f95329f01b0d325511ad0ea89ca5126e421e67e5239706d0f247c2c
Mnemonic: CppCompile
Action key: 3d79fe1470dcb842d5944c98dfe7a62715db6d86fdb12d3ff60af3bdf41b7996
Progress message: Compiling src/tools/launcher/dummy.cc
PrimaryInput: File:[/home/moritz/.cache/bazel/_bazel_moritz/bb4e4404f889dc1b816f246b08c0d9ea/external/bazel_tools[source]]src/tools/launcher/dummy.cc
PrimaryOutput: File:[[<execution_root>]bazel-out/k8-opt/bin]external/bazel_tools/src/tools/launcher/_objs/launcher/dummy.pic.o
Owner information: ConfiguredTargetKey{label=@bazel_tools//src/tools/launcher:launcher, config=BuildConfigurationValue.Key[869f6bbd14d2ac66dcacb164312d88fa059b017e3c17513cb5051b23879ac7f9]}, ConfiguredTargetKey{label=@bazel_tools//src/tools/launcher:launcher, config=BuildConfigurationValue.Key[8c138cc79f95329f01b0d325511ad0ea89ca5126e421e67e5239706d0f247c2c]}
MandatoryInputs: are equal
Outputs: are equal
ERROR: file 'external/bazel_tools/src/tools/launcher/_objs/launcher/dummy.o' is generated by these conflicting actions:
Label: @bazel_tools//src/tools/launcher:launcher
RuleClass: cc_binary rule
Configuration: 869f6bbd14d2ac66dcacb164312d88fa059b017e3c17513cb5051b23879ac7f9, 8c138cc79f95329f01b0d325511ad0ea89ca5126e421e67e5239706d0f247c2c
Mnemonic: CppCompile
Action key: 9f46e824944add9e9951ef51ddb6cb4b744bc97f90b5749132179d1d1699dfa1
Progress message: Compiling src/tools/launcher/dummy.cc
PrimaryInput: File:[/home/moritz/.cache/bazel/_bazel_moritz/bb4e4404f889dc1b816f246b08c0d9ea/external/bazel_tools[source]]src/tools/launcher/dummy.cc
PrimaryOutput: File:[[<execution_root>]bazel-out/k8-opt/bin]external/bazel_tools/src/tools/launcher/_objs/launcher/dummy.o
Owner information: ConfiguredTargetKey{label=@bazel_tools//src/tools/launcher:launcher, config=BuildConfigurationValue.Key[869f6bbd14d2ac66dcacb164312d88fa059b017e3c17513cb5051b23879ac7f9]}, ConfiguredTargetKey{label=@bazel_tools//src/tools/launcher:launcher, config=BuildConfigurationValue.Key[8c138cc79f95329f01b0d325511ad0ea89ca5126e421e67e5239706d0f247c2c]}
MandatoryInputs: are equal
Outputs: are equal
ERROR: com.google.devtools.build.lib.skyframe.ArtifactConflictFinder$ConflictException: com.google.devtools.build.lib.actions.MutableActionGraph$ActionConflictException: for external/bazel_tools/src/tools/launcher/_objs/launcher/dummy.o, previous action: action 'Compiling src/tools/launcher/dummy.cc', attempted action: action 'Compiling src/tools/launcher/dummy.cc'

changelog_begin
changelog_end
2022-02-16 18:24:00 +00:00

122 lines
4.6 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
parameters:
- name: final_job_name
jobs:
- job: patch_bazel_pre_check
pool:
name: ubuntu_20_04
steps:
- checkout: self
- template: ../bash-lib.yml
parameters:
var_name: bash-lib
- bash: |
set -euo pipefail
source $(bash-lib)
CACHE_KEY="$(find ci/patch_bazel_windows -type f -print0 | sort -z | xargs -r0 md5sum | md5sum | awk '{print $1}')"
TARGET="patch_bazel_windows/bazel-$CACHE_KEY.zip"
TARGET_URL="https://daml-binaries.da-ext.net/$TARGET"
STATUS="$(curl -Is "$TARGET_URL" | head -1 | awk '{print $2}')"
if [ "200" = "$STATUS" ]; then
SHOULD_RUN=false
else
SHOULD_RUN=true
fi
setvar cache_key $CACHE_KEY
setvar should_run $SHOULD_RUN
setvar target $TARGET
setvar target_url $TARGET_URL
echo "Final hash and URL will be printed by the ${{parameters.final_job_name}} job."
name: out
- job: patch_bazel_compile
dependsOn:
- patch_bazel_pre_check
variables:
cache_key: $[ dependencies.patch_bazel_pre_check.outputs['out.cache_key'] ]
should_run: $[ dependencies.patch_bazel_pre_check.outputs['out.should_run'] ]
bazel_base_version: 4.2.1
pool:
vmImage: windows-2019
steps:
- checkout: self
condition: eq(variables.should_run, 'true')
- bash: |
git clone https://github.com/bazelbuild/bazel.git
cd bazel
git checkout $(bazel_base_version)
condition: eq(variables.should_run, 'true')
- powershell: |
choco install msys2 --noprogress --yes
choco install zip --noprogress --yes
condition: eq(variables.should_run, 'true')
- powershell: |
C:\tools\msys64\usr\bin\pacman -S zip --noconfirm
condition: eq(variables.should_run, 'true')
- bash: |
set -euo pipefail
BAZEL=$(mktemp)
curl -sL https://github.com/bazelbuild/bazel/releases/download/$(bazel_base_version)/bazel-$(bazel_base_version)-windows-x86_64.exe > $BAZEL
cd bazel
$BAZEL build src/main/cpp:client src:package-zip_jdk_minimal -c opt --stamp --embed_label $(bazel_base_version)-patched-$(cache_key)
# Note (MK) For some reason, the `zip` from chocolatey seems to result in
# a “zip file structure invalid” error. Ive tried adding msys to PATH so the Bazel
# rules pick up `zip` from msys but that broke other things. So for now
# we skip the final Bazel rule to build the self-extracting exe and instead
# call `zip` from msys separately.
/c/tools/msys64/msys2_shell.cmd -defterm -no-start -here -c "cat bazel-bin/src/main/cpp/client.exe bazel-bin/src/package_jdk_minimal.zip > bazel.exe && zip -A bazel.exe"
mkdir '$(Build.StagingDirectory)\patched-bazel'
zip bazel.zip bazel.exe
cp bazel.zip '$(Build.StagingDirectory)\patched-bazel'
echo "Final hash and URL will be printed by the ${{parameters.final_job_name}} job."
condition: eq(variables.should_run, 'true')
- task: PublishPipelineArtifact@1
inputs:
targetPath: $(Build.StagingDirectory)/patched-bazel
artifactName: patched-bazel
condition: eq(variables.should_run, 'true')
- job: ${{ parameters.final_job_name }}
dependsOn:
- patch_bazel_compile
- patch_bazel_pre_check
variables:
cache_key: $[ dependencies.patch_bazel_pre_check.outputs['out.cache_key'] ]
target: $[ dependencies.patch_bazel_pre_check.outputs['out.target'] ]
target_url: $[ dependencies.patch_bazel_pre_check.outputs['out.target_url'] ]
should_run: $[ dependencies.patch_bazel_pre_check.outputs['out.should_run'] ]
pool:
name: ubuntu_20_04
steps:
- task: DownloadPipelineArtifact@2
inputs:
artifact: patched-bazel
path: $(Build.StagingDirectory)/patched-bazel
condition: eq(variables.should_run, 'true')
- bash: |
set -euo pipefail
SOURCE='$(Build.StagingDirectory)/patched-bazel/bazel.zip'
GCS_KEY=$(mktemp)
cleanup() {
rm -rf $GCS_KEY
}
trap cleanup EXIT
# This will break on external PRs.
echo "$GOOGLE_APPLICATION_CREDENTIALS_CONTENT" > $GCS_KEY
gcloud auth activate-service-account --key-file=$GCS_KEY
BOTO_CONFIG=/dev/null gsutil cp "$SOURCE" "gs://daml-binaries/$(target)"
echo "url: $(target_url)"
echo "hash: $(sha256sum "$(Build.StagingDirectory)/patched-bazel/bazel.zip" | awk '{print $1}')"
env:
GOOGLE_APPLICATION_CREDENTIALS_CONTENT: $(GOOGLE_APPLICATION_CREDENTIALS_CONTENT)
condition: eq(variables.should_run, 'true')