Skip to content

Commit 6e94197

Browse files
Upgrade daml2ts test to a more recent davl (#5316)
changelog_begin changelog_end
1 parent 52dbcf5 commit 6e94197

File tree

6 files changed

+64
-10
lines changed

6 files changed

+64
-10
lines changed

compiler/damlc/tests/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ da_haskell_test(
217217
"//compiler/damlc",
218218
"//compiler/damlc/tests:generate-simple-dalf",
219219
"//daml-lf/repl",
220-
"@davl//:released/davl-v3.dar",
220+
"@davl-v3//:released/davl-v3.dar",
221221
# Feel free to update this to 0.13.55 once that is frozen.
222222
":dars/old-proj-0.13.55-snapshot.20200309.3401.0.6f8c3ad8-1.8.dar",
223223
],

compiler/damlc/tests/src/DA/Test/Packaging.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ main = do
3434
setEnv "TASTY_NUM_THREADS" "1" True
3535
damlc <- locateRunfiles (mainWorkspace </> "compiler" </> "damlc" </> exe "damlc")
3636
repl <- locateRunfiles (mainWorkspace </> "daml-lf" </> "repl" </> exe "repl")
37-
davlDar <- locateRunfiles ("davl" </> "released" </> "davl-v3.dar")
37+
davlDar <- locateRunfiles ("davl-v3" </> "released" </> "davl-v3.dar")
3838
oldProjDar <- locateRunfiles (mainWorkspace </> "compiler" </> "damlc" </> "tests" </> "dars" </> "old-proj-0.13.55-snapshot.20200309.3401.0.6f8c3ad8-1.8.dar")
3939
let validate dar = callProcessSilent damlc ["validate-dar", dar]
4040
defaultMain $ tests Tools{..}

deps.bzl

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,14 @@ rules_haskell_version = "d59ccf9e7785553fd392924fb083d926c7e01134"
3535
rules_haskell_sha256 = "c29e779f512f72126c774bceb0bee5c01ca8149d30acc400058014f4b2275710"
3636
rules_nixpkgs_version = "c966bb8bd335f1e244c03efe6e7a1afa9784038e"
3737
rules_nixpkgs_sha256 = "ccafea4fc4d5fa2ddba2882f76728558bfe2c12657f7f56078ece43a31761148"
38-
davl_version = "51d3977be2ab22f7f4434fd4692ca2e17a7cce23"
39-
davl_sha256 = "e8e76e21b50fb3adab36df26045b1e8c3ee12814abc60f137d39b864d2eae166"
38+
39+
# Recent davl.
40+
davl_version = "f2d7480d118f32626533d6a150a8ee7552cc0222" # 2020-03-23, "Deploy upgrade to DAML SDK 0.13.56-snapshot.20200318",https://github.com/digital-asset/davl/pull/233/commits.
41+
davl_sha256 = "3e8ae2a05724093e33b7f0363381e81a7e8e9655ccb3aa47ad540ea87e814321"
42+
43+
# Pinned davl relied on by damlc packaging tests.
44+
davl_v3_version = "51d3977be2ab22f7f4434fd4692ca2e17a7cce23"
45+
davl_v3_sha256 = "e8e76e21b50fb3adab36df26045b1e8c3ee12814abc60f137d39b864d2eae166"
4046

4147
def daml_deps():
4248
if "rules_haskell" not in native.existing_rules():
@@ -256,6 +262,18 @@ def daml_deps():
256262
executable = True,
257263
)
258264

265+
if "davl-v3" not in native.existing_rules():
266+
http_archive(
267+
name = "davl-v3",
268+
strip_prefix = "davl-{}".format(davl_v3_version),
269+
urls = ["https://github.com/digital-asset/davl/archive/{}.tar.gz".format(davl_v3_version)],
270+
sha256 = davl_v3_sha256,
271+
build_file_content = """
272+
package(default_visibility = ["//visibility:public"])
273+
exports_files(["released/davl-v3.dar"])
274+
""",
275+
)
276+
259277
if "davl" not in native.existing_rules():
260278
http_archive(
261279
name = "davl",
@@ -264,6 +282,6 @@ def daml_deps():
264282
sha256 = davl_sha256,
265283
build_file_content = """
266284
package(default_visibility = ["//visibility:public"])
267-
exports_files(["released/davl-v3.dar", "released/davl-v4.dar", "released/davl-v5.dar", "released/davl-upgrade-v3-v4.dar", "released/davl-upgrade-v4-v5.dar"])
285+
exports_files(["released/davl-v4.dar", "released/davl-v5.dar", "released/davl-upgrade-v3-v4.dar", "released/davl-upgrade-v4-v5.dar"])
268286
""",
269287
)

