mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-19 00:37:23 +03:00
test: test for platform independent dars (#10535)
We add a CI test to check that dars don't depend on the underlying operating system where the dar is build. CHANGELOG_BEGIN CHANGELOG_END
This commit is contained in:
parent
3822a8c886
commit
0c1878530b
@ -38,6 +38,10 @@ steps:
|
||||
DAML_SDK_RELEASE_VERSION: ${{parameters.release_tag}}
|
||||
DAML_SCALA_VERSION: ${{parameters.scala_version}}
|
||||
|
||||
- template: publish-platform-independence-dar.yml
|
||||
parameters:
|
||||
platform: '${{parameters.name}}'
|
||||
|
||||
- task: PublishBuildArtifacts@1
|
||||
condition: succeededOrFailed()
|
||||
continueOnError: true
|
||||
|
@ -32,6 +32,10 @@ steps:
|
||||
# number).
|
||||
SKIP_TESTS: ${{parameters.skip_tests}}
|
||||
|
||||
- template: publish-platform-independence-dar.yml
|
||||
parameters:
|
||||
platform: 'windows'
|
||||
|
||||
- task: PublishBuildArtifacts@1
|
||||
condition: failed()
|
||||
displayName: 'Publish the bazel test logs'
|
||||
|
42
ci/build.yml
42
ci/build.yml
@ -338,6 +338,48 @@ jobs:
|
||||
trigger_sha: '$(trigger_sha)'
|
||||
- template: report-end.yml
|
||||
|
||||
- job: platform_independence_test
|
||||
dependsOn:
|
||||
- Windows
|
||||
- Linux
|
||||
- macOS
|
||||
pool:
|
||||
name: 'ubuntu_20_04'
|
||||
demands: assignment -equals default
|
||||
steps:
|
||||
- checkout: self
|
||||
- bash: ci/dev-env-install.sh
|
||||
displayName: 'Build/Install the Developer Environment'
|
||||
- task: DownloadPipelineArtifact@2
|
||||
inputs:
|
||||
artifactName: platform-independence-dar-linux
|
||||
targetPath: $(Build.StagingDirectory)/platform-independence/linux/
|
||||
- task: DownloadPipelineArtifact@2
|
||||
inputs:
|
||||
artifactName: platform-independence-dar-windows
|
||||
targetPath: $(Build.StagingDirectory)/platform-independence/windows/
|
||||
- task: DownloadPipelineArtifact@2
|
||||
inputs:
|
||||
artifactName: platform-independence-dar-macos
|
||||
targetPath: $(Build.StagingDirectory)/platform-independence/macos/
|
||||
- bash: |
|
||||
set -euo pipefail
|
||||
eval "$(./dev-env/bin/dade-assist)"
|
||||
|
||||
DIR1=$(mktemp -d)
|
||||
DIR2=$(mktemp -d)
|
||||
DIR3=$(mktemp -d)
|
||||
trap "rm -rf $DIR1; rm -rf $DIR2; rm -rf $DIR3" EXIT
|
||||
|
||||
unzip -d $DIR1 $(Build.StagingDirectory)/platform-independence/linux/platform-independence.dar
|
||||
unzip -d $DIR2 $(Build.StagingDirectory)/platform-independence/windows/platform-independence.dar
|
||||
unzip -d $DIR3 $(Build.StagingDirectory)/platform-independence/macos/platform-independence.dar
|
||||
|
||||
# hie/hi files may differ.
|
||||
diff -r --strip-trailing-cr -x '*.hie' -x '*.hi' $DIR1 $DIR2
|
||||
diff -r --strip-trailing-cr -x '*.hie' -x '*.hi' $DIR1 $DIR3
|
||||
displayName: 'Compare platform-independence dars of different platforms.'
|
||||
|
||||
- job: compatibility_ts_libs
|
||||
dependsOn:
|
||||
- da_ghc_lib
|
||||
|
12
ci/publish-platform-independence-dar.yml
Normal file
12
ci/publish-platform-independence-dar.yml
Normal file
@ -0,0 +1,12 @@
|
||||
# Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
parameters:
|
||||
platform: ''
|
||||
|
||||
steps:
|
||||
- task: PublishBuildArtifacts@1
|
||||
inputs:
|
||||
pathtoPublish: bazel-bin/compiler/damlc/tests/platform-independence.dar
|
||||
artifactName: platform-independence-dar-${{parameters.platform}}
|
||||
|
@ -4,7 +4,7 @@
|
||||
load("//bazel_tools:haskell.bzl", "da_haskell_binary", "da_haskell_library", "da_haskell_test")
|
||||
load("@os_info//:os_info.bzl", "is_windows")
|
||||
load(":util.bzl", "damlc_compile_test")
|
||||
load("//rules_daml:daml.bzl", "daml_compile")
|
||||
load("//rules_daml:daml.bzl", "daml_compile", "daml_compile_with_dalf")
|
||||
load("@build_environment//:configuration.bzl", "sdk_version")
|
||||
load("//daml-lf/language:daml-lf.bzl", "COMPILER_LF_VERSIONS", "lf_version_configuration")
|
||||
load("//compiler/damlc:util.bzl", "ghc_pkg")
|
||||
@ -991,3 +991,11 @@ da_haskell_binary(
|
||||
"//libs-haskell/da-hs-base",
|
||||
],
|
||||
)
|
||||
|
||||
daml_compile_with_dalf(
|
||||
name = "platform-independence",
|
||||
srcs = glob(["PlatformIndependence.daml"]),
|
||||
# don't turn warnings into errors, we have a missing pattern on purpose in
|
||||
# PlatformIndependence.daml.
|
||||
ghc_options = [],
|
||||
)
|
||||
|
41
compiler/damlc/tests/PlatformIndependence.daml
Normal file
41
compiler/damlc/tests/PlatformIndependence.daml
Normal file
@ -0,0 +1,41 @@
|
||||
-- Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||
-- SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
module PlatformIndependence where
|
||||
|
||||
import DA.Stack
|
||||
|
||||
type AssetId = ContractId Asset
|
||||
|
||||
data ADT
|
||||
= Foo
|
||||
| Bar
|
||||
| Baz
|
||||
|
||||
give : HasCallStack => Party -> Party -> Text -> Update (ContractId Asset)
|
||||
give issuer owner name = do
|
||||
let fs = [ srcLocFile srcLoc | (_t, srcLoc) <- getCallStack callStack]
|
||||
trace (show fs) $ create Asset{..}
|
||||
|
||||
incompletePattternMatch : ADT -> Update ()
|
||||
incompletePattternMatch adt =
|
||||
case adt of
|
||||
Foo -> pure ()
|
||||
Bar -> pure ()
|
||||
|
||||
template Asset
|
||||
with
|
||||
issuer : Party
|
||||
owner : Party
|
||||
name : Text
|
||||
where
|
||||
ensure name /= ""
|
||||
signatory issuer
|
||||
controller owner can
|
||||
Give : AssetId
|
||||
with
|
||||
newOwner : Party
|
||||
do
|
||||
incompletePattternMatch Baz
|
||||
create this with
|
||||
owner = newOwner
|
1
dev-env/bin/unzip
Symbolic link
1
dev-env/bin/unzip
Symbolic link
@ -0,0 +1 @@
|
||||
../lib/dade-exec-nix-tool
|
@ -191,6 +191,7 @@ in rec {
|
||||
# Packaging tools
|
||||
patchelf = bazel_dependencies.patchelf;
|
||||
zip = bazel_dependencies.zip;
|
||||
unzip = pkgs.unzip;
|
||||
openssl = pkgs.openssl.bin;
|
||||
tar = bazel_dependencies.gnutar;
|
||||
|
||||
|
@ -19,13 +19,12 @@ _zipper = attr.label(
|
||||
cfg = "host",
|
||||
)
|
||||
|
||||
ghc_opts = ["--ghc-option=-Werror"]
|
||||
|
||||
def _daml_configure_impl(ctx):
|
||||
project_name = ctx.attr.project_name
|
||||
project_version = ctx.attr.project_version
|
||||
daml_yaml = ctx.outputs.daml_yaml
|
||||
target = ctx.attr.target
|
||||
ghc_opts = ctx.attr.ghc_options
|
||||
opts = ghc_opts + ["--target={}".format(target)] if target else ghc_opts
|
||||
ctx.actions.write(
|
||||
output = daml_yaml,
|
||||
@ -62,6 +61,10 @@ _daml_configure = rule(
|
||||
"target": attr.string(
|
||||
doc = "DAML-LF version to output.",
|
||||
),
|
||||
"ghc_options": attr.string_list(
|
||||
doc = "Options passed to GHC.",
|
||||
default = ["--ghc-option=-Werror"],
|
||||
),
|
||||
},
|
||||
)
|
||||
|
||||
@ -84,6 +87,7 @@ def _daml_build_impl(ctx):
|
||||
input_dars = [file_of_target(k) for k in dar_dict.keys()]
|
||||
output_dar = ctx.outputs.dar
|
||||
posix = ctx.toolchains["@rules_sh//sh/posix:toolchain_type"]
|
||||
ghc_opts = ctx.attr.ghc_options
|
||||
ctx.actions.run_shell(
|
||||
tools = [damlc],
|
||||
inputs = [daml_yaml] + srcs + input_dars,
|
||||
@ -146,6 +150,10 @@ _daml_build = rule(
|
||||
mandatory = True,
|
||||
doc = "The generated DAR file.",
|
||||
),
|
||||
"ghc_options": attr.string_list(
|
||||
doc = "Options passed to GHC.",
|
||||
default = ["--ghc-option=-Werror"],
|
||||
),
|
||||
"_damlc": _damlc,
|
||||
},
|
||||
toolchains = ["@rules_sh//sh/posix:toolchain_type"],
|
||||
|
Loading…
Reference in New Issue
Block a user