Skip to content

Commit

Permalink
Fix SDK versions in trigger and daml-script dars (digital-asset#3706)
Browse files Browse the repository at this point in the history
* Fix SDK versions in trigger and daml-script dars

* Fix SDK versions in tests
  • Loading branch information
cocreature authored and mergify[bot] committed Dec 3, 2019
1 parent 8124569 commit 5a3b5f4
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 8 deletions.
3 changes: 1 addition & 2 deletions compiler/damlc/lib/DA/Cli/Damlc/Packaging.hs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ createProjectPackageDb opts thisSdkVer deps0 dataDeps = do
in mapM expand
deps <- handleSdkPackages $ filter (`notElem` basePackages) deps0
depsExtracted <- mapM extractDar deps
let uniqSdkVersions = nubSort $ filter (/= "0.0.0") $ unPackageSdkVersion thisSdkVer : map edSdkVersions depsExtracted
-- we filter the 0.0.0 version because otherwise integration tests fail that import SDK packages
let uniqSdkVersions = nubSort $ unPackageSdkVersion thisSdkVer : map edSdkVersions depsExtracted
unless (length uniqSdkVersions <= 1) $
fail $
"Package dependencies from different SDK versions: " ++
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,45 @@ packagingTests = testGroup "packaging"
withCurrentDirectory projDir $ callCommandQuiet "daml build"
let dar = projDir </> ".daml" </> "dist" </> "copy-trigger-0.0.1.dar"
assertBool "copy-trigger-0.1.0.dar was not created." =<< doesFileExist dar
, testCase "Build trigger with extra dependency" $ withTempDir $ \tmpDir -> do
let myDepDir = tmpDir </> "mydep"
createDirectoryIfMissing True (myDepDir </> "daml")
writeFileUTF8 (myDepDir </> "daml.yaml") $ unlines
[ "sdk-version: " <> sdkVersion
, "name: mydep"
, "version: \"1.0\""
, "source: daml"
, "dependencies:"
, " - daml-prim"
, " - daml-stdlib"
]
writeFileUTF8 (myDepDir </> "daml" </> "MyDep.daml") $ unlines
[ "daml 1.2"
, "module MyDep where"
]
withCurrentDirectory myDepDir $ callCommandQuiet "daml build -o mydep.dar"
let myTriggerDir = tmpDir </> "mytrigger"
createDirectoryIfMissing True (myTriggerDir </> "daml")
writeFileUTF8 (myTriggerDir </> "daml.yaml") $ unlines
[ "sdk-version: " <> sdkVersion
, "name: mytrigger"
, "version: \"1.0\""
, "source: daml"
, "dependencies:"
, " - daml-prim"
, " - daml-stdlib"
, " - daml-trigger"
, " - " <> myDepDir </> "mydep.dar"
]
writeFileUTF8 (myTriggerDir </> "daml/Main.daml") $ unlines
[ "daml 1.2"
, "module Main where"
, "import MyDep ()"
, "import Daml.Trigger ()"
]
withCurrentDirectory myTriggerDir $ callCommandQuiet "daml build -o mytrigger.dar"
let dar = myTriggerDir </> "mytrigger.dar"
assertBool "mytrigger.dar was not created." =<< doesFileExist dar
, testCase "Build DAML script example" $ withTempDir $ \tmpDir -> do
let projDir = tmpDir </> "script-example"
callCommandQuiet $ unwords ["daml", "new", projDir, "script-example"]
Expand Down
4 changes: 2 additions & 2 deletions daml-script/daml/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

genrule(
name = "daml-script",
srcs = glob(["**/*.daml"]),
srcs = glob(["**/*.daml"]) + ["//:VERSION"],
outs = ["daml-script.dar"],
cmd = """
set -eou pipefail
TMP_DIR=$$(mktemp -d)
mkdir -p $$TMP_DIR/daml/Daml
cp -L $(location Daml/Script.daml) $$TMP_DIR/daml/Daml
cat << EOF > $$TMP_DIR/daml.yaml
sdk-version: 0.0.0
sdk-version: $$(cat $(location //:VERSION))
name: daml-script
source: daml
version: 0.0.1
Expand Down
3 changes: 2 additions & 1 deletion daml-script/test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ genrule(
glob(["**/*.daml"]) + [
"//daml-script/daml:daml-script.dar",
"//docs:source/daml-script/template-root/src/ScriptExample.daml",
"//:VERSION",
],
outs = ["script-test.dar"],
cmd = """
Expand All @@ -28,7 +29,7 @@ genrule(
cp -L $(location //docs:source/daml-script/template-root/src/ScriptExample.daml) $$TMP_DIR/daml
cp -L $(location //daml-script/daml:daml-script.dar) $$TMP_DIR/
cat << EOF > $$TMP_DIR/daml.yaml
sdk-version: 0.0.0
sdk-version: $$(cat $(location //:VERSION))
name: script-test
source: daml
version: 0.0.1
Expand Down
4 changes: 2 additions & 2 deletions triggers/daml/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

genrule(
name = "daml-trigger",
srcs = glob(["**/*.daml"]),
srcs = glob(["**/*.daml"]) + ["//:VERSION"],
outs = ["daml-trigger.dar"],
cmd = """
set -eou pipefail
Expand All @@ -15,7 +15,7 @@ genrule(
cp -L $(location Daml/Trigger.daml) $$TMP_DIR/daml/Daml
cp -L $(location Daml/Trigger/LowLevel.daml) $$TMP_DIR/daml/Daml/Trigger
cat << EOF > $$TMP_DIR/daml.yaml
sdk-version: 0.0.0
sdk-version: $$(cat $(location //:VERSION))
name: daml-trigger
source: daml
version: 0.0.1
Expand Down
3 changes: 2 additions & 1 deletion triggers/tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ genrule(
glob(["**/*.daml"]) + [
"//triggers/daml:daml-trigger.dar",
"//docs:source/triggers/template-root/src/CopyTrigger.daml",
"//:VERSION",
],
outs = ["acs.dar"],
cmd = """
Expand All @@ -32,7 +33,7 @@ genrule(
cp -L $(location //docs:source/triggers/template-root/src/CopyTrigger.daml) $$TMP_DIR/daml
cp -L $(location //triggers/daml:daml-trigger.dar) $$TMP_DIR/
cat << EOF > $$TMP_DIR/daml.yaml
sdk-version: 0.0.0
sdk-version: $$(cat $(location //:VERSION))
name: acs
source: daml
version: 0.0.1
Expand Down

0 comments on commit 5a3b5f4

Please sign in to comment.