language-support/ts/codegen/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,31 @@ trinity of shell scripts, all in parallel and each in its own terminal:
4040
All these steps only check that everything compiles. They do _not_ run any
4141
tests. To run the tests suite, you need to issue the command above.
4242

43+
### How to run daml2ts on a set of DARs from bazel
44+
45+
Running the code-generator outside of the SDK means having to take
46+
into account the dependency of daml2ts generated packages on a version
47+
of `daml-types` that is not available on NPM. The folllowing recipe
48+
shows how it's done (obviously you'll need to adapt paths in the below
49+
to your own environment).
50+
```bash
51+
mkdir -p ~/tmp/davl
52+
cd ~/tmp/davl
53+
cat > package.json<<EOF
54+
{
55+
"private": true,
56+
"workspaces": ["daml2ts"],
57+
"resolutions": {
58+
"@daml/types": "file:daml-types"
59+
}
60+
}
61+
EOF
62+
cd ~/project/daml.git
63+
bazel build //language-support/ts/daml-types:npm_package
64+
cp -R bazel-bin/language-support/ts/daml-types/npm_package ~/tmp/davl/daml-types
65+
bazel run //language-support/ts/codegen:daml2ts -- -o ~/tmp/davl/daml2ts ~/project/davl.git/released/*.dar
66+
```
67+
4368
## What `daml2ts` generates
4469

4570
The DAML SDK documentation contains [a page](https://github.com/digital-asset/daml/tree/master/docs/source/daml2ts) on `daml2ts`. It is recommended that you start with this. The remainder of this section contains additional detail (mostly about serialization code). The code that `daml2ts` generates uses the [@daml/types](https://github.com/digital-asset/daml/tree/master/language-support/ts/daml-types) and [@mojotech/json-type-validation](https://github.com/mojotech/json-type-validation) libraries. All TypeScript modules generated by `daml2ts` begin with the following fragment:

language-support/ts/codegen/tests/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,7 @@ da_haskell_test(
149149
"//compiler/damlc",
150150
"//language-support/ts/codegen:daml2ts",
151151
"//language-support/ts/daml-types:npm_package",
152-
"@davl//:released/davl-upgrade-v3-v4.dar",
153152
"@davl//:released/davl-upgrade-v4-v5.dar",
154-
"@davl//:released/davl-v3.dar",
155153
"@davl//:released/davl-v4.dar",
156154
"@davl//:released/davl-v5.dar",
157155
],

language-support/ts/codegen/tests/src/DA/Test/Daml2Ts.hs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,22 @@ tests damlTypes yarn damlc daml2ts davl = testGroup "daml2ts tests"
202202
, davl </> "davl-v5.dar"
203203
, davl </> "davl-upgrade-v4-v5.dar" ] ++
204204
["-o", daml2tsDir]
205-
mapM_ (assertTsFileExists (daml2tsDir </> "davl-0.0.4")) [ "index", "DAVL" </> "module" ]
206-
mapM_ (assertTsFileExists (daml2tsDir </> "davl-0.0.5")) [ "index", "DAVL" </> "module" ]
207-
mapM_ (assertTsFileExists (daml2tsDir </> "davl-upgrade-v4-v5-0.0.5")) [ "index", "Upgrade" </> "module" ]
205+
mapM_ (assertTsFileExists (daml2tsDir </> "davl-0.0.4"))
206+
[ "index"
207+
, "DAVL" </> "index"
208+
, "DAVL" </> "module"
209+
]
210+
mapM_ (assertTsFileExists (daml2tsDir </> "davl-0.0.5"))
211+
[ "index"
212+
, "DAVL" </> "index"
213+
, "DAVL" </> "V5" </> "index"
214+
, "DAVL" </> "V5" </> "module"
215+
]
216+
mapM_ (assertTsFileExists (daml2tsDir </> "davl-upgrade-v4-v5-0.0.5"))
217+
[ "index"
218+
, "Upgrade" </> "index"
219+
, "Upgrade" </> "module"
220+
]
208221
step "eslint..."
209222
withCurrentDirectory daml2tsDir $ do
210223
pkgs <- (\\ ["package.json", "node_modules"]) <$> listDirectory daml2tsDir

0 commit comments

Comments
 (0)