From 4916a2868278641aaf3018ac13ec2ee18c89e12d Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Wed, 13 May 2020 10:39:51 +0200 Subject: [PATCH] Include create-daml-app tests in compatibility tests (#5945) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is the first part of #5700 It adds tests that build create-daml-app using `daml build` and then run the codegen and build the UI. Contrary to our main tests these also run on Windows. This is actually reasonably simple by first building the typescript libraries on Linux and then downloading them on Windows. There are two parts that are still missing from the tests in the main workspace: 1. Building the extra feature. This should be fairly easy to add. 2. Running the pupeeter tests. At least MacOS and Linux should be reasonably easy. I don’t know what horrors Windows will throw at us. This step is what actually makes this a compatibility test. Currently it doesn’t actually launch Sandbox and the JSON API. Since this PR is already pretty large, I’d like to tackle those things separately. changelog_begin changelog_end --- azure-pipelines.yml | 17 ++ ci/compatibility-windows.yml | 4 + ci/compatibility.yml | 4 + ci/compatibility_ts_libs.yml | 25 ++ ci/cron/daily-compat.yml | 11 + compatibility/WORKSPACE | 41 +++ compatibility/bazel-haskell-deps.bzl | 5 + compatibility/bazel_tools/BUILD | 1 + .../bazel_tools/create-daml-app/BUILD.bazel | 37 +++ .../bazel_tools/create-daml-app/Main.hs | 239 ++++++++++++++++++ .../bazel_tools/create_daml_app_test.sh | 33 +++ .../bazel_tools/daml_ledger/BUILD.bazel | 1 + compatibility/bazel_tools/daml_ledger/Main.hs | 23 +- compatibility/bazel_tools/daml_sdk.bzl | 26 +- compatibility/bazel_tools/test_utils/BUILD | 31 +++ .../bazel_tools/test_utils/DA/Test/Process.hs | 31 +++ .../bazel_tools/test_utils/DA/Test/Tar.hs | 79 ++++++ .../bazel_tools/test_utils/DA/Test/Util.hs | 17 ++ compatibility/bazel_tools/testing.bzl | 106 ++++++++ compatibility/build-ts-libs.sh | 25 ++ compatibility/deps.bzl | 14 + compatibility/versions.bzl | 31 +++ compatibility/versions/UpdateVersions.hs | 20 +- deps.bzl | 6 +- 24 files changed, 800 insertions(+), 27 deletions(-) create mode 100644 ci/compatibility_ts_libs.yml create mode 100644 compatibility/bazel_tools/create-daml-app/BUILD.bazel create mode 100644 compatibility/bazel_tools/create-daml-app/Main.hs create mode 100755 compatibility/bazel_tools/create_daml_app_test.sh create mode 100644 compatibility/bazel_tools/test_utils/BUILD create mode 100644 compatibility/bazel_tools/test_utils/DA/Test/Process.hs create mode 100644 compatibility/bazel_tools/test_utils/DA/Test/Tar.hs create mode 100644 compatibility/bazel_tools/test_utils/DA/Test/Util.hs create mode 100755 compatibility/build-ts-libs.sh diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a2b8d104e4..743ff1c9a5 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -189,9 +189,24 @@ jobs: trigger_sha: '$(trigger_sha)' - template: ci/report-end.yml + - job: compatibility_ts_libs + dependsOn: + - check_for_release + timeoutInMinutes: 60 + pool: + name: linux-pool + demands: assignment -equals default + steps: + - template: ci/report-start.yml + - checkout: self + - template: ci/compatibility_ts_libs.yml + - template: ci/tell-slack-failed.yml + - template: ci/report-end.yml + - job: compatibility_linux dependsOn: - check_for_release + - compatibility_ts_libs timeoutInMinutes: 60 pool: name: linux-pool @@ -208,6 +223,7 @@ jobs: - job: compatibility_macos dependsOn: - check_for_release + - compatibility_ts_libs timeoutInMinutes: 60 pool: name: macOS-pool @@ -223,6 +239,7 @@ jobs: - job: compatibility_windows dependsOn: - check_for_release + - compatibility_ts_libs - patch_bazel_windows timeoutInMinutes: 60 pool: diff --git a/ci/compatibility-windows.yml b/ci/compatibility-windows.yml index 0bf2370e97..4ac5e151a2 100644 --- a/ci/compatibility-windows.yml +++ b/ci/compatibility-windows.yml @@ -20,6 +20,10 @@ steps: IS_FORK: $(System.PullRequest.IsFork) # to upload to the bazel cache GOOGLE_APPLICATION_CREDENTIALS_CONTENT: $(GOOGLE_APPLICATION_CREDENTIALS_CONTENT) + - task: DownloadPipelineArtifact@0 + inputs: + artifactName: 'typescript-libs' + targetPath: $(Build.SourcesDirectory)/compatibility/head_sdk - powershell: '.\compatibility\build-release-artifacts-windows.ps1' displayName: 'Build release artifacts' - powershell: '.\compatibility\test-windows.ps1 ${{ parameters.test_flags }}' diff --git a/ci/compatibility.yml b/ci/compatibility.yml index 8f13d71c5d..99cd350abb 100644 --- a/ci/compatibility.yml +++ b/ci/compatibility.yml @@ -22,6 +22,10 @@ steps: IS_FORK: $(System.PullRequest.IsFork) # to upload to the bazel cache GOOGLE_APPLICATION_CREDENTIALS_CONTENT: $(GOOGLE_APPLICATION_CREDENTIALS_CONTENT) + - task: DownloadPipelineArtifact@0 + inputs: + artifactName: 'typescript-libs' + targetPath: $(Build.SourcesDirectory)/compatibility/head_sdk - bash: | set -euo pipefail ./compatibility/build-release-artifacts.sh diff --git a/ci/compatibility_ts_libs.yml b/ci/compatibility_ts_libs.yml new file mode 100644 index 0000000000..a2824f3d0a --- /dev/null +++ b/ci/compatibility_ts_libs.yml @@ -0,0 +1,25 @@ +# Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +parameters: + - name: test_flags + type: string + default: '' + +steps: + - bash: ci/dev-env-install.sh + displayName: 'Build/Install the Developer Environment' + - bash: ci/configure-bazel.sh + displayName: 'Configure Bazel for root workspace' + env: + IS_FORK: $(System.PullRequest.IsFork) + # to upload to the bazel cache + GOOGLE_APPLICATION_CREDENTIALS_CONTENT: $(GOOGLE_APPLICATION_CREDENTIALS_CONTENT) + - bash: | + set -euo pipefail + ./compatibility/build-ts-libs.sh "${BUILD_ARTIFACTSTAGINGDIRECTORY}" + displayName: 'Build typescript libraries' + - task: PublishPipelineArtifact@0 + inputs: + targetPath: $(Build.StagingDirectory)/ + artifactName: "typescript-libs" diff --git a/ci/cron/daily-compat.yml b/ci/cron/daily-compat.yml index c83f9d7d09..40f148a924 100644 --- a/ci/cron/daily-compat.yml +++ b/ci/cron/daily-compat.yml @@ -23,7 +23,17 @@ schedules: always: true jobs: + - job: compatibility_ts_libs + timeoutInMinutes: 60 + pool: + name: linux-pool + demands: assignment -equals default + steps: + - checkout: self + - template: ../compatibility_ts_libs.yml + - job: compatibility + dependsOn: compatibility_ts_libs timeoutInMinutes: 240 strategy: matrix: @@ -54,6 +64,7 @@ jobs: condition: always() - job: compatibility_windows + dependsOn: compatibility_ts_libs timeoutInMinutes: 240 pool: name: windows-pool diff --git a/compatibility/WORKSPACE b/compatibility/WORKSPACE index 20404847eb..5c9f787e53 100644 --- a/compatibility/WORKSPACE +++ b/compatibility/WORKSPACE @@ -33,6 +33,7 @@ load("@daml//bazel_tools/dev_env_tool:dev_env_tool.bzl", "dadew_sh_posix_configu dadew_sh_posix_configure() if is_windows else None +load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories") load( "@rules_haskell//haskell:nixpkgs.bzl", "haskell_register_ghc_nixpkgs", @@ -166,6 +167,40 @@ nixpkgs_package( repositories = dev_env_nix_repos, ) +nixpkgs_package( + name = "node_nix", + attribute_path = "nodejsNested", + build_file_content = 'exports_files(glob(["node_nix/**"]))', + 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 = "nodejs_dev_env", + nix_include = [ + "bin", + "include", + "lib", + "share", + ], + nix_label = "@node_nix", + nix_paths = [], + prefix = "nodejs_dev_env", + tools = [], + win_include = [ + ".", + ], + win_paths = [], + win_tool = "nodejs-10.16.3", +) + +node_repositories( + vendored_node = "@nodejs_dev_env" if is_windows else "@node_nix", + yarn_version = "1.22.4", +) + load("//:bazel-haskell-deps.bzl", "daml_haskell_deps") daml_haskell_deps() @@ -178,6 +213,9 @@ local_repository( ) daml_sdk_head( + 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", ledger_api_test_tool = "@head_sdk//:ledger-api-test-tool_deploy.jar", os_name = os_name, sdk_tarball = "@head_sdk//:sdk-release-tarball.tar.gz", @@ -185,6 +223,9 @@ daml_sdk_head( [ daml_sdk( + 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"), os_name = os_name, sdk_sha256 = version_sha256s.get(ver), test_tool_sha256 = version_sha256s.get(ver).get("test_tool"), diff --git a/compatibility/bazel-haskell-deps.bzl b/compatibility/bazel-haskell-deps.bzl index ee5be5493f..a5aebef31a 100644 --- a/compatibility/bazel-haskell-deps.bzl +++ b/compatibility/bazel-haskell-deps.bzl @@ -43,6 +43,8 @@ def daml_haskell_deps(): "async", "base", "bytestring", + "conduit", + "conduit-extra", "containers", "cryptonite", "directory", @@ -52,6 +54,7 @@ def daml_haskell_deps(): "jwt", "lens", "memory", + "mtl", "monad-loops", "network", "optparse-applicative", @@ -61,10 +64,12 @@ def daml_haskell_deps(): "semver", "split", "tagged", + "tar-conduit", "tasty", "tasty-hunit", "text", "optparse-applicative", + "unix-compat", "unordered-containers", ] + (["unix"] if not is_windows else ["Win32"]), stack = "@stack_windows//:stack.exe" if is_windows else None, diff --git a/compatibility/bazel_tools/BUILD b/compatibility/bazel_tools/BUILD index 5bcf071303..b77afee52f 100644 --- a/compatibility/bazel_tools/BUILD +++ b/compatibility/bazel_tools/BUILD @@ -1,4 +1,5 @@ exports_files([ "daml_ledger_test.sh", + "create_daml_app_test.sh", "sandbox-with-postgres.sh", ]) diff --git a/compatibility/bazel_tools/create-daml-app/BUILD.bazel b/compatibility/bazel_tools/create-daml-app/BUILD.bazel new file mode 100644 index 0000000000..038459a180 --- /dev/null +++ b/compatibility/bazel_tools/create-daml-app/BUILD.bazel @@ -0,0 +1,37 @@ +# Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +load( + "@daml//bazel_tools:haskell.bzl", + "da_haskell_binary", + "da_haskell_library", +) + +da_haskell_binary( + name = "runner", + srcs = ["Main.hs"], + hackage_deps = [ + "aeson", + "base", + "bytestring", + "conduit", + "conduit-extra", + "containers", + "extra", + "filepath", + "jwt", + "mtl", + "unix-compat", + "process", + "tagged", + "tar-conduit", + "tasty", + "tasty-hunit", + "text", + ], + visibility = ["//visibility:public"], + deps = [ + "//bazel_tools/test_utils", + "@rules_haskell//tools/runfiles", + ], +) diff --git a/compatibility/bazel_tools/create-daml-app/Main.hs b/compatibility/bazel_tools/create-daml-app/Main.hs new file mode 100644 index 0000000000..b86c4f8656 --- /dev/null +++ b/compatibility/bazel_tools/create-daml-app/Main.hs @@ -0,0 +1,239 @@ +-- 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 +import Control.Applicative +import Control.Exception.Extra +import Control.Monad +import DA.Test.Process +import DA.Test.Tar +import DA.Test.Util +import qualified Data.Aeson as Aeson +import Data.Conduit ((.|), runConduitRes) +import qualified Data.Conduit.Combinators as Conduit +import qualified Data.Conduit.Tar as Tar +import qualified Data.Conduit.Zlib as Zlib +import Data.List.Extra +import Data.Maybe +import Data.Proxy +import Data.Tagged +import qualified Data.Text as T +import System.Directory.Extra +import System.Environment.Blank +import System.FilePath +import System.IO.Extra +import System.Process +import Test.Tasty +import Test.Tasty.HUnit +import Test.Tasty.Options + +data Tools = Tools + { damlBinary :: FilePath + , sandboxBinary :: FilePath + , sandboxArgs :: [String] + , jsonApiBinary :: FilePath + , jsonApiArgs :: [String] + , damlLedgerPath :: FilePath + , damlTypesPath :: FilePath + , damlReactPath :: FilePath + , yarnPath :: FilePath + } + +newtype DamlOption = DamlOption FilePath +instance IsOption DamlOption where + defaultValue = DamlOption $ "daml" + parseValue = Just . DamlOption + optionName = Tagged "daml" + optionHelp = Tagged "runfiles path to the daml executable" + +newtype SandboxOption = SandboxOption FilePath +instance IsOption SandboxOption where + defaultValue = SandboxOption $ "sandbox" + parseValue = Just . SandboxOption + optionName = Tagged "sandbox" + optionHelp = Tagged "runfiles path to the sandbox executable" + +newtype SandboxArgsOption = SandboxArgsOption { unSandboxArgsOption :: [String] } +instance IsOption SandboxArgsOption where + defaultValue = SandboxArgsOption [] + parseValue = Just . SandboxArgsOption . (:[]) + optionName = Tagged "sandbox-arg" + optionHelp = Tagged "extra arguments to pass to sandbox executable" + optionCLParser = concatMany (mkOptionCLParser mempty) + where concatMany = fmap (SandboxArgsOption . concat) . many . fmap unSandboxArgsOption + +newtype JsonApiOption = JsonApiOption FilePath +instance IsOption JsonApiOption where + defaultValue = JsonApiOption $ "json-api" + parseValue = Just . JsonApiOption + optionName = Tagged "json-api" + optionHelp = Tagged "runfiles path to the json-api executable" + +newtype JsonApiArgsOption = JsonApiArgsOption { unJsonApiArgsOption :: [String] } +instance IsOption JsonApiArgsOption where + defaultValue = JsonApiArgsOption [] + parseValue = Just . JsonApiArgsOption . (:[]) + optionName = Tagged "json-api-arg" + optionHelp = Tagged "extra arguments to pass to json-api executable" + optionCLParser = concatMany (mkOptionCLParser mempty) + where concatMany = fmap (JsonApiArgsOption . concat) . many . fmap unJsonApiArgsOption + +newtype DamlLedgerOption = DamlLedgerOption FilePath +instance IsOption DamlLedgerOption where + defaultValue = DamlLedgerOption [] + parseValue = Just . DamlLedgerOption + optionName = Tagged "daml-ledger" + optionHelp = Tagged "path to extracted daml-ledger package" + +newtype DamlTypesOption = DamlTypesOption FilePath +instance IsOption DamlTypesOption where + defaultValue = DamlTypesOption [] + parseValue = Just . DamlTypesOption + optionName = Tagged "daml-types" + optionHelp = Tagged "path to extracted daml-types package" + +newtype DamlReactOption = DamlReactOption FilePath +instance IsOption DamlReactOption where + defaultValue = DamlReactOption [] + parseValue = Just . DamlReactOption + optionName = Tagged "daml-react" + optionHelp = Tagged "path to extracted daml-react package" + +newtype YarnOption = YarnOption FilePath +instance IsOption YarnOption where + defaultValue = YarnOption "" + parseValue = Just . YarnOption + optionName = Tagged "yarn" + optionHelp = Tagged "path to yarn" + +withTools :: (IO Tools -> TestTree) -> TestTree +withTools tests = do + askOption $ \(DamlOption damlPath) -> do + askOption $ \(SandboxOption sandboxPath) -> do + askOption $ \(SandboxArgsOption sandboxArgs) -> do + askOption $ \(JsonApiOption jsonApiPath) -> do + askOption $ \(JsonApiArgsOption jsonApiArgs) -> do + askOption $ \(DamlLedgerOption damlLedgerPath) -> do + askOption $ \(DamlTypesOption damlTypesPath) -> do + askOption $ \(DamlReactOption damlReactPath) -> do + askOption $ \(YarnOption yarnPath) -> do + let createRunfiles :: IO (FilePath -> FilePath) + createRunfiles = do + runfiles <- Bazel.Runfiles.create + mainWorkspace <- fromMaybe "compatibility" <$> getEnv "TEST_WORKSPACE" + pure (\path -> Bazel.Runfiles.rlocation runfiles $ mainWorkspace path) + withResource createRunfiles (\_ -> pure ()) $ \locateRunfiles -> do + let tools = do + damlBinary <- locateRunfiles <*> pure damlPath + sandboxBinary <- locateRunfiles <*> pure sandboxPath + jsonApiBinary <- locateRunfiles <*> pure jsonApiPath + pure Tools + { damlBinary + , sandboxBinary + , jsonApiBinary + , sandboxArgs + , jsonApiArgs + , damlLedgerPath + , damlTypesPath + , damlReactPath + , yarnPath + } + tests tools + +main :: IO () +main = do + setEnv "TASTY_NUM_THREADS" "1" True + let options = + [ Option @DamlOption Proxy + , Option @SandboxOption Proxy + , Option @SandboxArgsOption Proxy + , Option @JsonApiOption Proxy + , Option @JsonApiArgsOption Proxy + , Option @DamlLedgerOption Proxy + , Option @DamlTypesOption Proxy + , Option @DamlReactOption Proxy + , Option @YarnOption Proxy + ] + let ingredients = defaultIngredients ++ [includingOptions options] + defaultMainWithIngredients ingredients $ + withTools $ \getTools -> do + testGroup "Create DAML App tests" + [ test getTools + ] + where + test getTools = testCaseSteps "Getting Starte Guide" $ \step -> withTempDir $ \tmpDir -> do + Tools{..} <- getTools + -- daml codegen js assumes Yarn is in PATH. + -- To keep things as simple as possible, we just use `setEnv` + -- instead of copying `withEnv` from the `daml` workspace. + path <- getSearchPath + setEnv "PATH" (intercalate [searchPathSeparator] (takeDirectory yarnPath : path)) True + step "Create app from template" + withCurrentDirectory tmpDir $ do + callProcess damlBinary ["new", "create-daml-app", "create-daml-app"] + let cdaDir = tmpDir "create-daml-app" + -- First test the base application (without the user-added feature). + withCurrentDirectory cdaDir $ do + step "Build DAML model for base application" + callProcess damlBinary ["build"] + step "Set up TypeScript libraries and Yarn workspaces for codegen" + setupYarnEnv tmpDir (Workspaces ["create-daml-app/daml.js"]) + [(DamlTypes, damlTypesPath), (DamlLedger, damlLedgerPath)] + step "Run JavaScript codegen" + callProcess damlBinary ["codegen", "js", "-o", "daml.js", ".daml/dist/create-daml-app-0.1.0.dar"] + assertFileDoesNotExist (cdaDir "ui" "build" "index.html") + withCurrentDirectory (cdaDir "ui") $ do + -- NOTE(MH): We set up the yarn env again to avoid having all the + -- dependencies of the UI already in scope when `daml2js` runs + -- `yarn install`. Some of the UI dependencies are a bit flaky to + -- install and might need some retries. + 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 dependencies for UI" + retry 3 (callProcessSilent yarnPath ["install"]) + step "Run linter" + callProcessSilent yarnPath ["lint", "--max-warnings", "0"] + step "Build the application UI" + callProcessSilent yarnPath ["build"] + assertFileExists (cdaDir "ui" "build" "index.html") + +data TsLibrary + = DamlLedger + | DamlReact + | DamlTypes + deriving (Bounded, Enum) + +newtype Workspaces = Workspaces [FilePath] + +tsLibraryName :: TsLibrary -> String +tsLibraryName = \case + DamlLedger -> "daml-ledger" + DamlReact -> "daml-react" + DamlTypes -> "daml-types" + +-- NOTE(MH): In some tests we need our TS libraries like `@daml/types` in +-- scope. We achieve this by putting a `package.json` file further up in the +-- directory tree. This file sets up a yarn workspace that includes the TS +-- libraries via the `resolutions` field. +setupYarnEnv :: FilePath -> Workspaces -> [(TsLibrary, FilePath)] -> IO () +setupYarnEnv rootDir (Workspaces workspaces) tsLibs = do + forM_ tsLibs $ \(tsLib, libLocation) -> do + let name = tsLibraryName tsLib + removePathForcibly (rootDir name) + runConduitRes + $ Conduit.sourceFile libLocation + .| Zlib.ungzip + .| Tar.untar (restoreFile (\a b -> fail (T.unpack $ a <> b)) (rootDir name)) + Aeson.encodeFile (rootDir "package.json") $ Aeson.object + [ "private" Aeson..= True + , "workspaces" Aeson..= workspaces + , "resolutions" Aeson..= Aeson.object + [ pkgName Aeson..= ("file:./" ++ name) + | (tsLib, _) <- tsLibs + , let name = tsLibraryName tsLib + , let pkgName = "@" <> T.replace "-" "/" (T.pack name) + ] + ] diff --git a/compatibility/bazel_tools/create_daml_app_test.sh b/compatibility/bazel_tools/create_daml_app_test.sh new file mode 100755 index 0000000000..cf616e2eb8 --- /dev/null +++ b/compatibility/bazel_tools/create_daml_app_test.sh @@ -0,0 +1,33 @@ +#!/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 -euox pipefail + +RUNNER="$(rlocation "$TEST_WORKSPACE/$1")" +DAML="$(rlocation "$TEST_WORKSPACE/$2")" +SANDBOX="$(rlocation "$TEST_WORKSPACE/$3")" +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")" + +"$RUNNER" \ + --daml "$DAML" \ + --sandbox "$SANDBOX" \ + --json-api "$JSON_API" \ + --daml-types "$DAML_TYPES" \ + --daml-ledger "$DAML_LEDGER" \ + --daml-react "$DAML_REACT" \ + --yarn "$YARN" \ + "${@:9}" diff --git a/compatibility/bazel_tools/daml_ledger/BUILD.bazel b/compatibility/bazel_tools/daml_ledger/BUILD.bazel index 9a04becfe8..711f4afea9 100644 --- a/compatibility/bazel_tools/daml_ledger/BUILD.bazel +++ b/compatibility/bazel_tools/daml_ledger/BUILD.bazel @@ -43,6 +43,7 @@ da_haskell_binary( visibility = ["//visibility:public"], deps = [ ":sandbox-helper", + "//bazel_tools/test_utils", "@rules_haskell//tools/runfiles", ], ) diff --git a/compatibility/bazel_tools/daml_ledger/Main.hs b/compatibility/bazel_tools/daml_ledger/Main.hs index aa04bfe796..29b58db367 100644 --- a/compatibility/bazel_tools/daml_ledger/Main.hs +++ b/compatibility/bazel_tools/daml_ledger/Main.hs @@ -4,7 +4,7 @@ module Main (main) where import Control.Applicative (many) -import Control.Monad (unless, void) +import DA.Test.Process import Data.Function ((&)) import Data.Maybe (fromMaybe) import Data.Proxy (Proxy (..)) @@ -12,11 +12,8 @@ import Data.Tagged (Tagged (..)) import System.Directory.Extra (withCurrentDirectory) import System.Environment (lookupEnv) import System.Environment.Blank (setEnv) -import System.Exit (ExitCode(..), exitFailure) import System.FilePath ((), takeBaseName) -import System.IO (hPutStrLn, stderr) import System.IO.Extra (withTempDir,writeFileUTF8) -import System.Process (CreateProcess,proc,readCreateProcessWithExitCode) import Test.Tasty (TestTree,askOption,defaultMainWithIngredients,defaultIngredients,includingOptions,testGroup,withResource) import Test.Tasty.Options (IsOption(..), OptionDescription(..), mkOptionCLParser) import Test.Tasty.HUnit (testCaseSteps, testCase) @@ -252,21 +249,3 @@ writeMinimalProject (SdkVersion sdkVersion) = do , "module Main where" , "template T with p : Party where signatory p" ] - -callProcessSilent :: FilePath -> [String] -> IO () -callProcessSilent cmd args = - void $ run (proc cmd args) - -callProcessForStdout :: FilePath -> [String] -> IO String -callProcessForStdout cmd args = - run (proc cmd args) - -run :: CreateProcess -> IO String -run cp = do - (exitCode, out, err) <- readCreateProcessWithExitCode cp "" - unless (exitCode == ExitSuccess) $ do - hPutStrLn stderr $ "Failure: Command \"" <> show cp <> "\" exited with " <> show exitCode - hPutStrLn stderr $ unlines ["stdout: ", out] - hPutStrLn stderr $ unlines ["stderr: ", err] - exitFailure - return out diff --git a/compatibility/bazel_tools/daml_sdk.bzl b/compatibility/bazel_tools/daml_sdk.bzl index 53cb25d439..4b84d65bf2 100644 --- a/compatibility/bazel_tools/daml_sdk.bzl +++ b/compatibility/bazel_tools/daml_sdk.bzl @@ -56,6 +56,20 @@ def _daml_sdk_impl(ctx): output = "extracted-test-tool", ) + for lib in ["types", "ledger", "react"]: + tarball_name = "daml_{}_tarball".format(lib) + if getattr(ctx.attr, tarball_name): + ctx.symlink( + getattr(ctx.attr, tarball_name), + "daml-{}.tgz".format(lib), + ) + else: + ctx.download( + output = "daml-{}.tgz".format(lib), + url = "https://registry.npmjs.org/@daml/{}/-/{}-{}.tgz".format(lib, lib, ctx.attr.version), + sha256 = getattr(ctx.attr, "daml_{}_sha256".format(lib)), + ) + ctx.symlink(out_dir.get_child("daml").get_child("daml" + (".exe" if is_windows else "")), "sdk/bin/daml") ctx.file( "sdk/daml-config.yaml", @@ -107,6 +121,7 @@ filegroup( name = "dar-files", srcs = glob(["extracted-test-tool/ledger/test-common/**"]), ) +exports_files(["daml-types.tgz", "daml-ledger.tgz", "daml-react.tgz"]) """, ) return None @@ -120,6 +135,12 @@ _daml_sdk = repository_rule( "sdk_tarball": attr.label(allow_single_file = True, mandatory = False), "test_tool_sha256": attr.string(mandatory = False), "test_tool": attr.label(allow_single_file = True, mandatory = False), + "daml_types_tarball": attr.label(allow_single_file = True, mandatory = False), + "daml_ledger_tarball": attr.label(allow_single_file = True, mandatory = False), + "daml_react_tarball": attr.label(allow_single_file = True, mandatory = False), + "daml_types_sha256": attr.string(mandatory = False), + "daml_ledger_sha256": attr.string(mandatory = False), + "daml_react_sha256": attr.string(mandatory = False), }, ) @@ -130,12 +151,15 @@ def daml_sdk(version, **kwargs): **kwargs ) -def daml_sdk_head(sdk_tarball, ledger_api_test_tool, **kwargs): +def daml_sdk_head(sdk_tarball, ledger_api_test_tool, daml_types_tarball, daml_ledger_tarball, daml_react_tarball, **kwargs): version = "0.0.0" _daml_sdk( name = "daml-sdk-{}".format(version), version = version, sdk_tarball = sdk_tarball, test_tool = ledger_api_test_tool, + daml_types_tarball = daml_types_tarball, + daml_ledger_tarball = daml_ledger_tarball, + daml_react_tarball = daml_react_tarball, **kwargs ) diff --git a/compatibility/bazel_tools/test_utils/BUILD b/compatibility/bazel_tools/test_utils/BUILD new file mode 100644 index 0000000000..dd44f9b6a6 --- /dev/null +++ b/compatibility/bazel_tools/test_utils/BUILD @@ -0,0 +1,31 @@ +# Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +load( + "@daml//bazel_tools:haskell.bzl", + "da_haskell_library", +) + +da_haskell_library( + name = "test_utils", + srcs = glob(["DA/Test/**/*.hs"]), + hackage_deps = [ + "base", + "bytestring", + "tar-conduit", + "conduit", + "directory", + "extra", + "filepath", + "network", + "process", + "safe-exceptions", + "tasty", + "tasty-hunit", + "text", + "unix-compat", + ], + visibility = ["//visibility:public"], + deps = [ + ], +) diff --git a/compatibility/bazel_tools/test_utils/DA/Test/Process.hs b/compatibility/bazel_tools/test_utils/DA/Test/Process.hs new file mode 100644 index 0000000000..a22bf2664b --- /dev/null +++ b/compatibility/bazel_tools/test_utils/DA/Test/Process.hs @@ -0,0 +1,31 @@ +-- Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. +-- SPDX-License-Identifier: Apache-2.0 + +module DA.Test.Process + ( callProcessSilent + , callProcessForStdout + ) where + +import Control.Monad +import System.Exit +import System.IO +import System.Process + +callProcessSilent :: FilePath -> [String] -> IO () +callProcessSilent cmd args = + void $ run (proc cmd args) + +callProcessForStdout :: FilePath -> [String] -> IO String +callProcessForStdout cmd args = + run (proc cmd args) + +run :: CreateProcess -> IO String +run cp = do + (exitCode, out, err) <- readCreateProcessWithExitCode cp "" + unless (exitCode == ExitSuccess) $ do + hPutStrLn stderr $ "Failure: Command \"" <> show cp <> "\" exited with " <> show exitCode + hPutStrLn stderr $ unlines ["stdout: ", out] + hPutStrLn stderr $ unlines ["stderr: ", err] + exitFailure + return out + diff --git a/compatibility/bazel_tools/test_utils/DA/Test/Tar.hs b/compatibility/bazel_tools/test_utils/DA/Test/Tar.hs new file mode 100644 index 0000000000..a2c791687d --- /dev/null +++ b/compatibility/bazel_tools/test_utils/DA/Test/Tar.hs @@ -0,0 +1,79 @@ +-- Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. +-- SPDX-License-Identifier: Apache-2.0 + +-- This matches the code in Data.Conduit.Tar.Extra +-- in da-hs-base. +module DA.Test.Tar (restoreFile) where + +import Conduit +import Control.Monad +import qualified Data.ByteString as BS +import qualified Data.Conduit.Tar as Tar +import Data.List.Extra +import Data.Maybe +import qualified Data.Text as T +import System.Directory +import System.Info.Extra +import System.FilePath +import System.PosixCompat.Files (createSymbolicLink, setFileMode) + +-- | This is intended to be used in combination with `Data.Conduit.Tar.untar`. +-- It writes the given file to the given directory stripping the first component +-- thereby emulating tar’s --strip-components=1 option. +restoreFile + :: MonadResource m + => (T.Text -> T.Text -> m ()) + -> FilePath + -> Tar.FileInfo + -> ConduitT BS.ByteString Void m () +restoreFile throwError extractPath info = do + let oldPath = Tar.decodeFilePath (Tar.filePath info) + newPath = dropDirectory1 oldPath + targetPath = extractPath dropTrailingPathSeparator newPath + parentPath = takeDirectory targetPath + + when (pathEscapes newPath) $ do + lift $ throwError + "file path escapes tarball." + ("path = " <> T.pack oldPath) + + when (notNull newPath) $ do + case Tar.fileType info of + Tar.FTNormal -> do + liftIO $ createDirectoryIfMissing True parentPath + Conduit.sinkFileBS targetPath + liftIO $ setFileMode targetPath (Tar.fileMode info) + Tar.FTDirectory -> do + liftIO $ createDirectoryIfMissing True targetPath + Tar.FTSymbolicLink bs | not isWindows -> do + let path = Tar.decodeFilePath bs + unless (isRelative path) $ + lift $ throwError + "symbolic link target is absolute." + ("target = " <> T.pack path <> ", path = " <> T.pack oldPath) + + when (pathEscapes (takeDirectory newPath path)) $ + lift $ throwError + "symbolic link target escapes tarball." + ("target = " <> T.pack path <> ", path = " <> T.pack oldPath) + + liftIO $ createDirectoryIfMissing True parentPath + liftIO $ createSymbolicLink path targetPath + unsupported -> + lift $ throwError + "unsupported file type." + ("type = " <> T.pack (show unsupported) <> ", path = " <> T.pack oldPath) + +-- | Check whether a relative path escapes its root. +pathEscapes :: FilePath -> Bool +pathEscapes path = isNothing $ foldM step "" (splitDirectories path) + where + step acc "." = Just acc + step "" ".." = Nothing + step acc ".." = Just (takeDirectory acc) + step acc name = Just (acc name) + +-- | Drop first component from path +dropDirectory1 :: FilePath -> FilePath +dropDirectory1 = joinPath . tail . splitPath + diff --git a/compatibility/bazel_tools/test_utils/DA/Test/Util.hs b/compatibility/bazel_tools/test_utils/DA/Test/Util.hs new file mode 100644 index 0000000000..7395b712c5 --- /dev/null +++ b/compatibility/bazel_tools/test_utils/DA/Test/Util.hs @@ -0,0 +1,17 @@ +-- Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. +-- SPDX-License-Identifier: Apache-2.0 + +module DA.Test.Util + ( assertFileExists + , assertFileDoesNotExist + ) where + +import System.Directory +import Test.Tasty.HUnit + +assertFileExists :: FilePath -> IO () +assertFileExists file = doesFileExist file >>= assertBool (file ++ " was expected to exist, but does not exist") + +assertFileDoesNotExist :: FilePath -> IO () +assertFileDoesNotExist file = doesFileExist file >>= assertBool (file ++ " was expected to not exist, but does exist") . not + diff --git a/compatibility/bazel_tools/testing.bzl b/compatibility/bazel_tools/testing.bzl index ca9363738f..226fa9ed23 100644 --- a/compatibility/bazel_tools/testing.bzl +++ b/compatibility/bazel_tools/testing.bzl @@ -22,6 +22,12 @@ excluded_test_tool_tests = { # Fix for https://github.com/digital-asset/daml/issues/5562 "ContractKeysIT", ], + "1.1.0-snapshot.20200506.4107.0.7e448d81": [ + # 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", @@ -58,6 +64,12 @@ excluded_test_tool_tests = { # Fix for https://github.com/digital-asset/daml/issues/5562 "ContractKeysIT", ], + "1.1.0-snapshot.20200506.4107.0.7e448d81": [ + # 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": [ @@ -76,6 +88,10 @@ excluded_test_tool_tests = { # This restriction has been removed in https://github.com/digital-asset/daml/pull/5611. "ContractKeysSubmitterIsMaintainerIT", ], + "1.1.0-snapshot.20200506.4107.0.7e448d81": [ + # 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", @@ -98,6 +114,10 @@ excluded_test_tool_tests = { # This restriction has been removed in https://github.com/digital-asset/daml/pull/5611. "ContractKeysSubmitterIsMaintainerIT", ], + "1.1.0-snapshot.20200506.4107.0.7e448d81": [ + # 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 +138,12 @@ excluded_test_tool_tests = { # Fix for https://github.com/digital-asset/daml/issues/5562 "ContractKeysIT", ], + "1.1.0-snapshot.20200506.4107.0.7e448d81": [ + # 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", @@ -139,6 +165,20 @@ excluded_test_tool_tests = { "ContractKeysIT", ], }, + "1.1.0-snapshot.20200506.4107.0.7e448d81": { + "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 @@ -209,6 +249,51 @@ def daml_ledger_test( **kwargs ) +def create_daml_app_test( + name, + daml, + sandbox, + json_api, + daml_types, + daml_react, + daml_ledger, + sandbox_args = [], + json_api_args = [], + data = [], + **kwargs): + native.sh_test( + name = name, + # See the comment on daml_ledger_test for why + # we need the sh_test. + srcs = ["//bazel_tools:create_daml_app_test.sh"], + args = [ + "$(rootpath //bazel_tools/create-daml-app:runner)", + #"--daml", + "$(rootpath %s)" % daml, + #"--sandbox", + "$(rootpath %s)" % sandbox, + #"--json-api", + "$(rootpath %s)" % json_api, + "$(rootpath %s)" % daml_types, + "$(rootpath %s)" % daml_ledger, + "$(rootpath %s)" % daml_react, + "$(rootpath @nodejs//:yarn)", + ] + _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", + # Deduplicate if daml and sandbox come from the same release. + daml, + sandbox, + json_api, + daml_types, + daml_react, + daml_ledger, + ]).to_list(), + **kwargs + ) + def sdk_platform_test(sdk_version, platform_version): # SDK components daml_assistant = "@daml-sdk-{sdk_version}//:daml".format( @@ -226,10 +311,16 @@ def sdk_platform_test(sdk_version, platform_version): platform_version = platform_version, ) + json_api = "@daml-sdk-{platform_version}//:daml".format( + platform_version = platform_version, + ) + # We need to use weak seeding to avoid our tests timing out # if the CI machine does not have enough entropy. sandbox_args = ["sandbox", "--contract-id-seeding=testing-weak"] + json_api_args = ["json-api"] + # ledger-api-test-tool test-cases name = "ledger-api-test-tool-{sdk_version}-platform-{platform_version}".format( sdk_version = version_to_name(sdk_version), @@ -290,3 +381,18 @@ def sdk_platform_test(sdk_version, platform_version): size = "large", tags = extra_tags(sdk_version, platform_version), ) + create_daml_app_test( + name = "create-daml-app-{sdk_version}-platform-{platform_version}".format(sdk_version = version_to_name(sdk_version), platform_version = version_to_name(platform_version)), + daml = daml_assistant, + sandbox = sandbox, + json_api = json_api, + 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), + sandbox_args = sandbox_args, + json_api_args = json_api_args, + size = "large", + # Yarn gets really unhappy on Windows if it is called in parallel + # so we mark this exclusive for now. + tags = extra_tags(sdk_version, platform_version) + (["exclusive"] if is_windows else []), + ) diff --git a/compatibility/build-ts-libs.sh b/compatibility/build-ts-libs.sh new file mode 100755 index 0000000000..a10f61316b --- /dev/null +++ b/compatibility/build-ts-libs.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +set -eou pipefail + +cd "$(dirname "$0")/.." + +eval "$(./dev-env/bin/dade-assist)" + +# We allow overwriting this since on CI we build this in a separate step and upload it first +# before fetching it in another step. +HEAD_TARGET_DIR=${1:-compatibility/head_sdk} + +function cleanup { + rm -rf "daml-types-0.0.0.tar.gz" "daml-ledger-0.0.0.tar.gz" "daml-react-0.0.0.tar.gz" +} + +trap cleanup EXIT + +bazel run //language-support/ts/daml-types:npm_package.pack +bazel run //language-support/ts/daml-ledger:npm_package.pack +bazel run //language-support/ts/daml-react:npm_package.pack + +cp -f daml-types-0.0.0.tgz daml-react-0.0.0.tgz daml-ledger-0.0.0.tgz "$HEAD_TARGET_DIR" diff --git a/compatibility/deps.bzl b/compatibility/deps.bzl index b1a4baaef6..fa0757e0e2 100644 --- a/compatibility/deps.bzl +++ b/compatibility/deps.bzl @@ -36,6 +36,8 @@ load( "rules_haskell_version", "rules_nixpkgs_sha256", "rules_nixpkgs_version", + "rules_nodejs_sha256", + "rules_nodejs_version", "zlib_sha256", "zlib_version", ) @@ -80,3 +82,15 @@ def daml_deps(): urls = ["https://github.com/madler/zlib/archive/{}.tar.gz".format(zlib_version)], sha256 = zlib_sha256, ) + + if "build_bazel_rules_nodejs" not in native.existing_rules(): + http_archive( + name = "build_bazel_rules_nodejs", + urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/{}/rules_nodejs-{}.tar.gz".format(rules_nodejs_version, rules_nodejs_version)], + sha256 = rules_nodejs_sha256, + patches = [ + # Work around for https://github.com/bazelbuild/rules_nodejs/issues/1565 + "@daml//bazel_tools:rules_nodejs_npm_cli_path.patch", + ], + patch_args = ["-p1"], + ) diff --git a/compatibility/versions.bzl b/compatibility/versions.bzl index 970a1e1339..e8fc335c53 100644 --- a/compatibility/versions.bzl +++ b/compatibility/versions.bzl @@ -1,5 +1,7 @@ # Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +# This file is autogenerated and should not be modified manually. +# Update versions/UpdateVersions.hs instead. sdk_versions = [ "1.0.0", "1.0.1-snapshot.20200417.3908.1.722bac90", @@ -7,6 +9,7 @@ sdk_versions = [ "1.0.1", "1.1.0-snapshot.20200422.3991.0.6391ee9f", "1.1.0-snapshot.20200430.4057.0.681c862d", + "1.1.0-snapshot.20200506.4107.0.7e448d81", "0.0.0", ] platform_versions = [ @@ -16,6 +19,7 @@ platform_versions = [ "1.0.1", "1.1.0-snapshot.20200422.3991.0.6391ee9f", "1.1.0-snapshot.20200430.4057.0.681c862d", + "1.1.0-snapshot.20200506.4107.0.7e448d81", "0.0.0", ] stable_versions = [ @@ -30,35 +34,62 @@ version_sha256s = { "macos": "feb2086a9a01048300270c71eb212c8541cdec1082f541408250d6124bc307a8", "windows": "2028efe1f505c1994e1abc41c0fb5181669cd46834818aa8276d04b0fb6eb034", "test_tool": "cf66efafd9490e1256e825f377b208b8ae90151f56e411b596fbaaef91353e14", + "daml_types": "f85e5dd7ef1c5733826c1c79e316d2733344ac0da67f0d381ba70fc83a64fc78", + "daml_ledger": "5aab9a6cbdc987fc4279481152ff65bda503425f7e338c5123237b283aae44d6", + "daml_react": "30ab9db8a20df6cbfed7c1b42a45ca0ea55af6e150c013105d46c94afa5f9a46", }, "1.0.1-snapshot.20200417.3908.1.722bac90": { "linux": "aaf832ceda1a66a8469460d5a4b6c14f681ce692d4e9ef6010896febbaf4b6e1", "macos": "c2f89e394332b6ff19f547ccb399bacd3cd50d2493249c2d3a1ecaad0b87ac8b", "windows": "7033ef0c5cbe75910a27730643076d3919b5694f3dc75f8daa57d5c22d04c593", "test_tool": "762cd4836a8359dca0fb3271ba2e1d0629138f7d8d914298324418a174c5d22a", + "daml_types": "5ef8c162c0ea7d9bb8e40e2ea1bc632e0e842c33d2da6b45ad9e14c34fe41d66", + "daml_ledger": "af92004ec98f9439785a3a8cf9659341ee000c47a0d63d0088668915ed1462e7", + "daml_react": "562609f975c4d98d202b8400cb1f80398c7b38195546b73cb57d3257ec384446", }, "1.0.1-snapshot.20200424.3917.0.16093690": { "linux": "c46d3b24b34078e974a958cd30deb8628a42d85ac2c0159341ad13eff25a7d22", "macos": "f8cae6ff524d0050e323218196d47c7c8ecd0399dca8a0571324ca3f4380da23", "windows": "2c884302b4cc80777cd084dc68d58f00102a043e4f1ac001d3be023d743e2670", "test_tool": "a88bf4594aea82a218871b6966d298ddafcd7a9deb83e337e83ed100e86ea316", + "daml_types": "6ce2173fe407e6e5c9496b58a66f48db8f191c6c2bf66d1db3e2318d12d12f62", + "daml_ledger": "872733ef3dbd19a972e360935d747e3673ab1b972f713db08ce89f5e83c802a3", + "daml_react": "705d7ad62204a389de5cfaf0c0cc50e071aedc9168247ea806a64dc430f7c306", }, "1.0.1": { "linux": "9cff04c29bb28503b41dcde310a2f3307984b1d976f8bccfb38268672e730c8f", "macos": "a7e094e2d8766c852a247e0601b7c062c435b0d91f9ab256bbf4fcb40971ee36", "windows": "41ecd44f3ea7c2a64a7f677f36b3f26dabaa5de913bc57bd680ea8f40f00ff0b", "test_tool": "038de725b74f128fc0cb6f3ce8eef7d62da9527d0cbf25b93b7c1623bbb413c9", + "daml_types": "c50d5f37dbb42f45ae1f4f4013a72006ae7bbd531c68c363b54212a3458c5b6e", + "daml_ledger": "12fc3ef723171162128fb5951dec5452f75b1a3de7facf85a2b0126f46de159b", + "daml_react": "dc4cbf95f22cc0300af1f450be316bd55ebbc2816e9806231b13edce85bea44c", }, "1.1.0-snapshot.20200422.3991.0.6391ee9f": { "linux": "d3bddaa903ebaebb6f714a3ac39598ba7fd71e8b80636c1275054ed7b883a0d9", "macos": "66f1713057800ed75db1b967a8ea2d9b6c18da1a76b8224abdec0d33ed5533ae", "windows": "2c779776d923d990870fbb2aa1c71e6081258a9b9ccc7cf8242c419a765d4821", "test_tool": "649ecf7a7e98caef7dac20082526444b33d85dfe79b4b9b66d069ad67aac74fa", + "daml_types": "cad498131eb60f2651303cc26d520fe3614750ef2705db23ffbefeae0be3b7cf", + "daml_ledger": "527b6353c6d88d79f69aa78a51b9707e541555c42f1a2331f2bf075a730b3305", + "daml_react": "18f3363aa9c4f32b1fac48028a73a56dfdd8a73058d4b8d119adb16c72cb70fb", }, "1.1.0-snapshot.20200430.4057.0.681c862d": { "linux": "199cb51a5b406c8968f2352fe04ace8368ce95beaee81f19073b0f998c5518bf", "macos": "f4844d54a62999ced90a3435a6c7b97c21e96882151489451d88774fdd4a05bc", "windows": "1367d103cd514c759dc55ff4600cc73dd68d67cf89fa6ec5260634b0bdad08d0", "test_tool": "7f693a9384df622136d5a039fdd5ffd22a9fd12439064017f339002fbf509da2", + "daml_types": "3329d1c1fc7382e86af2bff305effd31e22387149dc3231e9ed03ccd1b25bc30", + "daml_ledger": "1c5a3eb196a90685f406d4a91a8514ab22d0ebeaf1302f22854c6ac1e49c5ae4", + "daml_react": "8a217c7af7c828f41b532640914ed83f3d19bf5b8b42a52671db427ed9dd770c", + }, + "1.1.0-snapshot.20200506.4107.0.7e448d81": { + "linux": "36d192d7004b2d307437a97bf86af9ffdea8adde99419867cf51740dd7a89a94", + "macos": "2359fb405497784781c0c9a94737d6c1999e15a33789eda1372e7bea57068c71", + "windows": "d1e521ca254d6768acb4efc0f3e53e8f464a0f09948c60128fafdcddc96d2232", + "test_tool": "1f6dacd2e37022bb3d6de567408f4b0f009281115513e4c6a7c4ace11f093361", + "daml_types": "987560f3b2268bc8dffcbad2f257a182f7145884afc9c69c62658cea037459c1", + "daml_ledger": "3762cd5185d69121a3277fe2d3520cf2762e23e09049ef771d3e44c8c5891f2f", + "daml_react": "35d892da1844358e032adbfd987c5fcf7eb279209d846126c37c8d993401a792", }, } diff --git a/compatibility/versions/UpdateVersions.hs b/compatibility/versions/UpdateVersions.hs index f77e6306d9..de10f171f7 100644 --- a/compatibility/versions/UpdateVersions.hs +++ b/compatibility/versions/UpdateVersions.hs @@ -73,6 +73,9 @@ renderVersionsFile (Versions (Set.toAscList -> versions)) checksums = , " \"macos\": " <> renderDigest macosHash <> "," , " \"windows\": " <> renderDigest windowsHash <> "," , " \"test_tool\": " <> renderDigest testToolHash <> "," + , " \"daml_types\": " <> renderDigest damlTypesHash <> "," + , " \"daml_ledger\": " <> renderDigest damlLedgerHash <> "," + , " \"daml_react\": " <> renderDigest damlReactHash <> "," , " }," ] renderDigest digest = T.pack $ show (convertToBase Base16 digest :: ByteString) @@ -88,13 +91,23 @@ data Checksums = Checksums , macosHash :: Digest SHA256 , windowsHash :: Digest SHA256 , testToolHash :: Digest SHA256 + , damlTypesHash :: Digest SHA256 + , damlLedgerHash :: Digest SHA256 + , damlReactHash :: Digest SHA256 } getChecksums :: Version -> IO Checksums getChecksums ver = do putStrLn ("Requesting hashes for " <> SemVer.toString ver) - [linuxHash, macosHash, windowsHash, testToolHash] <- - forConcurrently [sdkUrl "linux", sdkUrl "macos", sdkUrl "windows", testToolUrl] $ \url -> do + [ linuxHash, macosHash, windowsHash, testToolHash, + 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) @@ -107,6 +120,9 @@ getChecksums ver = do testToolUrl = "https://repo1.maven.org/maven2/com/daml/ledger-api-test-tool/" <> SemVer.toString ver <> "/ledger-api-test-tool-" <> SemVer.toString ver <> ".jar" + tsLib name = + "https://registry.npmjs.org/@daml/" <> name <> + "/-/" <> name <> "-" <> SemVer.toString ver <> ".tgz" optsParser :: Parser Opts optsParser = Opts diff --git a/deps.bzl b/deps.bzl index 53390a0fd5..d358b2e2f8 100644 --- a/deps.bzl +++ b/deps.bzl @@ -39,6 +39,8 @@ buildifier_version = "0.26.0" buildifier_sha256 = "86592d703ecbe0c5cbb5139333a63268cf58d7efd2c459c8be8e69e77d135e29" zlib_version = "cacf7f1d4e3d44d871b605da3b647f07d718623f" zlib_sha256 = "6d4d6640ca3121620995ee255945161821218752b551a1a180f4215f7d124d45" +rules_nodejs_version = "1.6.0" +rules_nodejs_sha256 = "f9e7b9f42ae202cc2d2ce6d698ccb49a9f7f7ea572a78fd451696d03ef2ee116" # Recent davl. 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. @@ -184,8 +186,8 @@ def daml_deps(): if "build_bazel_rules_nodejs" not in native.existing_rules(): http_archive( name = "build_bazel_rules_nodejs", - urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.6.0/rules_nodejs-1.6.0.tar.gz"], - sha256 = "f9e7b9f42ae202cc2d2ce6d698ccb49a9f7f7ea572a78fd451696d03ef2ee116", + urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/{}/rules_nodejs-{}.tar.gz".format(rules_nodejs_version, rules_nodejs_version)], + sha256 = rules_nodejs_sha256, patches = [ # Work around for https://github.com/bazelbuild/rules_nodejs/issues/1565 "@com_github_digital_asset_daml//bazel_tools:rules_nodejs_npm_cli_path.patch",