daml/templates/BUILD.bazel
Rohan Jacob-Rao 37ca4af529
create-daml-app: Add end-to-end tests to integration tests (#5540)
This PR gets yarn test running the Puppeteer end-to-end tests in the GSG integration test.

The first step of the test is adding the extra dependencies (Jest, Puppeteer and more). The GSG recommends a yarn add command, but this does not work against HEAD. This is because yarn add does not use resolutions in the parent package.json, and then complains about unknown versions 0.0.0 of the daml TS libaries. The solution here is to hack in the extra dependencies into the ui/package.json and then yarn install. This works, but it hard codes version numbers which we would need to maintain. I would like to be able to say version "latest", which is what yarn add would install.

The next step of the test is to copy the index.test.ts file and run yarn test in CI mode.

I've moved the GSG test to a new create-daml-app-tests target. It's marked "exclusive" in Bazel until we figure out how to avoid hardcoding port numbers. This is a bit tricky since the HTTP port is hardcoded in a couple of places in ui/package.json.

Finally, this PR gets the GSG testing docs to reference the code in the new templates/create-daml-app-test-resources folder.

changelog_begin
changelog_end
2020-04-17 12:42:24 -04:00

76 lines
2.8 KiB
Python

# Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
exports_files(glob(["create-daml-app-test-resources/*"]))
genrule(
name = "templates-tarball",
srcs = glob([
"default-gitignore",
"default-dlint-yaml",
"skeleton/**",
"create-daml-app/**",
"quickstart-java/**",
"quickstart-scala/**",
]) + [
"//docs:quickstart-java.tar.gz",
"//docs:daml-intro-templates",
"//docs:daml-patterns",
"//docs:copy-trigger-template",
"//docs:script-example-template",
"//language-support/scala/examples:quickstart-scala-dir",
],
outs = ["templates-tarball.tar.gz"],
cmd = """
SRC=templates
OUT=templates-tarball
# templates in templates dir
for d in skeleton create-daml-app quickstart-scala quickstart-java; do
mkdir -p $$OUT/$$d
cp -rL $$SRC/$$d/* $$OUT/$$d/
# use default .gitignore and .dlint.yaml if they don't exist in the template
cp -n $$SRC/default-gitignore $$OUT/$$d/.gitignore
cp -n $$SRC/default-dlint-yaml $$OUT/$$d/.dlint.yaml
# We avoid introducing infix syntax in the GSG so we disable
# the lint there.
if [ "$$d" = "create-daml-app" ]; then
cat >> $$OUT/$$d/.dlint.yaml <<EOF
# This rule is enabled by default but we avoid
# infix syntax here to keep things simple.
- ignore: {name: Use infix }
EOF
fi
done
## special cases we should work to remove
# quickstart-java template
# right now, uses the preexisting quickstart-java rule and replaces the
# da.yaml template with a daml.yaml template; in the future, move
# everything into //templates/quickstart-java and avoid untar, rm here
tar xf $(location //docs:quickstart-java.tar.gz) --strip-components=1 -C $$OUT/quickstart-java
# quickstart-scala template
cp -r $(location //language-support/scala/examples:quickstart-scala-dir)/* $$OUT/quickstart-scala/
# daml intro templates
tar xf $(location //docs:daml-intro-templates) -C $$OUT
mkdir -p $$OUT/copy-trigger
tar xf $(location //docs:copy-trigger-template) -C $$OUT/copy-trigger
mkdir -p $$OUT/script-example
tar xf $(location //docs:script-example-template) -C $$OUT/script-example
mkdir -p $$OUT/daml-patterns
tar xf $(location //docs:daml-patterns) --strip-components=1 -C $$OUT/daml-patterns
tar c templates-tarball \
--owner=0 --group=0 --numeric-owner --mtime=2000-01-01\ 00:00Z --sort=name \
| gzip -n >$(location :templates-tarball.tar.gz)
""",
visibility = ["//visibility:public"],
)