daml/compatibility/bazel_tools/create_daml_app_test.sh
Moritz Kiefer 34ae06414e
Speed-up create-daml-app compat tests (#6087)
Previously we ran `daml codegen js` and `daml build` in the tests and
we also ran it twice. While this makes sense for the SDK integration
tests, it doesn’t really make sense for the compatibility tests. These
are SDK-only features so they don’t actually test compatibility. These
steps are super slow and running them in the tests also means that we
run them a quadratic number of times.

This PR moves the `daml build` and the `daml codegen js` step to
separate genrules. In the actual test, the only expensive steps are to
run `yarn install` and the actual jest tests. In principle, we could
probably try to factor out the `yarn install` step as well but I’m a
bit scared of coyping around node_modules so I’ll not attempt to do
that for now.

changelog_begin
changelog_end
2020-05-25 16:25:10 +02:00

53 lines
2.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# Copy-pasted from the Bazel Bash runfiles library v2.
set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
source "$0.runfiles/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
{ echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
# --- end runfiles.bash initialization v2 ---
set -euo pipefail
canonicalize_rlocation() {
# Bazel will add a . at the beginning of locations in the root package
# which breaks rlocation.
rlocation $(realpath -L -s -m --relative-to=$PWD $TEST_WORKSPACE/$1)
}
RUNNER="$(rlocation "$TEST_WORKSPACE/$1")"
DAML="$(rlocation "$TEST_WORKSPACE/$2")"
# These things are only used in the jest tests so rather
# than adding a lot of boilerplate to the Haskell code
# to parse them only to pass them on, we simply set them here.
export DAML_SANDBOX="$(rlocation "$TEST_WORKSPACE/$3")"
export SANDBOX_VERSION="${4}"
export DAML_JSON_API="$(rlocation "$TEST_WORKSPACE/$5")"
export JSON_API_VERSION="${6}"
DAML_TYPES="$(rlocation "$TEST_WORKSPACE/$7")"
DAML_LEDGER="$(rlocation "$TEST_WORKSPACE/$8")"
DAML_REACT="$(rlocation "$TEST_WORKSPACE/$9")"
MESSAGING_PATCH="$(rlocation "$TEST_WORKSPACE/${10}")"
YARN="$(rlocation "$TEST_WORKSPACE/${11}")"
PATCH="$(rlocation "$TEST_WORKSPACE/${12}")"
TEST_DEPS="$(rlocation "$TEST_WORKSPACE/${13}")"
TEST_TS="$(rlocation "$TEST_WORKSPACE/${14}")"
CODEGEN_OUTPUT="$(canonicalize_rlocation "${15}")"
export DAR_PATH="$(canonicalize_rlocation "${16}")"
"$RUNNER" \
--daml "$DAML" \
--daml-types "$DAML_TYPES" \
--daml-ledger "$DAML_LEDGER" \
--daml-react "$DAML_REACT" \
--messaging-patch "$MESSAGING_PATCH" \
--yarn "$YARN" \
--patch "$PATCH" \
--test-deps "$TEST_DEPS" \
--test-ts "$TEST_TS" \
--codegen "$CODEGEN_OUTPUT" \