Make compat tests work on windows (#5732)

* Make compat tests work on windows

This required some changes to the daml_sdk rule since the read-only
installation by the assistant breaks Bazel completely. We could only
apply those changes on Windows but I think I prefer the consistency
across platforms here over trying to stay close to how the SDK is
installed on user machines given that the SDK installation is not
something we’ve had issues with.

I’ve excluded the postgresql tests for now. I don’t expect them to be
particularly hard to fix but I’ve already spent almost 2 days on this
and having some tests run on Windows seems like a clear improvement
over running no tests on Windows :)

changelog_begin
changelog_end

* Remove todo

changelog_begin
changelog_end
This commit is contained in:
Moritz Kiefer 2020-04-28 16:06:36 +02:00 committed by GitHub
parent d6c5a2532d
commit 49e19ebed1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 285 additions and 48 deletions

1
.gitignore vendored
View File

@ -79,6 +79,7 @@ ledger-api/.bin
### Bazel: https://www.gitignore.io/api/bazel ###
/bazel-*
/compatibility/bazel-*
/compatibility/.bazelrc
.bazelrc.local
.ijwb
.bazelproject

View File

@ -204,6 +204,21 @@ jobs:
- template: ci/tell-slack-failed.yml
- template: ci/report-end.yml
- job: compatibility_windows
dependsOn:
- check_for_release
timeoutInMinutes: 60
pool:
name: 'windows-pool'
steps:
- template: ci/report-start.yml
- checkout: self
- template: ci/compatibility-windows.yml
parameters:
test_flags: '--quick'
- template: ci/tell-slack-failed.yml
- template: ci/report-end.yml
- job: check_for_release
dependsOn:
- git_sha
@ -378,6 +393,7 @@ jobs:
- git_sha
- compatibility_macos
- compatibility_linux
- compatibility_windows
pool:
name: "linux-pool"
variables:
@ -409,6 +425,10 @@ jobs:
compatibility_macos.machine: $[ dependencies.compatibility_macos.outputs['start.machine'] ]
compatibility_macos.end: $[ dependencies.compatibility_macos.outputs['end.time'] ]
compatibility_macos.status: $[ dependencies.compatibility_macos.result ]
compatibility_windows.start: $[ dependencies.compatibility_windows.outputs['start.time'] ]
compatibility_windows.machine: $[ dependencies.compatibility_windows.outputs['start.machine'] ]
compatibility_windows.end: $[ dependencies.compatibility_windows.outputs['end.time'] ]
compatibility_windows.status: $[ dependencies.compatibility_windows.result ]
branch_sha: $[ dependencies.git_sha.outputs['out.branch'] ]
master_sha: $[ dependencies.git_sha.outputs['out.master'] ]
@ -455,7 +475,11 @@ jobs:
"compatibility_macos": {"start": "$(compatibility_macos.start)",
"machine": "$(compatibility_macos.machine)",
"end": "$(compatibility_macos.end)",
"status": "$(compatibility_macos.status)"}},
"status": "$(compatibility_macos.status)"},
"compatibility_windows": {"start": "$(compatibility_windows.start)",
"machine": "$(compatibility_windows.machine)",
"end": "$(compatibility_windows.end)",
"status": "$(compatibility_windows.status)"}},
"id": "$(Build.BuildId)",
"url": "https://dev.azure.com/digitalasset/daml/_build/results?buildId=$(Build.BuildId)",
"name": "$(Build.DefinitionName)",

View File

