# Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 load("//bazel_tools:haskell.bzl", "da_haskell_binary", "da_haskell_library", "da_haskell_repl", "da_haskell_test") load("//rules_daml:daml.bzl", "daml_compile") load("@os_info//:os_info.bzl", "is_darwin") da_haskell_library( name = "hs-ledger", srcs = glob(["src/**/*.hs"]), hackage_deps = [ "aeson", "async", "base", "bytestring", "containers", "exceptions", "extra", "grpc-haskell", "grpc-haskell-core", "mtl", "proto3-suite", "retry", "sorted-list", "text", "time", "transformers", "unliftio", "utf8-string", "vector", ], visibility = ["//visibility:public"], deps = [ "//ledger-api/grpc-definitions:ledger-api-haskellpb", ], ) daml_compile( name = "for-tests", srcs = glob(["test/daml/for-tests/*.daml"]), ) daml_compile( name = "for-upload", srcs = ["test/daml/for-upload/ExtraModule.daml"], ) da_haskell_test( name = "test", srcs = glob(["test/**/*.hs"]), data = [ ":for-tests.dar", ":for-upload.dar", "//ledger/sandbox:sandbox-binary", ], # The tests throw flaky timeout errors. It looks like this comes # from a fundamental issue in the Haskell bindings: they eagerly pull # from streams and those stream receives have a timeout. If we create the # stream too early and do a bunch of other stuff in between, this will then timeout. # We could increase the timeout to an absurd value but that also seems silly # and affects other operations as well so for now, we still keep it flaky # and try not to cry. flaky = True, hackage_deps = [ "aeson", "async", "base", "bytestring", "containers", "filepath", "directory", "extra", "jwt", "process", "random", "retry", "safe", "tasty", "tasty-hunit", "text", "time", "utf8-string", "uuid", "vector", "zip-archive", ], main_function = "DA.Ledger.Tests.main", src_strip_prefix = "test", # We spin up Sandbox as a separate process, so # try not to overload the machine. tags = ["cpu:2"] + (["manual"] if is_darwin else []), visibility = ["//visibility:public"], deps = [ "//compiler/daml-lf-ast", "//compiler/daml-lf-proto", "//compiler/daml-lf-reader", "//language-support/hs/bindings:hs-ledger", "//libs-haskell/bazel-runfiles", "//libs-haskell/test-utils", ], ) da_haskell_repl( name = "repl", testonly = True, visibility = ["//visibility:public"], deps = [ "//language-support/hs/bindings:hs-ledger", "//language-support/hs/bindings:test", "//language-support/hs/bindings/examples/chat", "//language-support/hs/bindings/examples/nim", ], )