Include the first feature in compat tests for create-daml-app (#6002)

* Include the first feature in compat tests for create-daml-app

This adds the step from the create-daml-app tests that applies the
patch for the messaging feature and tests that things will build. This
is the last step before we can actually run the puppeteer tests which
will turn this into an actual compatibility test.

changelog_begin
changelog_end

* temporarily run all tests

changelog_begin
changelog_end

* Fix exclusions

changelog_begin
changelog_end

* Revert "temporarily run all tests"

This reverts commit 7425dd09cf48f2bfd6064b55d857c76d51afc821.

* Remove accidentally committed messaging.patch

changelog_begin
changelog_end
This commit is contained in:
Moritz Kiefer 2020-05-18 14:37:16 +02:00 committed by GitHub
parent 1018e2744b
commit de03425664
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 248 additions and 16 deletions

1
.gitignore vendored
View File

@ -80,6 +80,7 @@ ledger-api/.bin
/bazel-*
/compatibility/bazel-*
/compatibility/.bazelrc
/compatibility/head_sdk/
.bazelrc.local
.ijwb
.bazelproject

View File

@ -201,6 +201,26 @@ node_repositories(
yarn_version = "1.22.4",
)
nixpkgs_package(
name = "patch_nix",
attribute_path = "gnupatch",
fail_not_supported = False,
nix_file = "@daml//nix:bazel.nix",
nix_file_deps = common_nix_file_deps,
repositories = dev_env_nix_repos,
)
dev_env_tool(
name = "patch_dev_env",
nix_include = ["bin/patch"],
nix_label = "@patch_nix",
nix_paths = ["bin/patch"],
tools = ["patch"],
win_include = ["usr/bin/patch.exe"],
win_paths = ["usr/bin/patch.exe"],
win_tool = "msys2",
)
load("//:bazel-haskell-deps.bzl", "daml_haskell_deps")
daml_haskell_deps()
@ -213,6 +233,7 @@ local_repository(
)
daml_sdk_head(
create_daml_app_patch = "@head_sdk//:messaging.patch",
daml_ledger_tarball = "@head_sdk//:daml-ledger-0.0.0.tgz",
daml_react_tarball = "@head_sdk//:daml-react-0.0.0.tgz",
daml_types_tarball = "@head_sdk//:daml-types-0.0.0.tgz",
@ -223,6 +244,9 @@ daml_sdk_head(
[
daml_sdk(
# See the explanation in UpdateVersions.hs
create_daml_app_patch = None if version_sha256s.get(ver).get("create_daml_app_patch") else "@daml-sdk-1.1.0-snapshot.20200422.3991.0.6391ee9f//:create_daml_app.patch",
create_daml_app_patch_sha256 = version_sha256s.get(ver).get("create_daml_app_patch"),
daml_ledger_sha256 = version_sha256s.get(ver).get("daml_ledger"),
daml_react_sha256 = version_sha256s.get(ver).get("daml_react"),
daml_types_sha256 = version_sha256s.get(ver).get("daml_types"),

View File

@ -50,6 +50,7 @@ def daml_haskell_deps():
"directory",
"extra",
"filepath",
"http-client",
"http-conduit",
"jwt",
"lens",

View File

@ -1,6 +1,5 @@
-- Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main (main) where
import qualified Bazel.Runfiles
@ -38,7 +37,9 @@ data Tools = Tools
, damlLedgerPath :: FilePath
, damlTypesPath :: FilePath
, damlReactPath :: FilePath
, messagingPatch :: FilePath
, yarnPath :: FilePath
, patchPath :: FilePath
}
newtype DamlOption = DamlOption FilePath
@ -101,6 +102,13 @@ instance IsOption DamlReactOption where
optionName = Tagged "daml-react"
optionHelp = Tagged "path to extracted daml-react package"
newtype MessagingPatchOption = MessagingPatchOption FilePath
instance IsOption MessagingPatchOption where
defaultValue = MessagingPatchOption ""
parseValue = Just . MessagingPatchOption
optionName = Tagged "messaging-patch"
optionHelp = Tagged "path to messaging patch"
newtype YarnOption = YarnOption FilePath
instance IsOption YarnOption where
defaultValue = YarnOption ""
@ -108,6 +116,13 @@ instance IsOption YarnOption where
optionName = Tagged "yarn"
optionHelp = Tagged "path to yarn"
newtype PatchOption = PatchOption FilePath
instance IsOption PatchOption where
defaultValue = PatchOption ""
parseValue = Just . PatchOption
optionName = Tagged "patch"
optionHelp = Tagged "path to patch"
withTools :: (IO Tools -> TestTree) -> TestTree
withTools tests = do
askOption $ \(DamlOption damlPath) -> do
@ -118,7 +133,9 @@ withTools tests = do
askOption $ \(DamlLedgerOption damlLedgerPath) -> do
askOption $ \(DamlTypesOption damlTypesPath) -> do
askOption $ \(DamlReactOption damlReactPath) -> do
askOption $ \(MessagingPatchOption messagingPatch) -> do
askOption $ \(YarnOption yarnPath) -> do
askOption $ \(PatchOption patchPath) -> do
let createRunfiles :: IO (FilePath -> FilePath)
createRunfiles = do
runfiles <- Bazel.Runfiles.create
@ -138,7 +155,9 @@ withTools tests = do
, damlLedgerPath
, damlTypesPath
, damlReactPath
, messagingPatch
, yarnPath
, patchPath
}
tests tools
@ -154,7 +173,9 @@ main = do
, Option @DamlLedgerOption Proxy
, Option @DamlTypesOption Proxy
, Option @DamlReactOption Proxy
, Option @MessagingPatchOption Proxy
, Option @YarnOption Proxy
, Option @PatchOption Proxy
]
let ingredients = defaultIngredients ++ [includingOptions options]
defaultMainWithIngredients ingredients $
@ -200,6 +221,29 @@ main = do
callProcessSilent yarnPath ["build"]
assertFileExists (cdaDir </> "ui" </> "build" </> "index.html")
step "Patch the application code with messaging feature"
withCurrentDirectory cdaDir $ do
callProcessSilent patchPath ["-p2", "-i", messagingPatch]
forM_ ["MessageEdit", "MessageList"] $ \messageComponent ->
assertFileExists ("ui" </> "src" </> "components" </> messageComponent <.> "tsx")
step "Build the new DAML model"
callProcessSilent damlBinary ["build"]
step "Set up TypeScript libraries and Yarn workspaces for codegen again"
setupYarnEnv tmpDir (Workspaces ["create-daml-app/daml.js"])
[ (DamlTypes, damlTypesPath), (DamlLedger, damlLedgerPath) ]
step "Run JavaScript codegen for new DAML model"
callProcessSilent damlBinary ["codegen", "js", "-o", "daml.js", ".daml/dist/create-daml-app-0.1.0.dar"]
withCurrentDirectory (cdaDir </> "ui") $ do
step "Set up libraries and workspaces again for UI build"
setupYarnEnv tmpDir (Workspaces ["create-daml-app/ui"])
[(DamlLedger, damlLedgerPath), (DamlReact, damlReactPath), (DamlTypes, damlTypesPath)]
step "Install UI dependencies again, forcing rebuild of generated code"
callProcessSilent yarnPath ["install", "--force", "--frozen-lockfile"]
step "Run linter again"
callProcessSilent yarnPath ["lint", "--max-warnings", "0"]
step "Build the new UI"
callProcessSilent yarnPath ["build"]
data TsLibrary
= DamlLedger
| DamlReact

View File

@ -20,7 +20,9 @@ JSON_API="$(rlocation "$TEST_WORKSPACE/$4")"
DAML_TYPES="$(rlocation "$TEST_WORKSPACE/$5")"
DAML_LEDGER="$(rlocation "$TEST_WORKSPACE/$6")"
DAML_REACT="$(rlocation "$TEST_WORKSPACE/$7")"
YARN="$(rlocation "$TEST_WORKSPACE/$8")"
MESSAGING_PATCH="$(rlocation "$TEST_WORKSPACE/$8")"
YARN="$(rlocation "$TEST_WORKSPACE/$9")"
PATCH="$(rlocation "$TEST_WORKSPACE/${10}")"
"$RUNNER" \
--daml "$DAML" \
@ -29,5 +31,7 @@ YARN="$(rlocation "$TEST_WORKSPACE/$8")"
--daml-types "$DAML_TYPES" \
--daml-ledger "$DAML_LEDGER" \
--daml-react "$DAML_REACT" \
--messaging-patch "$MESSAGING_PATCH" \
--yarn "$YARN" \
"${@:9}"
--patch "$PATCH" \
"${@:11}"

View File

@ -56,6 +56,17 @@ def _daml_sdk_impl(ctx):
output = "extracted-test-tool",
)
if ctx.attr.create_daml_app_patch:
ctx.symlink(ctx.attr.create_daml_app_patch, "create_daml_app.patch")
elif ctx.attr.test_tool_sha256:
ctx.download(
output = "create_daml_app.patch",
url = "https://raw.githubusercontent.com/digital-asset/daml/v{}/templates/create-daml-app-test-resources/messaging.patch".format(ctx.attr.version),
sha256 = ctx.attr.create_daml_app_patch_sha256,
)
else:
fail("Must specify either test_tool or test_tool_sha256")
for lib in ["types", "ledger", "react"]:
tarball_name = "daml_{}_tarball".format(lib)
if getattr(ctx.attr, tarball_name):
@ -121,7 +132,7 @@ filegroup(
name = "dar-files",
srcs = glob(["extracted-test-tool/ledger/test-common/**"]),
)
exports_files(["daml-types.tgz", "daml-ledger.tgz", "daml-react.tgz"])
exports_files(["daml-types.tgz", "daml-ledger.tgz", "daml-react.tgz", "create_daml_app.patch"])
""",
)
return None
@ -141,6 +152,8 @@ _daml_sdk = repository_rule(
"daml_types_sha256": attr.string(mandatory = False),
"daml_ledger_sha256": attr.string(mandatory = False),
"daml_react_sha256": attr.string(mandatory = False),
"create_daml_app_patch": attr.label(allow_single_file = True, mandatory = False),
"create_daml_app_patch_sha256": attr.string(mandatory = False),
},
)
@ -151,7 +164,7 @@ def daml_sdk(version, **kwargs):
**kwargs
)
def daml_sdk_head(sdk_tarball, ledger_api_test_tool, daml_types_tarball, daml_ledger_tarball, daml_react_tarball, **kwargs):
def daml_sdk_head(sdk_tarball, ledger_api_test_tool, daml_types_tarball, daml_ledger_tarball, daml_react_tarball, create_daml_app_patch, **kwargs):
version = "0.0.0"
_daml_sdk(
name = "daml-sdk-{}".format(version),
@ -161,5 +174,6 @@ def daml_sdk_head(sdk_tarball, ledger_api_test_tool, daml_types_tarball, daml_le
daml_types_tarball = daml_types_tarball,
daml_ledger_tarball = daml_ledger_tarball,
daml_react_tarball = daml_react_tarball,
create_daml_app_patch = create_daml_app_patch,
**kwargs
)

View File

@ -42,6 +42,18 @@ excluded_test_tool_tests = {
# Fix for https://github.com/digital-asset/daml/issues/5562
"ContractKeysIT",
],
"1.1.1": [
# This restriction has been removed in https://github.com/digital-asset/daml/pull/5611.
"ContractKeysSubmitterIsMaintainerIT",
# Fix for https://github.com/digital-asset/daml/issues/5562
"ContractKeysIT",
],
"1.2.0-snapshot.20200513.4172.0.021f4af3": [
# This restriction has been removed in https://github.com/digital-asset/daml/pull/5611.
"ContractKeysSubmitterIsMaintainerIT",
# Fix for https://github.com/digital-asset/daml/issues/5562
"ContractKeysIT",
],
},
"1.0.1-snapshot.20200417.3908.1.722bac90": {
"0.0.0": [
@ -70,6 +82,18 @@ excluded_test_tool_tests = {
# Fix for https://github.com/digital-asset/daml/issues/5562
"ContractKeysIT",
],
"1.1.1": [
# This restriction has been removed in https://github.com/digital-asset/daml/pull/5611.
"ContractKeysSubmitterIsMaintainerIT",
# Fix for https://github.com/digital-asset/daml/issues/5562
"ContractKeysIT",
],
"1.2.0-snapshot.20200513.4172.0.021f4af3": [
# This restriction has been removed in https://github.com/digital-asset/daml/pull/5611.
"ContractKeysSubmitterIsMaintainerIT",
# Fix for https://github.com/digital-asset/daml/issues/5562
"ContractKeysIT",
],
},
"1.0.1-snapshot.20200424.3917.0.16093690": {
"1.0.0": [
@ -92,6 +116,14 @@ excluded_test_tool_tests = {
# This restriction has been removed in https://github.com/digital-asset/daml/pull/5611.
"ContractKeysSubmitterIsMaintainerIT",
],
"1.1.1": [
# This restriction has been removed in https://github.com/digital-asset/daml/pull/5611.
"ContractKeysSubmitterIsMaintainerIT",
],
"1.2.0-snapshot.20200513.4172.0.021f4af3": [
# This restriction has been removed in https://github.com/digital-asset/daml/pull/5611.
"ContractKeysSubmitterIsMaintainerIT",
],
"0.0.0": [
# This restriction has been removed in https://github.com/digital-asset/daml/pull/5611.
"ContractKeysSubmitterIsMaintainerIT",
@ -118,6 +150,14 @@ excluded_test_tool_tests = {
# This restriction has been removed in https://github.com/digital-asset/daml/pull/5611.
"ContractKeysSubmitterIsMaintainerIT",
],
"1.1.1": [
# This restriction has been removed in https://github.com/digital-asset/daml/pull/5611.
"ContractKeysSubmitterIsMaintainerIT",
],
"1.2.0-snapshot.20200513.4172.0.021f4af3": [
# This restriction has been removed in https://github.com/digital-asset/daml/pull/5611.
"ContractKeysSubmitterIsMaintainerIT",
],
"0.0.0": [
# This restriction has been removed in https://github.com/digital-asset/daml/pull/5611.
"ContractKeysSubmitterIsMaintainerIT",
@ -144,6 +184,18 @@ excluded_test_tool_tests = {
# Fix for https://github.com/digital-asset/daml/issues/5562
"ContractKeysIT",
],
"1.1.1": [
# This restriction has been removed in https://github.com/digital-asset/daml/pull/5611.
"ContractKeysSubmitterIsMaintainerIT",
# Fix for https://github.com/digital-asset/daml/issues/5562
"ContractKeysIT",
],
"1.2.0-snapshot.20200513.4172.0.021f4af3": [
# This restriction has been removed in https://github.com/digital-asset/daml/pull/5611.
"ContractKeysSubmitterIsMaintainerIT",
# Fix for https://github.com/digital-asset/daml/issues/5562
"ContractKeysIT",
],
"0.0.0": [
# This restriction has been removed in https://github.com/digital-asset/daml/pull/5611.
"ContractKeysSubmitterIsMaintainerIT",
@ -179,6 +231,34 @@ excluded_test_tool_tests = {
"ContractKeysIT",
],
},
"1.1.1": {
"1.0.0": [
# Fix for https://github.com/digital-asset/daml/issues/5562
"ContractKeysIT",
],
"1.0.1-snapshot.20200417.3908.1.722bac90": [
# Fix for https://github.com/digital-asset/daml/issues/5562
"ContractKeysIT",
],
"1.1.0-snapshot.20200422.3991.0.6391ee9f": [
# Fix for https://github.com/digital-asset/daml/issues/5562
"ContractKeysIT",
],
},
"1.2.0-snapshot.20200513.4172.0.021f4af3": {
"1.0.0": [
# Fix for https://github.com/digital-asset/daml/issues/5562
"ContractKeysIT",
],
"1.0.1-snapshot.20200417.3908.1.722bac90": [
# Fix for https://github.com/digital-asset/daml/issues/5562
"ContractKeysIT",
],
"1.1.0-snapshot.20200422.3991.0.6391ee9f": [
# Fix for https://github.com/digital-asset/daml/issues/5562
"ContractKeysIT",
],
},
"0.0.0": {
"1.0.0": [
# Fix for https://github.com/digital-asset/daml/issues/5562
@ -257,6 +337,7 @@ def create_daml_app_test(
daml_types,
daml_react,
daml_ledger,
messaging_patch,
sandbox_args = [],
json_api_args = [],
data = [],
@ -277,12 +358,15 @@ def create_daml_app_test(
"$(rootpath %s)" % daml_types,
"$(rootpath %s)" % daml_ledger,
"$(rootpath %s)" % daml_react,
"$(rootpath %s)" % messaging_patch,
"$(rootpath @nodejs//:yarn)",
"$(rootpath @patch_dev_env//:patch)",
] + _concat([["--sandbox-arg", arg] for arg in sandbox_args]) +
_concat([["--json-api-arg", arg] for arg in json_api_args]),
data = data + depset(direct = [
"//bazel_tools/create-daml-app:runner",
"@nodejs//:yarn",
"@patch_dev_env//:patch",
# Deduplicate if daml and sandbox come from the same release.
daml,
sandbox,
@ -290,6 +374,7 @@ def create_daml_app_test(
daml_types,
daml_react,
daml_ledger,
messaging_patch,
]).to_list(),
**kwargs
)
@ -389,6 +474,7 @@ def sdk_platform_test(sdk_version, platform_version):
daml_types = "@daml-sdk-{}//:daml-types.tgz".format(sdk_version),
daml_react = "@daml-sdk-{}//:daml-react.tgz".format(sdk_version),
daml_ledger = "@daml-sdk-{}//:daml-ledger.tgz".format(sdk_version),
messaging_patch = "@daml-sdk-{}//:create_daml_app.patch".format(sdk_version),
sandbox_args = sandbox_args,
json_api_args = json_api_args,
size = "large",

View File

@ -45,3 +45,4 @@ bazel build `
cp -Force bazel-bin\release\sdk-release-tarball.tar.gz compatibility/head_sdk
cp -Force bazel-bin\ledger\ledger-api-test-tool\ledger-api-test-tool_deploy.jar compatibility/head_sdk
cp -Force templates\create-daml-app-test-resources\messaging.patch compatibility/head_sdk

View File

@ -23,4 +23,4 @@ bazel build \
cp -f bazel-bin/release/sdk-release-tarball.tar.gz "$HEAD_TARGET_DIR"
cp -f bazel-bin/ledger/ledger-api-test-tool/ledger-api-test-tool_deploy.jar "$HEAD_TARGET_DIR"
cp -f templates/create-daml-app-test-resources/messaging.patch "$HEAD_TARGET_DIR"

View File

@ -1,2 +1,3 @@
sdk-release-tarball.tar.gz
ledger-api-test-tool_deploy.jar
messaging.patch

View File

@ -10,6 +10,8 @@ sdk_versions = [
"1.1.0-snapshot.20200422.3991.0.6391ee9f",
"1.1.0-snapshot.20200430.4057.0.681c862d",
"1.1.0-snapshot.20200506.4107.0.7e448d81",
"1.1.1",
"1.2.0-snapshot.20200513.4172.0.021f4af3",
"0.0.0",
]
platform_versions = [
@ -20,14 +22,17 @@ platform_versions = [
"1.1.0-snapshot.20200422.3991.0.6391ee9f",
"1.1.0-snapshot.20200430.4057.0.681c862d",
"1.1.0-snapshot.20200506.4107.0.7e448d81",
"1.1.1",
"1.2.0-snapshot.20200513.4172.0.021f4af3",
"0.0.0",
]
stable_versions = [
"1.0.0",
"1.0.1",
"1.1.1",
"0.0.0",
]
latest_stable_version = "1.0.1"
latest_stable_version = "1.1.1"
version_sha256s = {
"1.0.0": {
"linux": "ee7e2f50394d44fb3490068de64d37f4f87534e802717bd7e07e8767df2e4e05",
@ -73,6 +78,7 @@ version_sha256s = {
"daml_types": "cad498131eb60f2651303cc26d520fe3614750ef2705db23ffbefeae0be3b7cf",
"daml_ledger": "527b6353c6d88d79f69aa78a51b9707e541555c42f1a2331f2bf075a730b3305",
"daml_react": "18f3363aa9c4f32b1fac48028a73a56dfdd8a73058d4b8d119adb16c72cb70fb",
"create_daml_app_patch": "b187d446443209288c165cf34247307275b497e015a5d953805297c05279d856",
},
"1.1.0-snapshot.20200430.4057.0.681c862d": {
"linux": "199cb51a5b406c8968f2352fe04ace8368ce95beaee81f19073b0f998c5518bf",
@ -82,6 +88,7 @@ version_sha256s = {
"daml_types": "3329d1c1fc7382e86af2bff305effd31e22387149dc3231e9ed03ccd1b25bc30",
"daml_ledger": "1c5a3eb196a90685f406d4a91a8514ab22d0ebeaf1302f22854c6ac1e49c5ae4",
"daml_react": "8a217c7af7c828f41b532640914ed83f3d19bf5b8b42a52671db427ed9dd770c",
"create_daml_app_patch": "b187d446443209288c165cf34247307275b497e015a5d953805297c05279d856",
},
"1.1.0-snapshot.20200506.4107.0.7e448d81": {
"linux": "36d192d7004b2d307437a97bf86af9ffdea8adde99419867cf51740dd7a89a94",
@ -91,5 +98,26 @@ version_sha256s = {
"daml_types": "987560f3b2268bc8dffcbad2f257a182f7145884afc9c69c62658cea037459c1",
"daml_ledger": "3762cd5185d69121a3277fe2d3520cf2762e23e09049ef771d3e44c8c5891f2f",
"daml_react": "35d892da1844358e032adbfd987c5fcf7eb279209d846126c37c8d993401a792",
"create_daml_app_patch": "b187d446443209288c165cf34247307275b497e015a5d953805297c05279d856",
},
"1.1.1": {
"linux": "1e396287b7462147d182fd2c536a5ee03163e3efeefc989d368b1dfc01a40a97",
"macos": "f49dd3f5198d3392b81bd64067f697bc0d18612fe9599a50580d57d1dd9c721c",
"windows": "c2ec9b51f7d4e44309d73f1ee9eb4919eac5c80452782b97d76251a0c283f596",
"test_tool": "f5b5024d7173e7f56b1d2ca57c8ee0b4a107208cd9d15f27f9ab1737ecfc33a4",
"daml_types": "142e7094081a95f202e0a5eaf72a15df724c2b9aa5e83bd22e4c544705de967e",
"daml_ledger": "15041d0be63f1781b9d036481093f49d56071078a4e826a862de921b5a806d93",
"daml_react": "3dabcccd1d4c13637cc096c401606f777f90368a4057dc7220269f8101aa1888",
"create_daml_app_patch": "b187d446443209288c165cf34247307275b497e015a5d953805297c05279d856",
},
"1.2.0-snapshot.20200513.4172.0.021f4af3": {
"linux": "3cefc08a50cd2dc9809064e94fc34af93e9b95da211346483b8f32219d9d6b10",
"macos": "ee07b3c8ac414ee872afb598075957e26e7f1ff50a93e23a1df1a45844711a9a",
"windows": "a50b4c03d76eef967cb8061ed84d99b6175d3501f795b98d86c9a195d7b3e47c",
"test_tool": "9cdb47c4b3c2d49aba00a0e684beac105fdefa390aeecdd731c7e6811ab33105",
"daml_types": "5bc76ae50297af0587ec26d380bed46fd9ba90316000bdb7d0907c0db60171e5",
"daml_ledger": "6ca843d878a510910f4be34c61e0ad0b8f7a6d4646175334caecdda4f5a297d7",
"daml_react": "0fc2cd41c8f0205f07e18e066a2d7f89cbcb03ef46825f241e2ec1efa6cd0778",
"create_daml_app_patch": "b187d446443209288c165cf34247307275b497e015a5d953805297c05279d856",
},
}

View File

@ -11,6 +11,7 @@ da_haskell_binary(
"containers",
"cryptonite",
"extra",
"http-client",
"http-conduit",
"lens",
"memory",

View File

@ -9,6 +9,7 @@ import Crypto.Hash (hashlazy, Digest, SHA256)
import Data.Aeson
import Data.ByteArray.Encoding (Base(Base16), convertToBase)
import Data.ByteString (ByteString)
import Data.Either (fromRight)
import qualified Data.HashMap.Strict as HashMap
import Data.Map (Map)
import qualified Data.Map.Strict as Map
@ -17,6 +18,7 @@ import qualified Data.Set as Set
import Data.SemVer (Version)
import qualified Data.SemVer as SemVer
import qualified Data.Text as T
import Network.HTTP.Client (responseTimeout, responseTimeoutMicro)
import Network.HTTP.Simple
import Options.Applicative
import System.IO.Extra
@ -67,8 +69,8 @@ renderVersionsFile (Versions (Set.toAscList -> versions)) checksums =
, [ "}" ]
]
where
renderChecksums (ver, Checksums{..}) =
[ " \"" <> SemVer.toText ver <> "\": {"
renderChecksums (ver, Checksums{..}) = concat
[ [ " \"" <> SemVer.toText ver <> "\": {"
, " \"linux\": " <> renderDigest linuxHash <> ","
, " \"macos\": " <> renderDigest macosHash <> ","
, " \"windows\": " <> renderDigest windowsHash <> ","
@ -76,8 +78,12 @@ renderVersionsFile (Versions (Set.toAscList -> versions)) checksums =
, " \"daml_types\": " <> renderDigest damlTypesHash <> ","
, " \"daml_ledger\": " <> renderDigest damlLedgerHash <> ","
, " \"daml_react\": " <> renderDigest damlReactHash <> ","
, " },"
]
, [ " \"create_daml_app_patch\": " <> renderDigest hash <> ","
| Just hash <- [mbCreateDamlAppPatchHash]
]
, [ " }," ]
]
renderDigest digest = T.pack $ show (convertToBase Base16 digest :: ByteString)
renderVersion ver = " \"" <> SemVer.toText ver <> "\","
stableVersions = filter (null . view SemVer.release) versions
@ -94,24 +100,34 @@ data Checksums = Checksums
, damlTypesHash :: Digest SHA256
, damlLedgerHash :: Digest SHA256
, damlReactHash :: Digest SHA256
, mbCreateDamlAppPatchHash :: Maybe (Digest SHA256)
-- ^ Nothing for older versions
}
-- | The messaging patch wasnt included in 1.0.0 directly
-- but only added later.
-- However, the code did not change and we can apply
-- the later patch on the older versions.
-- Therefore we fallback to using the patch from this version
-- for releases before this one.
firstMessagingPatch :: Version
firstMessagingPatch =
fromRight (error "Invalid version") $
SemVer.fromText "1.1.0-snapshot.20200422.3991.0.6391ee9f"
getChecksums :: Version -> IO Checksums
getChecksums ver = do
putStrLn ("Requesting hashes for " <> SemVer.toString ver)
[ linuxHash, macosHash, windowsHash, testToolHash,
damlTypesHash, damlLedgerHash, damlReactHash ] <-
damlTypesHash, damlLedgerHash, damlReactHash] <-
forConcurrently
[ sdkUrl "linux", sdkUrl "macos", sdkUrl "windows"
, testToolUrl
, tsLib "types"
, tsLib "ledger"
, tsLib "react"
] $ \url -> do
req <- parseRequestThrow url
bs <- httpLbs req
let !hash = hashlazy (getResponseBody bs)
pure hash
] getHash
mbCreateDamlAppPatchHash <- traverse getHash mbCreateDamlAppUrl
pure Checksums {..}
where sdkUrl platform =
"https://github.com/digital-asset/daml/releases/download/v" <>
@ -123,6 +139,17 @@ getChecksums ver = do
tsLib name =
"https://registry.npmjs.org/@daml/" <> name <>
"/-/" <> name <> "-" <> SemVer.toString ver <> ".tgz"
mbCreateDamlAppUrl
| ver >= firstMessagingPatch =
Just $
"https://raw.githubusercontent.com/digital-asset/daml/v" <> SemVer.toString ver
<> "/templates/create-daml-app-test-resources/messaging.patch"
| otherwise = Nothing
getHash url = do
req <- parseRequestThrow url
bs <- httpLbs req { responseTimeout = responseTimeoutMicro (60 * 10 ^ (6 :: Int) ) }
let !hash = hashlazy (getResponseBody bs)
pure hash
optsParser :: Parser Opts
optsParser = Opts