# Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 load( "//bazel_tools:scala.bzl", "da_scala_binary", "da_scala_library", "da_scala_test_suite", "silencer_plugin", ) load("@build_environment//:configuration.bzl", "sdk_version") DAML_LF_VERSIONS = [ "1.dev", "", # SDK default ] [ genrule( name = "acs" + suffix, srcs = glob(["**/*.daml"]) + [ "//triggers/daml:daml-trigger%s.dar" % suffix, "//daml-script/daml:daml-script%s.dar" % suffix, ] + [ "//templates:copy-trigger/src/CopyTrigger.daml", ], outs = ["acs%s.dar" % suffix], cmd = """ set -eou pipefail TMP_DIR=$$(mktemp -d) mkdir -p $$TMP_DIR/daml cp -L $(location :daml/ACS.daml) $$TMP_DIR/daml cp -L $(location :daml/Retry.daml) $$TMP_DIR/daml cp -L $(location :daml/ExerciseByKey.daml) $$TMP_DIR/daml cp -L $(location :daml/CreateAndExercise.daml) $$TMP_DIR/daml cp -L $(location :daml/MaxInboundMessageTest.daml) $$TMP_DIR/daml cp -L $(location :daml/Numeric.daml) $$TMP_DIR/daml cp -L $(location :daml/CommandId.daml) $$TMP_DIR/daml cp -L $(location :daml/PendingSet.daml) $$TMP_DIR/daml cp -L $(location :daml/TemplateIdFilter.daml) $$TMP_DIR/daml cp -L $(location :daml/Time.daml) $$TMP_DIR/daml cp -L $(location :daml/Heartbeat.daml) $$TMP_DIR/daml cp -L $(location :daml/ReadAs.daml) $$TMP_DIR/daml cp -L $(location //templates:copy-trigger/src/CopyTrigger.daml) $$TMP_DIR/daml cp -L $(location //triggers/daml:daml-trigger{suffix}.dar) $$TMP_DIR/daml-trigger.dar cp -L $(location //daml-script/daml:daml-script{suffix}.dar) $$TMP_DIR/daml-script.dar if [ "{lf_version}" = "1.dev" ] then cp -L $(location :daml/Interface.daml) $$TMP_DIR/daml fi cat << EOF > $$TMP_DIR/daml.yaml sdk-version: {sdk} name: acs source: daml version: 0.0.1 dependencies: - daml-stdlib - daml-prim - daml-trigger.dar - daml-script.dar EOF test -z "{lf_version}" || echo "build-options: [--target={lf_version}]" >> $$TMP_DIR/daml.yaml $(location //compiler/damlc) build --project-root=$$TMP_DIR --ghc-option=-Werror -o $$PWD/$(location acs{suffix}.dar) rm -rf $$TMP_DIR """.format( sdk = sdk_version, lf_version = lf_version, suffix = suffix, ), tools = ["//compiler/damlc"], visibility = ["//visibility:public"], ) for lf_version in DAML_LF_VERSIONS for suffix in [("-" + lf_version) if lf_version else ""] ] da_scala_library( name = "test-utils", srcs = [ "src/test/scala/com/digitalasset/daml/lf/engine/trigger/test/AbstractFuncTests.scala", "src/test/scala/com/digitalasset/daml/lf/engine/trigger/test/AbstractTriggerTest.scala", ], plugins = [ silencer_plugin, ], scala_deps = [ "@maven//:com_typesafe_akka_akka_stream", "@maven//:org_scala_lang_modules_scala_collection_compat", "@maven//:org_scalactic_scalactic", "@maven//:org_scalatest_scalatest_core", "@maven//:org_scalatest_scalatest_matchers_core", "@maven//:org_scalatest_scalatest_shouldmatchers", "@maven//:org_scalatest_scalatest_wordspec", "@maven//:org_scalaz_scalaz_core", ], deps = [ "//bazel_tools/runfiles:scala_runfiles", "//daml-lf/archive:daml_lf_archive_reader", "//daml-lf/data", "//daml-lf/interpreter", "//daml-lf/language", "//daml-lf/transaction", "//language-support/scala/bindings", "//language-support/scala/bindings-akka", "//ledger-api/rs-grpc-bridge", "//ledger-api/testing-utils", "//ledger/ledger-api-auth", "//ledger/ledger-api-common", "//ledger/ledger-api-domain", "//ledger/ledger-resources", "//ledger/sandbox", "//ledger/sandbox:sandbox-scala-tests-lib", "//ledger/sandbox-common", "//ledger/sandbox-common:sandbox-common-scala-tests-lib", "//ledger/test-common", "//libs-scala/contextualized-logging", "//libs-scala/ports", "//libs-scala/resources", "//triggers/runner:trigger-runner-lib", "@maven//:org_scalatest_scalatest_compatible", ], ) [ da_scala_test_suite( name = "trigger-integration-tests" + suffix, srcs = [ "src/test/scala/com/digitalasset/daml/lf/engine/trigger/test/%s.scala" % f for f in [ "FuncTestsStaticTime", "FuncTestsWallClock", "Jwt", "Tls", "RunnerSpec", "UnfoldStateSpec", ] + (["DevOnly"] if lf_version else []) ], data = [ ":acs%s.dar" % suffix, "//ledger/test-common/test-certificates", ], resources = ["//triggers/runner:src/main/resources/logback.xml"], scala_deps = [ "@maven//:com_typesafe_akka_akka_stream", "@maven//:org_scalacheck_scalacheck", "@maven//:org_scalatestplus_scalacheck_1_15", "@maven//:org_scalaz_scalaz_core", ], deps = [ ":test-utils", "//bazel_tools/runfiles:scala_runfiles", "//daml-lf/archive:daml_lf_archive_reader", "//daml-lf/data", "//daml-lf/interpreter", "//daml-lf/language", "//language-support/scala/bindings", "//language-support/scala/bindings-akka", "//ledger-api/rs-grpc-bridge", "//ledger-api/testing-utils", "//ledger/caching", "//ledger/ledger-api-auth", "//ledger/ledger-api-common", "//ledger/ledger-api-domain", "//ledger/ledger-configuration", "//ledger/ledger-resources", "//ledger/participant-integration-api", "//ledger/sandbox:sandbox-scala-tests-lib", "//ledger/sandbox-common", "//ledger/sandbox-common:sandbox-common-scala-tests-lib", "//ledger/test-common", "//libs-scala/ports", "//libs-scala/resources", "//libs-scala/scalatest-utils", "//triggers/runner:trigger-runner-lib", ], ) for lf_version in DAML_LF_VERSIONS for suffix in [("-" + lf_version) if lf_version else ""] ]