daml/compatibility/BUILD
Moritz Kiefer d6e5862645
Add platform-version field to daml.yaml (#6736)
* Add `platform-version` field to `daml.yaml`

This PR adds the `platform-version` field to `daml.yaml`. Based on the
approach agreed upon in #6558, the logic for this all sits in
`daml-helper` and there are no changes to the assistant.

The details of how the logic work are in a comment so I’m not going to
repeat them here but the commands that are affected are:

- `daml sandbox`
- `daml sandbox-classic`
- `daml json-api`
- `daml start` (but only for sandbox and the JSON API, not for
  Navigator or anything else)

For tests, I’ve added a test to the compat workspace that installs two
SDKs simultaneously and tries out various combinations and verifies
that we get the correct version. Open to other ideas for testing this
but that seemed like the most sensible option that actually tests what
we run.

changelog_begin

- [DAML Assistant] You can now specify the version of Sandbox and the
  JSON API independently of your SDK version by setting
  ``platform-version`` in your ``daml.yaml``. This is useful if you
  are deploying to a ledger that is running components from a
  different SDK version. See
  https://docs.daml.com/tools/assistant.html#project-config-file-daml-yaml
  for details.

changelog_end

* Run platform-version tests

changelog_begin
changelog_end

* Fix tag globbing

changelog_begin
changelog_end

* fmt

changelog_begin
changelog_end

* .

changelog_begin
changelog_end

* Try to fix env vars

changelog_begin
changelog_end

* Remove hardcoded references to 1.2.0

changelog_begin
changelog_end

* Rephrase doc comment

changelog_begin
changelog_end

* get things to compile

changelog_begin
changelog_end

* maybe fix things for realz

changelog_begin
changelog_end

* Remove debugging output

changelog_begin
changelog_end

* Get angry at windows

changelog_begin
changelog_end

* why is windows

changelog_begin
changelog_end

* .

changelog_begin
changelog_end
2020-07-15 16:30:01 +02:00

152 lines
3.9 KiB
Python

# Copyright (c) 2020 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", "sdk_platform_test")
load(
"//bazel_tools/daml_script:daml_script.bzl",
"daml_script_dar",
"daml_script_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_upgrade_test",
)
load("//bazel_tools:versions.bzl", "versions")
load("//sandbox-migration:util.bzl", "migration_test")
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",
},
)
[
sh_binary(
name = "sandbox-with-postgres-{}".format(version),
srcs = ["@//bazel_tools:sandbox-with-postgres.sh"],
args = ["sandbox"],
data = [
"@//bazel_tools/client_server/with-postgres:with-postgres-exe",
"@daml-sdk-{}//:daml".format(version),
],
deps = ["@bazel_tools//tools/bash/runfiles"],
)
for version in platform_versions
]
[
[
create_daml_app_dar(sdk_version),
create_daml_app_codegen(sdk_version),
]
for sdk_version in sdk_versions
]
[
sdk_platform_test(
platform_version = platform_version,
sdk_version = sdk_version,
)
for sdk_version in sdk_versions
for platform_version in platform_versions
]
[
daml_script_dar(sdk_version)
for sdk_version in sdk_versions
]
[
daml_script_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)
]
[
daml_trigger_dar(sdk_version)
for sdk_version in sdk_versions
]
[
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(sdk_version, platform_version)
]
# We have two migration tests: migration-stable runs through all stable releases
# including current HEAD. migration-all includes snapshot releases.
migration_test(
name = "migration-stable",
timeout = "long",
# Exclusive due to hardcoded postgres ports.
tags = [
"exclusive",
"head-quick",
],
versions = stable_versions,
) if not is_windows else None
migration_test(
name = "meta-migration-test",
tags = [
"exclusive",
"manual",
],
versions = [
"1.0.0",
"0.0.0",
],
)
migration_test(
name = "migration-all",
timeout = "long",
# Exclusive due to hardcoded postgres ports.
tags = ["exclusive"],
versions = platform_versions,
) if not is_windows else None
[
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)
]