daml/compatibility/BUILD

238 lines
7.2 KiB
Python
Raw Normal View History

# Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
load("@os_info//:os_info.bzl", "is_windows")
load("//bazel_tools:testing.bzl", "create_daml_app_codegen", "create_daml_app_dar", "daml_lf_compatible", "sdk_platform_test")
load(
"//bazel_tools/daml_script:daml_script.bzl",
"daml_script_example_dar",
"daml_script_example_test",
)
load(
"//bazel_tools/daml_trigger:daml_trigger.bzl",
"daml_trigger_dar",
"daml_trigger_test",
)
load(
"//bazel_tools/data_dependencies:data_dependencies.bzl",
"data_dependencies_coins",
"data_dependencies_daml_script_test",
"data_dependencies_upgrade_test",
)
load("//bazel_tools:versions.bzl", "versions")
load("//:versions.bzl", "platform_versions", "sdk_versions", "stable_versions")
load("@daml//bazel_tools:haskell.bzl", "da_haskell_binary")
config_setting(
name = "ghci_data",
define_values = {
"ghci_data": "True",
},
)
last_non_canton_in_ledger_api_tests = "2.7.0-snapshot.20230427.11728.0.1f3c22cf"
[
sh_test(
name = "test-daml-version-and-install-{}".format(sdk_version),
srcs = ["test-daml-version-and-install.sh"],
args = [sdk_version],
data = [
"@daml-sdk-{}//:daml".format(sdk_version),
"@diffutils_nix//:bin/diff",
],
deps = ["@bazel_tools//tools/bash/runfiles"],
)
for sdk_version in sdk_versions
if versions.is_at_least("2.7.6", sdk_version)
] if not is_windows else None
[
[
create_daml_app_dar(sdk_version),
create_daml_app_codegen(sdk_version),
]
for sdk_version in sdk_versions
]
# Instead of testing the full cartesian product of all SDK versions with
# all platform (~= Sandbox/JSON API) versions, we test the latest version of
# each with all versions of the other. This gives us a reasonable feedback
# with regards to maintaining backwards-compatibility without causing the
# test runs to grow quadratically.
head = "0.0.0"
# Missing on purpose: do not test the latest SDK with the latest platform
# That is not a compatibility test, it's just testing the main branch. ;)
# Test all old platform versions with the latest SDK
[
sdk_platform_test(
platform_version = platform_version,
sdk_version = head,
)
for platform_version in platform_versions
if platform_version != head and daml_lf_compatible(head, platform_version)
]
# Test all old SDK versions with the latest platform
[
sdk_platform_test(
platform_version = head,
sdk_version = sdk_version,
)
for sdk_version in sdk_versions
if sdk_version != head and daml_lf_compatible(sdk_version, head)
]
[
daml_script_example_dar(sdk_version)
for sdk_version in sdk_versions
]
[
daml_script_example_test(
compiler_version = sdk_version,
runner_version = platform_version,
)
for sdk_version in sdk_versions
for platform_version in platform_versions
# Test that the Daml script runner can run DARs built with an older SDK
# version. I.e. where the runner version is at least the SDK version or
# more recent.
if versions.is_at_least(sdk_version, platform_version)
] if not is_windows else None
# Change to `CommandId` generation
first_post_7587_trigger_version = "1.7.0-snapshot.20201012.5405.0.af92198d"
interpret allowed updates and other actions in a free Trigger monad, like Script (#7456) * conservatively move daml-script, trigger SValue interpreters to common library * introduce expect and JavaList pattern for converters * clean up trigger Converter Command interpretation * add Church Free monad * add an action language for trigger updates * add expectE to remove some of the joins * convert more of the converters to expect * tool for unrolling Free/Roll * split handleStepResult up and clean up its pattern * handleStepFreeResult to interpret TriggerF * replace Free Church with Pure/Roll free from Script * newtype for ActionTrigger * replace update in low-level Trigger with Free TriggerF * submit one Commands at a time * boolean blindness strikes again * log missed TriggerF steps * comment actual Submit contents * match #7501 fromPureSExpr sig change in 00b80b8ea3 * avoid using forwardPort in runTrigger * push State back into DAML, so it can be excluded from the action list * push Message back into DAML, unifying the action language for initialState and update * bringing TriggerF into initial state * really add TriggerF into initial state, with all ports, tested * add ActionTrigger class, express initialState in its terms * add all TriggerF actions to existing TriggerA * Trigger.rule will no longer have Time argument * rename getS, setS to get, put, matching C.M.T.State from transformers * make high-level Rule evaluate to the underlying TriggerF sequence * Assert's testRule doesn't have a transform yet * move DamlTuple2 to common converter library - suggested by @cocreature; thanks * combine the two Frees, provide from Script * remove time argument from integration tests CHANGELOG_BEGIN - [Triggers] The ``Time`` argument was removed from the trigger rule function; instead, it can be fetched within the ``TriggerA`` ``do`` block by ``getTime``, as with ``Update`` and ``Scenario``. The ``LowLevel`` trigger interface has been redesigned; such triggers need to be rewritten or ported to high-level triggers. See `issue #7456 <https://github.com/digital-asset/daml/pull/7456>`_. CHANGELOG_END * add trigger rule simulator to support Assert module * missed new Free module - left in script per @cocreature * remove retract as we ended up using foldFree for that purpose instead - suggested by @cocreature; thanks * throw ConverterException instead of RuntimeException - suggested by @cocreature; thanks * remove Time argument from coin-upgrade-trigger * port trigger service tests * port trigger scenario test * put TriggerSetup and TriggerRule into LowLevel.Trigger instead of unboxed Free - suggested by @cocreature; thanks * remove Time argument from trigger compatibility test * submit commands as soon as each `emitCommands` is sequenced - we still collect a list, but only for tracking commandsInFlight * filter out compatibility tests for triggers before now * remove commented imports, libraries from new shared converter * make the TriggerF interpreter tail-recursive * remove unused compatibility trait * add back new state logging * remove refactoring comment * rewrite some LowLevel initialStates in do * hide Daml.Script.Free from docs Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org> * remove forwardPortInitialState - suggested by @cocreature; thanks * manually port low-level updates - suggested by @cocreature; thanks * remove forwardPort - suggested by @cocreature; thanks * fail faster on unrecognized TriggerF - suggested by @cocreature; thanks Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2020-10-02 21:18:13 +03:00
[
daml_trigger_dar(sdk_version)
for sdk_version in sdk_versions
if versions.is_at_least(first_post_7587_trigger_version, sdk_version)
]
[
daml_trigger_test(
compiler_version = sdk_version,
runner_version = platform_version,
)
for sdk_version in sdk_versions
for platform_version in platform_versions
# Test that the Daml trigger runner can run DARs built with an older SDK
# version. I.e. where the runner version is at least the SDK version or
# more recent.
if versions.is_at_least(first_post_7587_trigger_version, sdk_version) and
interpret allowed updates and other actions in a free Trigger monad, like Script (#7456) * conservatively move daml-script, trigger SValue interpreters to common library * introduce expect and JavaList pattern for converters * clean up trigger Converter Command interpretation * add Church Free monad * add an action language for trigger updates * add expectE to remove some of the joins * convert more of the converters to expect * tool for unrolling Free/Roll * split handleStepResult up and clean up its pattern * handleStepFreeResult to interpret TriggerF * replace Free Church with Pure/Roll free from Script * newtype for ActionTrigger * replace update in low-level Trigger with Free TriggerF * submit one Commands at a time * boolean blindness strikes again * log missed TriggerF steps * comment actual Submit contents * match #7501 fromPureSExpr sig change in 00b80b8ea3 * avoid using forwardPort in runTrigger * push State back into DAML, so it can be excluded from the action list * push Message back into DAML, unifying the action language for initialState and update * bringing TriggerF into initial state * really add TriggerF into initial state, with all ports, tested * add ActionTrigger class, express initialState in its terms * add all TriggerF actions to existing TriggerA * Trigger.rule will no longer have Time argument * rename getS, setS to get, put, matching C.M.T.State from transformers * make high-level Rule evaluate to the underlying TriggerF sequence * Assert's testRule doesn't have a transform yet * move DamlTuple2 to common converter library - suggested by @cocreature; thanks * combine the two Frees, provide from Script * remove time argument from integration tests CHANGELOG_BEGIN - [Triggers] The ``Time`` argument was removed from the trigger rule function; instead, it can be fetched within the ``TriggerA`` ``do`` block by ``getTime``, as with ``Update`` and ``Scenario``. The ``LowLevel`` trigger interface has been redesigned; such triggers need to be rewritten or ported to high-level triggers. See `issue #7456 <https://github.com/digital-asset/daml/pull/7456>`_. CHANGELOG_END * add trigger rule simulator to support Assert module * missed new Free module - left in script per @cocreature * remove retract as we ended up using foldFree for that purpose instead - suggested by @cocreature; thanks * throw ConverterException instead of RuntimeException - suggested by @cocreature; thanks * remove Time argument from coin-upgrade-trigger * port trigger service tests * port trigger scenario test * put TriggerSetup and TriggerRule into LowLevel.Trigger instead of unboxed Free - suggested by @cocreature; thanks * remove Time argument from trigger compatibility test * submit commands as soon as each `emitCommands` is sequenced - we still collect a list, but only for tracking commandsInFlight * filter out compatibility tests for triggers before now * remove commented imports, libraries from new shared converter * make the TriggerF interpreter tail-recursive * remove unused compatibility trait * add back new state logging * remove refactoring comment * rewrite some LowLevel initialStates in do * hide Daml.Script.Free from docs Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org> * remove forwardPortInitialState - suggested by @cocreature; thanks * manually port low-level updates - suggested by @cocreature; thanks * remove forwardPort - suggested by @cocreature; thanks * fail faster on unrecognized TriggerF - suggested by @cocreature; thanks Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2020-10-02 21:18:13 +03:00
versions.is_at_least(sdk_version, platform_version)
]
[
data_dependencies_coins(
sdk_version = sdk_version,
)
for sdk_version in sdk_versions
]
[
data_dependencies_upgrade_test(
new_sdk_version = new_sdk_version,
old_sdk_version = old_sdk_version,
)
for old_sdk_version in sdk_versions
for new_sdk_version in sdk_versions
# Tests that we can build a package with a newer SDK version that has
# data-dependencies on packages built with an older SDK version.
if versions.is_at_least(old_sdk_version, new_sdk_version)
]
[
data_dependencies_daml_script_test(
old_sdk_version = old_sdk_version,
)
for old_sdk_version in sdk_versions
# Tests that we can run a daml script from a package built with an older
# SDK version even when exposed through an import in a package built with
# the latest SDK version.
# (regression test for https://github.com/digital-asset/daml/issues/14291)
if old_sdk_version != "0.0.0"
# These tests use data-dependency reexports (#11147), so the earliest
# supported SDK is 1.18.0
if versions.is_at_least("1.18.0", old_sdk_version)
]
Supporting version splitting in Daml Assistant and Daml Compiler (#17682) * initial implementation supporting version splitting in assistant stubbed out implementations of resolveReleaseVersion/other resolution * implement resolveReleaseVersionFromGithub * continue work on fixing SDK/release version split * First commit that successfully runs `daml-head install <split version>` * fix tests * Ignore snapshot/metadata for isHeadVersion * remove log debugging * Fix tests for getSdk * refactor DA.Daml.Project.Types.defaultSdkPath * enable incremental changes to version cache * Allow resolveReleaseVersionFromGithub to fail via Either * Split getSdkVersionFromSdkPath into get{Sdk,Release}VersionFromSdkPath * Add resolveReleaseVersionFromDamlPath/Github to resolveReleaseVersion * Add mock sdk config with version * Remove getInstalledSdkVersions dependency on Cache * add override for github version api endpoint, useful for mocking * Add alternate-download to provide alternate tarball install resolution * initial work on comprehensive autotester * Copyright header * fix build generation to have valid Main.daml * improve error message for check_daml_install_nonzero * Make killing miniserve processes more robust * remove breakpoint * Implement `daml build` tests * Solve TODO in installExtracted to resolve sourceSdkVersion coherently Supply useful error message with it. * Return SdkVersion from sdkVersionFromReleaseVersion for typechecking * Finish tests for tarball build, drop installed_already_behaviour * Try to force-reload cache on tar failure, fix `Possible fix:` notes * Add AllowInstallNonRelease as a flag * Test allow_nonrelease, refactor, clean up setup_sandbox * Move no_cache_override_github_endpoint API response into file * Remove dead code, vestigial code * Remove TODOs that no longer are relevant * fix iAllowInstallNonRelease in InstallOptions for autoInstall * Refactor alternateVersionLocation * (Try to) lint language-support/ts/codegen/BUILD.bazel * fix daml-assistant/test * Enable allow_nonrelease post-build checks * Remove writeFile debugging from DA.Daml.Assistant.Version * Replace ../test-daml-yaml-install/test.sh with test-all-installs.sh * lint * more lint run-full-compat: true * Stop tracking API response in test-daml-yaml-install * Move ReleaseResolution into Version * remove extra deps, fixes daml-project-config-cabal-file-matches * Move InstallLocation to minimize changes to DA.Daml.Project.Types run-full-compat: true * Create cachePath in daml-assistant tests that need it * Bind to unused ports in test-all-installs.sh run-full-compat: true * Override via files instead of just URLs run-full-compat: true * Remove unused RELEASES_ENDPOINT * Use dict keys instead of hardcoding in test-all-installs listing * Refactor to remove check_daml_install_from_tarball_after_cache_reload * Improve comment on update_cache * Move shift before cases * Add comment for unsafeParseReleaseVersion * Rename unsafeParseReleaseVersion into unsafeParseOldReleaseVersion * remove done todo * Add some hungarian notation to resolveReleaseVersionFromDamlPath * drop redundant let * Define ordering over ReleaseVersion run-full-compat: true * use sdkVersion for codegen * Use `urls` attribute in http_file, `url` is unsupported on Windows (!) run-full-compat: true * Remove unnecessary check for cache reload run-full-compat: true * Try use daml executable directly without daml-sdk-0.0.0 run-full-compat: true * try force daml.exe to daml run-full-compat: true * Use daml.exe when windows is detected * add windows tarballs for snapshots * Fix most tests on windows, "line too long" breaks some tarball tests run-full-compat: true * Point to more recent snapshot post Moises's fixes * Add os-specific tarball paths and alternate-download run-full-compat: true * Fix windows autoinstall with 0.0.0 run-full-compat: true * Fix error message, remove daml_install_output catching * Detect "The input line is too long" in other post_failed commands * Fix missing releases endpoint, handle "cannot find the path specified" run-full-compat: true
2023-11-22 17:24:13 +03:00
os_name = "linux" if not is_windows else "windows"
command_targets = {
"install_from_version": [
"2.8.0-snapshot.20231109.2",
"0.0.0",
"latest",
"2.7.1",
],
"build_from_version": [
"2.8.0-snapshot.20231109.2",
"2.7.1",
"0.0.0",
],
"install_and_build_from_tarball": [
"v2.8.0-snapshot.20231109.2/daml-sdk-2.8.0-snapshot.20231107.12319.0.v03a51e65-{}.tar.gz".format(os_name),
"v2.7.5/daml-sdk-2.7.5-{}.tar.gz".format(os_name),
"v2.7.1/daml-sdk-2.7.1-{}.tar.gz".format(os_name),
],
}
command_post_failure_behaviours = {
"install_from_version": [
"do_nothing",
],
"build_from_version": [
"do_nothing",
],
"install_and_build_from_tarball": [
"allow_nonrelease",
"update_cache",
"install_via_custom_version",
Supporting version splitting in Daml Assistant and Daml Compiler (#17682) * initial implementation supporting version splitting in assistant stubbed out implementations of resolveReleaseVersion/other resolution * implement resolveReleaseVersionFromGithub * continue work on fixing SDK/release version split * First commit that successfully runs `daml-head install <split version>` * fix tests * Ignore snapshot/metadata for isHeadVersion * remove log debugging * Fix tests for getSdk * refactor DA.Daml.Project.Types.defaultSdkPath * enable incremental changes to version cache * Allow resolveReleaseVersionFromGithub to fail via Either * Split getSdkVersionFromSdkPath into get{Sdk,Release}VersionFromSdkPath * Add resolveReleaseVersionFromDamlPath/Github to resolveReleaseVersion * Add mock sdk config with version * Remove getInstalledSdkVersions dependency on Cache * add override for github version api endpoint, useful for mocking * Add alternate-download to provide alternate tarball install resolution * initial work on comprehensive autotester * Copyright header * fix build generation to have valid Main.daml * improve error message for check_daml_install_nonzero * Make killing miniserve processes more robust * remove breakpoint * Implement `daml build` tests * Solve TODO in installExtracted to resolve sourceSdkVersion coherently Supply useful error message with it. * Return SdkVersion from sdkVersionFromReleaseVersion for typechecking * Finish tests for tarball build, drop installed_already_behaviour * Try to force-reload cache on tar failure, fix `Possible fix:` notes * Add AllowInstallNonRelease as a flag * Test allow_nonrelease, refactor, clean up setup_sandbox * Move no_cache_override_github_endpoint API response into file * Remove dead code, vestigial code * Remove TODOs that no longer are relevant * fix iAllowInstallNonRelease in InstallOptions for autoInstall * Refactor alternateVersionLocation * (Try to) lint language-support/ts/codegen/BUILD.bazel * fix daml-assistant/test * Enable allow_nonrelease post-build checks * Remove writeFile debugging from DA.Daml.Assistant.Version * Replace ../test-daml-yaml-install/test.sh with test-all-installs.sh * lint * more lint run-full-compat: true * Stop tracking API response in test-daml-yaml-install * Move ReleaseResolution into Version * remove extra deps, fixes daml-project-config-cabal-file-matches * Move InstallLocation to minimize changes to DA.Daml.Project.Types run-full-compat: true * Create cachePath in daml-assistant tests that need it * Bind to unused ports in test-all-installs.sh run-full-compat: true * Override via files instead of just URLs run-full-compat: true * Remove unused RELEASES_ENDPOINT * Use dict keys instead of hardcoding in test-all-installs listing * Refactor to remove check_daml_install_from_tarball_after_cache_reload * Improve comment on update_cache * Move shift before cases * Add comment for unsafeParseReleaseVersion * Rename unsafeParseReleaseVersion into unsafeParseOldReleaseVersion * remove done todo * Add some hungarian notation to resolveReleaseVersionFromDamlPath * drop redundant let * Define ordering over ReleaseVersion run-full-compat: true * use sdkVersion for codegen * Use `urls` attribute in http_file, `url` is unsupported on Windows (!) run-full-compat: true * Remove unnecessary check for cache reload run-full-compat: true * Try use daml executable directly without daml-sdk-0.0.0 run-full-compat: true * try force daml.exe to daml run-full-compat: true * Use daml.exe when windows is detected * add windows tarballs for snapshots * Fix most tests on windows, "line too long" breaks some tarball tests run-full-compat: true * Point to more recent snapshot post Moises's fixes * Add os-specific tarball paths and alternate-download run-full-compat: true * Fix windows autoinstall with 0.0.0 run-full-compat: true * Fix error message, remove daml_install_output catching * Detect "The input line is too long" in other post_failed commands * Fix missing releases endpoint, handle "cannot find the path specified" run-full-compat: true
2023-11-22 17:24:13 +03:00
"do_nothing",
],
}
[
sh_test(
name = "test-all-installs-{}-{}-{}-{}".format(
command[:10],
command_target.split("/")[0][:11],
version_cache_behaviour[:8],
post_failure_behaviour[:5],
),
size = "enormous",
srcs = ["test-all-installs.sh"],
args = [
os_name,
command,
command_target,
version_cache_behaviour,
post_failure_behaviour,
],
data = [
":new_cache",
":old_cache",
":releases-github-api.json",
"@daml-sdk-2.7.1-tarball//file",
"@daml-sdk-2.7.4-tarball//file",
"@daml-sdk-2.7.5-tarball//file",
"@daml-sdk-2.8.0-snapshot.20231107.12319.0.v03a51e65-tarball//file",
"@head_sdk//:daml" if not is_windows else "@head_sdk//:daml.exe",
"@head_sdk//:sdk-release-tarball-ce.tar.gz",
],
deps = ["@bazel_tools//tools/bash/runfiles"],
)
for command in command_targets.keys()
for command_target in command_targets[command]
for version_cache_behaviour in [
"init_new_cache",
"init_old_cache",
"no_cache_override_github_endpoint",
]
for post_failure_behaviour in command_post_failure_behaviours[command]
]