@ -12,25 +12,35 @@ def _client_server_test_impl(ctx):
output = wrapper,
content = """#!/usr/bin/env bash
set -eou pipefail
canonicalize_rlocation() {{
# Note (MK): This is a fun one: Lets say $TEST_WORKSPACE is "compatibility"
# and the argument points to a target from an external workspace, e.g.,
# @daml-sdk-0.0.0//:daml. Then the short path will point to
# ../daml-sdk-0.0.0/daml. Putting things together we end up with
# compatibility/../daml-sdk-0.0.0/daml. On Linux and MacOS this works
# just fine. However, on windows we need to normalize the path
# or rlocation will fail to find the path in the manifest file.
rlocation $(realpath -L -s -m --relative-to=$PWD $TEST_WORKSPACE/$1)
}}
runner=$(rlocation "$TEST_WORKSPACE/{runner}")
runner=$(canonicalize_rlocation "{runner}")
runner_args="{runner_args}"
client=$(rlocation "$TEST_WORKSPACE/{client}")
server=$(rlocation "$TEST_WORKSPACE/{server}")
client=$(canonicalize_rlocation "{client}")
server=$(canonicalize_rlocation "{server}")
server_args="{server_args}"
for file in {server_files}; do
server_args+=" $(rlocation $TEST_WORKSPACE/$file)"
server_args+=" $(canonicalize_rlocation $file)"
done
client_args="$@"
if [ -z "$client_args" ]; then
client_args="{client_args}"
for file in {client_files}; do
client_args+=" $(rlocation $TEST_WORKSPACE/$file)"
client_args+=" $(canonicalize_rlocation $file)"
done
fi
$runner "$client" "$client_args" "$server" "$server_args" "$runner_args"
$runner $client "$client_args" $server "$server_args" "$runner_args"
""".format(
runner = ctx.executable.runner.short_path,
runner_args = _expand_args(ctx, ctx.attr.runner_args),

View File

@ -0,0 +1,26 @@
# Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
parameters:
- name: test_flags
type: string
default: ''
steps:
- bash: ci/configure-bazel.sh
displayName: 'Configure Bazel for root workspace'
env:
IS_FORK: $(System.PullRequest.IsFork)
# to upload to the bazel cache
GOOGLE_APPLICATION_CREDENTIALS_CONTENT: $(GOOGLE_APPLICATION_CREDENTIALS_CONTENT)
- bash: ci/configure-bazel.sh
displayName: 'Configure Bazel for compatibility workspace'
env:
BAZEL_CONFIG_DIR: compatibility
IS_FORK: $(System.PullRequest.IsFork)
# to upload to the bazel cache
GOOGLE_APPLICATION_CREDENTIALS_CONTENT: $(GOOGLE_APPLICATION_CREDENTIALS_CONTENT)
- powershell: '.\compatibility\build-release-artifacts-windows.ps1'
displayName: 'Build release artifacts'
- powershell: '.\compatibility\test-windows.ps1 ${{ parameters.test_flags }}'
displayName: 'Run tests'

View File

@ -31,8 +31,6 @@ jobs:
pool: 'linux-pool'
macos:
pool: 'macOS-pool'
# windows:
# pool: 'windows-pool'
pool:
name: $(pool)
steps:
@ -54,3 +52,26 @@ jobs:
$(Slack.team-daml)
displayName: report
condition: always()
- job: compatibility_windows
timeoutInMinutes: 240
pool:
name: windows-pool
steps:
- checkout: self
- template: ../compatibility-windows.yml
- bash: |
set -euo pipefail
COMMIT_TITLE=$(git log --pretty=format:%s -n1)
COMMIT_LINK="<https://dev.azure.com/digitalasset/daml/_build/results?buildId=$(Build.BuildId)|$COMMIT_TITLE>"
if [ "$(Agent.JobStatus)" != "Succeeded" ]; then
MESSAGE=":fire: <!here> :fire: :fire:\n$(Agent.JobName) *FAILED*: $COMMIT_LINK\n:fire: :fire:"
else
MESSAGE="$(Agent.JobName) passed: $COMMIT_LINK"
fi
curl -XPOST \
-i \
-H 'Content-type: application/json' \
--data "{\"text\":\"$MESSAGE\n\"}" \
$(Slack.team-daml)
displayName: report
condition: always()

View File

@ -1 +0,0 @@
../.bazelrc

View File

@ -49,7 +49,7 @@ platform_versions = [
)
for sdk_version in sdk_versions
for platform_version in platform_versions
] if not is_windows else None
]
test_suite(
name = "head-quick",

View File

@ -12,7 +12,7 @@ load("@daml//bazel_tools:os_info.bzl", "os_info")
os_info(name = "os_info")
load("@os_info//:os_info.bzl", "is_linux", "os_name")
load("@os_info//:os_info.bzl", "is_darwin", "is_linux", "is_windows", "os_name")
load("@daml//bazel_tools:build_environment.bzl", "build_environment")
build_environment(name = "build_environment")
@ -25,10 +25,22 @@ load("@rules_haskell//haskell:repositories.bzl", "rules_haskell_dependencies")
rules_haskell_dependencies()
load("@daml//bazel_tools/dev_env_tool:dev_env_tool.bzl", "dadew", "dev_env_tool")
dadew(name = "dadew")
load("@daml//bazel_tools/dev_env_tool:dev_env_tool.bzl", "dadew_sh_posix_configure")
dadew_sh_posix_configure() if is_windows else None
load(
"@rules_haskell//haskell:nixpkgs.bzl",
"haskell_register_ghc_nixpkgs",
)
load(
"@rules_haskell//haskell:ghc_bindist.bzl",
"haskell_register_ghc_bindists",
)
load(
"@io_tweag_rules_nixpkgs//nixpkgs:nixpkgs.bzl",
"nixpkgs_cc_configure",
@ -88,6 +100,11 @@ filegroup(
repositories = dev_env_nix_repos,
) if is_linux else None
haskell_register_ghc_bindists(
compiler_flags = [],
version = "8.6.5",
) if is_windows else None
haskell_register_ghc_nixpkgs(
attribute_path = "ghcStatic",
build_file = "@io_tweag_rules_nixpkgs//nixpkgs:BUILD.pkg",
@ -126,6 +143,20 @@ nixpkgs_package(
repositories = dev_env_nix_repos,
)
dev_env_tool(
name = "openssl_dev_env",
nix_include = ["bin/openssl"],
nix_label = "@openssl_nix",
nix_paths = ["bin/openssl"],
tools = ["openssl"],
win_include = [
"usr/bin",
"usr/ssl",
],
win_paths = ["usr/bin/openssl.exe"],
win_tool = "msys2",
)
nixpkgs_package(
name = "hlint_nix",
attribute_path = "hlint",
@ -156,6 +187,7 @@ daml_sdk(
sdk_sha256 = {
"linux": "ee7e2f50394d44fb3490068de64d37f4f87534e802717bd7e07e8767df2e4e05",
"macos": "feb2086a9a01048300270c71eb212c8541cdec1082f541408250d6124bc307a8",
"windows": "2028efe1f505c1994e1abc41c0fb5181669cd46834818aa8276d04b0fb6eb034",
},
test_tool_sha256 = "cf66efafd9490e1256e825f377b208b8ae90151f56e411b596fbaaef91353e14",
version = "1.0.0",
@ -166,6 +198,7 @@ daml_sdk(
sdk_sha256 = {
"linux": "aaf832ceda1a66a8469460d5a4b6c14f681ce692d4e9ef6010896febbaf4b6e1",
"macos": "c2f89e394332b6ff19f547ccb399bacd3cd50d2493249c2d3a1ecaad0b87ac8b",
"windows": "7033ef0c5cbe75910a27730643076d3919b5694f3dc75f8daa57d5c22d04c593",
},
test_tool_sha256 = "762cd4836a8359dca0fb3271ba2e1d0629138f7d8d914298324418a174c5d22a",
version = "1.0.1-snapshot.20200417.3908.1.722bac90",
@ -176,6 +209,7 @@ daml_sdk(
sdk_sha256 = {
"linux": "d3bddaa903ebaebb6f714a3ac39598ba7fd71e8b80636c1275054ed7b883a0d9",
"macos": "66f1713057800ed75db1b967a8ea2d9b6c18da1a76b8224abdec0d33ed5533ae",
"windows": "2c779776d923d990870fbb2aa1c71e6081258a9b9ccc7cf8242c419a765d4821",
},
test_tool_sha256 = "649ecf7a7e98caef7dac20082526444b33d85dfe79b4b9b66d069ad67aac74fa",
version = "1.1.0-snapshot.20200422.3991.0.6391ee9f",

View File

@ -15,11 +15,12 @@ load("@bazel_skylib//lib:dicts.bzl", "dicts")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@os_info//:os_info.bzl", "is_windows")
load("@rules_haskell//haskell:cabal.bzl", "stack_snapshot")
load("@dadew//:dadew.bzl", "dadew_tool_home")
def daml_haskell_deps():
"""Load all Haskell dependencies of the DAML repository."""
use_integer_simple = True
use_integer_simple = not is_windows
stack_snapshot(
name = "stackage",
@ -56,7 +57,16 @@ def daml_haskell_deps():
"tasty-hunit",
"text",
] + (["unix"] if not is_windows else ["Win32"]),
stack = None,
stack = "@stack_windows//:stack.exe" if is_windows else None,
tools = [
],
)
if is_windows:
native.new_local_repository(
name = "stack_windows",
build_file_content = """
exports_files(["stack.exe"], visibility = ["//visibility:public"])
""",
path = dadew_tool_home("stack"),
)

View File

@ -64,23 +64,23 @@ genrule(
cmd = """
set -eou pipefail
# Generate CA key and crt
$(location @openssl_nix//:bin/openssl) genrsa -out $(location ca.key) 4096
$(location @openssl_nix//:bin/openssl) req -new -x509 -key $(location ca.key) -out $(location ca.crt) -subj '/CN=0.0.0.0.ca' -days 3650
$(location @openssl_dev_env//:openssl) genrsa -out $(location ca.key) 4096
$(location @openssl_dev_env//:openssl) req -new -x509 -key $(location ca.key) -out $(location ca.crt) -subj '/CN=0.0.0.0.ca' -days 3650
# Generate server key, csr and crt
$(location @openssl_nix//:bin/openssl) genrsa -out $(location server.key) 4096
$(location @openssl_nix//:bin/openssl) pkey -in $(location server.key) -out $(location server.pem)
$(location @openssl_nix//:bin/openssl) req -new -key $(location server.key) -out $(location server.csr) -subj '/CN=0.0.0.0.server'
$(location @openssl_nix//:bin/openssl) x509 -req -in $(location server.csr) -CA $(location ca.crt) -CAkey $(location ca.key) -CAcreateserial -out $(location server.crt) -extfile $(location openssl-extensions.cnf) -extensions req_ext -days 3650
$(location @openssl_dev_env//:openssl) genrsa -out $(location server.key) 4096
$(location @openssl_dev_env//:openssl) pkey -in $(location server.key) -out $(location server.pem)
$(location @openssl_dev_env//:openssl) req -new -key $(location server.key) -out $(location server.csr) -subj '/CN=0.0.0.0.server'
$(location @openssl_dev_env//:openssl) x509 -req -in $(location server.csr) -CA $(location ca.crt) -CAkey $(location ca.key) -CAcreateserial -out $(location server.crt) -extfile $(location openssl-extensions.cnf) -extensions req_ext -days 3650
# Generate client key, csr and crt
$(location @openssl_nix//:bin/openssl) genrsa -out $(location client.key) 4096
$(location @openssl_nix//:bin/openssl) pkey -in $(location client.key) -out $(location client.pem)
$(location @openssl_nix//:bin/openssl) req -new -key $(location client.key) -out $(location client.csr) -subj '/CN=0.0.0.0.client'
$(location @openssl_nix//:bin/openssl) x509 -req -in $(location client.csr) -CA $(location ca.crt) -CAkey $(location ca.key) -CAcreateserial -out $(location client.crt) -extfile $(location openssl-extensions.cnf) -extensions req_ext -days 3650
$(location @openssl_dev_env//:openssl) genrsa -out $(location client.key) 4096
$(location @openssl_dev_env//:openssl) pkey -in $(location client.key) -out $(location client.pem)
$(location @openssl_dev_env//:openssl) req -new -key $(location client.key) -out $(location client.csr) -subj '/CN=0.0.0.0.client'
$(location @openssl_dev_env//:openssl) x509 -req -in $(location client.csr) -CA $(location ca.crt) -CAkey $(location ca.key) -CAcreateserial -out $(location client.crt) -extfile $(location openssl-extensions.cnf) -extensions req_ext -days 3650
""",
tools = [
"@openssl_nix//:bin/openssl",
"@openssl_dev_env//:openssl",
],
visibility = ["//visibility:public"],
)

View File

@ -1,6 +1,8 @@
# Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
load("@os_info//:os_info.bzl", "is_windows", "os_name")
runfiles_library = """
# Copy-pasted from the Bazel Bash runfiles library v2.
set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash
@ -14,21 +16,24 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
"""
def _daml_sdk_impl(ctx):
# The DAML assistant will mark the installed SDK read-only.
# This breaks Bazel horribly on Windows to the point where
# even `bazel clean --expunge` fails because it cannot remove
# the installed SDK. Therefore, we do not use the assistant to
# install the SDK but instead simply extract the SDK to the right
# location and set the symlink ourselves.
out_dir = ctx.path("sdk").get_child("sdk").get_child(ctx.attr.version)
if ctx.attr.sdk_tarball:
ctx.extract(
ctx.attr.sdk_tarball,
output = "extracted-sdk",
output = out_dir,
stripPrefix = "sdk-{}".format(ctx.attr.version),
)
elif ctx.attr.sdk_sha256:
ctx.download_and_extract(
output = "extracted-sdk",
# TODO (MK) Make this work on other platforms.
url = "https://github.com/digital-asset/daml/releases/download/v{version}/daml-sdk-{version}-{os}.tar.gz"
.format(
version = ctx.attr.version,
os = ctx.attr.os_name,
),
output = out_dir,
url =
"https://github.com/digital-asset/daml/releases/download/v{}/daml-sdk-{}-{}.tar.gz".format(ctx.attr.version, ctx.attr.version, ctx.attr.os_name),
sha256 = ctx.attr.sdk_sha256[ctx.attr.os_name],
stripPrefix = "sdk-{}".format(ctx.attr.version),
)
@ -50,19 +55,8 @@ def _daml_sdk_impl(ctx):
"ledger-api-test-tool.jar",
output = "extracted-test-tool",
)
ps_result = ctx.execute(
["extracted-sdk/daml/daml", "install", "extracted-sdk", "--install-assistant=no"],
environment = {
"DAML_HOME": "sdk",
},
)
if ps_result.return_code != 0:
fail("Failed to install SDK.\nExit code %d.\n%s\n%s" %
(ps_result.return_code, ps_result.stdout, ps_result.stderr))
# At least on older SDKs, the symlinking in --install-assistant=yes does not work
# properly so we symlink ourselves.
ctx.symlink("sdk/sdk/{}/daml/daml".format(ctx.attr.version), "sdk/bin/daml")
ctx.symlink(out_dir.get_child("daml").get_child("daml" + (".exe" if is_windows else "")), "sdk/bin/daml")
ctx.file(
"sdk/daml-config.yaml",
content =
@ -121,11 +115,11 @@ _daml_sdk = repository_rule(
implementation = _daml_sdk_impl,
attrs = {
"version": attr.string(mandatory = True),
"os_name": attr.string(mandatory = False, default = os_name),
"sdk_sha256": attr.string_dict(mandatory = False),
"sdk_tarball": attr.label(allow_single_file = True, mandatory = False),
"test_tool_sha256": attr.string(mandatory = False),
"test_tool": attr.label(allow_single_file = True, mandatory = False),
"os_name": attr.string(mandatory = True),
},
)

View File

@ -15,4 +15,12 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
set -eou pipefail
version=$1
extra_args="${@:2}"
$(rlocation compatibility/bazel_tools/client_server/with-postgres) $(rlocation daml-sdk-$version/daml) sandbox $extra_args
WITH_POSTGRES=$(rlocation compatibility/bazel_tools/client_server/with-postgres)
if [ -z "$WITH_POSTGRES" ]; then
WITH_POSTGRES=$(rlocation compatibility/bazel_tools/client_server/with-postgres.exe)
fi
if [ -z "$WITH_POSTGRES" ]; then
echo "Faild to find with-postgres wrapper"
exit 1
fi
$WITH_POSTGRES $(rlocation daml-sdk-$version/daml) sandbox $extra_args

View File

@ -5,6 +5,7 @@ load(
"@daml//bazel_tools/client_server:client_server_test.bzl",
"client_server_test",
)
load("@os_info//:os_info.bzl", "is_windows")
latest_stable = "1.0.0"
@ -168,7 +169,9 @@ def sdk_platform_test(sdk_version, platform_version):
dar_files = dar_files,
)],
tags = ["exclusive"] + extra_tags(sdk_version, platform_version),
)
) if not is_windows else None
# We disable the postgres tests on Windows for now since our postgres setup
# relies on Nix. This should be fixable by getting postgres from dev-env.
# daml-ledger test-cases
name = "daml-ledger-{sdk_version}-platform-{platform_version}".format(
@ -181,4 +184,5 @@ def sdk_platform_test(sdk_version, platform_version):
daml = daml_assistant,
sandbox = sandbox,
sandbox_args = sandbox_args,
tags = extra_tags(sdk_version, platform_version),
)

View File

@ -0,0 +1,44 @@
Set-StrictMode -Version latest
$ErrorActionPreference = 'Stop'
# Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# Build the release artifacts required for running the compatibility
# tests against HEAD. At the moment this includes the SDK release tarball
# and the ledger-api-test-tool fat JAR.
# See https://github.com/lukesampson/scoop/issues/3859
Set-Strictmode -Off
.\dev-env\windows\bin\dadew.ps1 install
Set-StrictMode -Version latest
.\dev-env\windows\bin\dadew.ps1 sync
.\dev-env\windows\bin\dadew.ps1 enable
if (Test-Path -Path $env:appdata\stack\pantry\hackage\hackage-security-lock) {
Write-Output ">> Nuking stack directory"
Remove-Item -ErrorAction Continue -Force -Recurse -Path $env:appdata\stack
}
function bazel() {
Write-Output ">> bazel $args"
$global:lastexitcode = 0
$backupErrorActionPreference = $script:ErrorActionPreference
$script:ErrorActionPreference = "Continue"
& bazel.exe @args 2>&1 | %{ "$_" }
$script:ErrorActionPreference = $backupErrorActionPreference
if ($global:lastexitcode -ne 0 -And $args[0] -ne "shutdown") {
Write-Output "<< bazel $args (failed, exit code: $global:lastexitcode)"
throw ("Bazel returned non-zero exit code: $global:lastexitcode")
}
Write-Output "<< bazel $args (ok)"
}
bazel shutdown
bazel fetch @nodejs_dev_env//...
bazel build `
//release:sdk-release-tarball `
//ledger/ledger-api-test-tool:ledger-api-test-tool_deploy.jar
cp -Force bazel-bin\release\sdk-release-tarball.tar.gz compatibility/head_sdk
cp -Force bazel-bin\ledger\ledger-api-test-tool\ledger-api-test-tool_deploy.jar compatibility/head_sdk

View File

@ -36,6 +36,12 @@ def daml_deps():
name = "rules_haskell",
strip_prefix = "rules_haskell-%s" % rules_haskell_version,
urls = ["https://github.com/tweag/rules_haskell/archive/%s.tar.gz" % rules_haskell_version],
patches = [
"@daml//bazel_tools:haskell-strict-source-names.patch",
"@daml//bazel_tools:haskell-windows-remove-fake-libs.patch",
"@daml//bazel_tools:haskell-windows-extra-libraries.patch",
],
patch_args = ["-p1"],
sha256 = rules_haskell_sha256,
)

View File

@ -0,0 +1,51 @@
Set-StrictMode -Version latest
$ErrorActionPreference = 'Stop'
# Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# Build the release artifacts required for running the compatibility
# tests against HEAD. At the moment this includes the SDK release tarball
# and the ledger-api-test-tool fat JAR.
$test_args = "//..."
if (($args.length -ge 1) -and ($args[0] -eq "--quick")) {
$test_args = "//:head-quick"
}
write-output $test_args
# For reasons I do not understand, it seems to be important
# to sync here even though we sync in the previous step already.
.\dev-env\windows\bin\dadew.ps1 sync
.\dev-env\windows\bin\dadew.ps1 enable
if (Test-Path -Path $env:appdata\stack\pantry\hackage\hackage-security-lock) {
Write-Output ">> Nuking stack directory"
Remove-Item -ErrorAction Continue -Force -Recurse -Path $env:appdata\stack
}
# This is currently shared between various powershell scripts.
# We should probably factor this out.
function bazel() {
Write-Output ">> bazel $args"
$global:lastexitcode = 0
$backupErrorActionPreference = $script:ErrorActionPreference
$script:ErrorActionPreference = "Continue"
& bazel.exe @args 2>&1 | %{ "$_" }
$script:ErrorActionPreference = $backupErrorActionPreference
if ($global:lastexitcode -ne 0 -And $args[0] -ne "shutdown") {
Write-Output "<< bazel $args (failed, exit code: $global:lastexitcode)"
throw ("Bazel returned non-zero exit code: $global:lastexitcode")
}
Write-Output "<< bazel $args (ok)"
}
cd compatibility
# Symlinks dont work on Windows.
cp ../.bazelrc .bazelrc
bazel shutdown
bazel build //...
bazel shutdown
bazel test "$test_args"

View File

@ -13,6 +13,11 @@ cd "$(dirname "$0")"
eval "$(../dev-env/bin/dade-assist)"
# Git, symlinks and windows do not play well together
# so we have to copy over the Bazel config. We just do
# it unconditionally since it should be cheap enough.
cp ../.bazelrc .bazelrc
bazel build //...
if [ "${1:-}" = "--quick" ]; then
bazel test //:head-quick