From 2afefb78833ee2f1b103f1335b853b8dc74f4629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Majcherski?= <43614029+majcherm-da@users.noreply.github.com> Date: Fri, 28 Jun 2019 12:55:31 +0200 Subject: [PATCH] windows: root build (#1894) * windows: root build * windows: fixed haskell bindings tests * windows: disable client_server_test test * windows: marking daml_test flaky due to #1907 * windows: removing da-hs-damlc-app run from build.ps1 * windows: disable hie-core alias of currently disabled target --- BUILD | 3 +- .../client_server_test/tests/BUILD.bazel | 3 +- build.ps1 | 43 +------------------ daml-foundations/daml-ghc/util.bzl | 2 + docs/BUILD.bazel | 20 ++++++--- .../bindings/examples/group-chat/BUILD.bazel | 2 + .../hs/bindings/test/DA/Ledger/Tests.hs | 11 +++-- rules_daml/daml.bzl | 12 +++++- 8 files changed, 43 insertions(+), 53 deletions(-) diff --git a/BUILD b/BUILD index d282bd9e5bf3..79ac3208d2a8 100644 --- a/BUILD +++ b/BUILD @@ -9,6 +9,7 @@ load( "c2hs_toolchain", ) load("//bazel_tools:haskell.bzl", "da_haskell_library", "da_haskell_repl") +load("@os_info//:os_info.bzl", "is_windows") exports_files([".hlint.yaml"]) @@ -153,7 +154,7 @@ alias( alias( name = "hie-core", actual = "//compiler/hie-core:hie-core-exe", -) +) if not is_windows else None # Disable on Windows until ghc-paths is fixed upstream alias( name = "daml-lf-repl", diff --git a/bazel_tools/client_server_test/tests/BUILD.bazel b/bazel_tools/client_server_test/tests/BUILD.bazel index 31aa9d075620..6ff2beda6a55 100644 --- a/bazel_tools/client_server_test/tests/BUILD.bazel +++ b/bazel_tools/client_server_test/tests/BUILD.bazel @@ -9,6 +9,7 @@ load( "//bazel_tools:scala.bzl", "da_scala_binary", ) +load("@os_info//:os_info.bzl", "is_windows") sh_binary( name = "client", @@ -41,4 +42,4 @@ client_server_test( ":client_input_file", ], server = ":server", -) +) if not is_windows else None diff --git a/build.ps1 b/build.ps1 index c8a46342a45c..2c6536319f34 100644 --- a/build.ps1 +++ b/build.ps1 @@ -30,47 +30,8 @@ function bazel() { # which is a workaround for this problem. bazel shutdown -# FIXME: Until all bazel issues on Windows are resolved we will be testing only specific bazel targets -bazel build `-`-experimental_execution_log_file ${ARTIFACT_DIRS}/build_execution_windows.log ` - //:git-revision ` - @com_github_grpc_grpc//:grpc ` - @haskell_c2hs//... ` - //3rdparty/... ` - //compiler/... ` - //daml-assistant/... ` - //daml-foundations/... ` - //daml-lf/... ` - //extractor/... ` - //hazel/... ` - //language-support/... ` - //ledger/... ` - //ledger-api/... ` - //libs-haskell/... ` - //navigator/... ` - //nix/... ` - //notices-gen/... ` - //release/... ` - //rules_daml/... ` - //scala-protoc-plugins/... ` - //templates/... +bazel build `-`-experimental_execution_log_file ${ARTIFACT_DIRS}/build_execution_windows.log //... bazel shutdown -bazel run ` - //daml-foundations/daml-tools/da-hs-damlc-app `-`- `-h - -bazel shutdown - -bazel test `-`-experimental_execution_log_file ${ARTIFACT_DIRS}/test_execution_windows.log ` - //compiler/... ` - //daml-lf/... ` - //extractor/... ` - //language-support/codegen-common/... ` - //language-support/java/... ` - //language-support/scala/... ` - //ledger/... ` - //ledger-api/... ` - //libs-haskell/... ` - //navigator/... ` - //daml-assistant/... ` - //daml-foundations/... +bazel test `-`-experimental_execution_log_file ${ARTIFACT_DIRS}/test_execution_windows.log //... diff --git a/daml-foundations/daml-ghc/util.bzl b/daml-foundations/daml-ghc/util.bzl index 119626f399b2..1339f153e54a 100644 --- a/daml-foundations/daml-ghc/util.bzl +++ b/daml-foundations/daml-ghc/util.bzl @@ -7,6 +7,8 @@ def _daml_ghc_compile_test_impl(ctx): stack_opt = "-K" + ctx.attr.stack_limit if ctx.attr.stack_limit else "" heap_opt = "-M" + ctx.attr.heap_limit if ctx.attr.heap_limit else "" script = """ + set -eou pipefail + DAMLC=$(rlocation $TEST_WORKSPACE/{damlc}) MAIN=$(rlocation $TEST_WORKSPACE/{main}) diff --git a/docs/BUILD.bazel b/docs/BUILD.bazel index 00bd9f5f7fea..f3038f0ac3cd 100644 --- a/docs/BUILD.bazel +++ b/docs/BUILD.bazel @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary") -load("@os_info//:os_info.bzl", "is_linux") +load("@os_info//:os_info.bzl", "is_linux", "is_windows") load("//rules_daml:daml.bzl", "daml_test") load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar") @@ -73,7 +73,7 @@ genrule( ":grunt", "@sass_nix//:bin/sass", ], -) +) if not is_windows else None genrule( name = "sources", @@ -146,7 +146,7 @@ genrule( "@sphinx_nix//:bin/sphinx-build", "@imagemagick_nix//:bin/convert", ] + (["@glibc_locales//:locale-archive"] if is_linux else []), -) +) if not is_windows else None genrule( name = "docs-no-pdf", @@ -199,7 +199,7 @@ genrule( tools = ["@sphinx_nix//:bin/sphinx-build"] + (["@glibc_locales//:locale-archive"] if is_linux else []), -) +) if not is_windows else None genrule( name = "redirects", @@ -258,7 +258,7 @@ genrule( """%LOC%%DATE%daily0.8""", """""", ), -) +) if not is_windows else None filegroup( name = "daml-assistant-iou-setup", @@ -325,52 +325,62 @@ java_binary( daml_test( name = "ledger-api-daml-test", srcs = glob(["source/app-dev/code-snippets/**/*.daml"]), + flaky = is_windows, # https://github.com/digital-asset/daml/issues/1907 ) daml_test( name = "bindings-java-daml-test", srcs = glob(["source/app-dev/bindings-java/code-snippets/**/*.daml"]), + flaky = is_windows, # https://github.com/digital-asset/daml/issues/1907 ) daml_test( name = "patterns-daml-test", srcs = glob(["source/daml/patterns/daml/**/*.daml"]), + flaky = is_windows, # https://github.com/digital-asset/daml/issues/1907 ) daml_test( name = "daml-studio-daml-test", srcs = glob(["source/daml/daml-studio/daml/**/*.daml"]), + flaky = is_windows, # https://github.com/digital-asset/daml/issues/1907 ) daml_test( name = "daml-ref-daml-test", timeout = "long", srcs = glob(["source/daml/code-snippets/**/*.daml"]), + flaky = is_windows, # https://github.com/digital-asset/daml/issues/1907 ) daml_test( name = "introduction-daml-test", srcs = glob(["source/getting-started/introduction/code/**/*.daml"]), + flaky = is_windows, # https://github.com/digital-asset/daml/issues/1907 ) daml_test( name = "quickstart-daml-test", srcs = glob(["source/getting-started/quickstart/template-root/daml/**/*.daml"]), + flaky = is_windows, # https://github.com/digital-asset/daml/issues/1907 ) daml_test( name = "ledger-model-daml-test", srcs = glob(["source/concepts/ledger-model/daml/**/*.daml"]), + flaky = is_windows, # https://github.com/digital-asset/daml/issues/1907 ) daml_test( name = "java-bindings-docs-daml-test", srcs = glob(["source/app-dev/bindings-java/daml/**/*.daml"]), + flaky = is_windows, # https://github.com/digital-asset/daml/issues/1907 ) daml_test( name = "daml-intro-daml-test", srcs = glob(["source/daml/intro/daml/**/*.daml"]), + flaky = is_windows, # https://github.com/digital-asset/daml/issues/1907 ) filegroup( diff --git a/language-support/hs/bindings/examples/group-chat/BUILD.bazel b/language-support/hs/bindings/examples/group-chat/BUILD.bazel index 9b37fde421c2..9d33f37cd756 100644 --- a/language-support/hs/bindings/examples/group-chat/BUILD.bazel +++ b/language-support/hs/bindings/examples/group-chat/BUILD.bazel @@ -3,6 +3,7 @@ load("//bazel_tools:haskell.bzl", "da_haskell_binary", "da_haskell_library", "da_haskell_test") load("//rules_daml:daml.bzl", "daml_compile", "daml_test") +load("@os_info//:os_info.bzl", "is_windows") daml_compile( name = "GroupChat", @@ -13,4 +14,5 @@ daml_compile( daml_test( name = "GroupChat-test", srcs = glob(["daml/GroupChat.daml"]), + flaky = is_windows, # https://github.com/digital-asset/daml/issues/1907 ) diff --git a/language-support/hs/bindings/test/DA/Ledger/Tests.hs b/language-support/hs/bindings/test/DA/Ledger/Tests.hs index 754950442a5f..82ca243faac6 100644 --- a/language-support/hs/bindings/test/DA/Ledger/Tests.hs +++ b/language-support/hs/bindings/test/DA/Ledger/Tests.hs @@ -8,6 +8,7 @@ module DA.Ledger.Tests (main) where import Control.Concurrent (MVar,newMVar,takeMVar,withMVar) import Control.Monad(unless) import Control.Monad.IO.Class(liftIO) +import DA.Bazel.Runfiles import DA.Daml.LF.Proto3.Archive (decodeArchive) import DA.Daml.LF.Reader(ManifestData(..),manifestFromDar) import DA.Ledger.Sandbox (Sandbox,SandboxSpec(..),startSandbox,shutdownSandbox,withSandbox) @@ -16,6 +17,7 @@ import Data.Text.Lazy (Text) import System.Environment.Blank (setEnv) import System.Random (randomIO) import System.Time.Extra (timeout) +import System.FilePath import Test.Tasty as Tasty (TestName,TestTree,testGroup,withResource,defaultMain) import Test.Tasty.HUnit as Tasty(assertFailure,assertBool,assertEqual,testCase) import qualified Codec.Archive.Zip as Zip @@ -295,9 +297,10 @@ assertTextContains text frag = enableSharing :: Bool enableSharing = True -specQuickstart :: SandboxSpec -specQuickstart = SandboxSpec {dar} - where dar = "language-support/hs/bindings/quickstart.dar" +createSpecQuickstart :: IO SandboxSpec +createSpecQuickstart = do + dar <- locateRunfiles (mainWorkspace "language-support/hs/bindings/quickstart.dar") + return SandboxSpec {dar} testGroupWithSandbox :: TestName -> [WithSandbox -> TestTree] -> TestTree testGroupWithSandbox name tests = @@ -309,6 +312,7 @@ testGroupWithSandbox name tests = else do -- runs in it's own freshly (and very slowly!) spun-up sandbox let withSandbox' f = do + specQuickstart <- createSpecQuickstart pid <- mainPackageId specQuickstart withSandbox specQuickstart $ \sandbox -> f sandbox pid testGroup name $ map (\f -> f withSandbox') tests @@ -330,6 +334,7 @@ data SharedSandbox = SharedSandbox (MVar (Sandbox, PackageId)) acquireShared :: IO SharedSandbox acquireShared = do + specQuickstart <- createSpecQuickstart sandbox <- startSandbox specQuickstart pid <- mainPackageId specQuickstart mv <- newMVar (sandbox, pid) diff --git a/rules_daml/daml.bzl b/rules_daml/daml.bzl index ae591c3fde97..cb57ff1175ae 100644 --- a/rules_daml/daml.bzl +++ b/rules_daml/daml.bzl @@ -104,8 +104,16 @@ daml_compile = rule( def _daml_test_impl(ctx): script = """ - {damlc} test --files {files} - """.format(damlc = ctx.executable.damlc.short_path, files = " ".join([f.short_path for f in ctx.files.srcs])) + set -eou pipefail + + DAMLC=$(rlocation $TEST_WORKSPACE/{damlc}) + rlocations () {{ for i in $@; do echo $(rlocation $TEST_WORKSPACE/$i); done; }} + + $DAMLC test --files $(rlocations "{files}") + """.format( + damlc = ctx.executable.damlc.short_path, + files = " ".join([f.short_path for f in ctx.files.srcs]), + ) ctx.actions.write( output = ctx.outputs.executable,