forked from digital-asset/daml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Platform independence pre-check (digital-asset#17955)
* Rename //bazel_tools:match-{cabal=>golden}-file * Generate and check hash file for contents of //compiler/damlc/tests:platform-independence.dar * Add pre-commit hook to test //compiler/damlc/tests:platform-independence-dar-hash-file-matches * Print info when //bazel_tools:match-golden-file fails * platform-independence-dar-check pre-commit hook runs depending on env var * Skip platform-independence-check if RUN_PLATFORM_INDEPENDENCE_CHECK is unset * Document dar_hash_file rules * move platform-independence-checks warning to .envrc * implement generate_dar_hash_file genrule in python in particular, this allows us to produce the same output on all platforms * fix windows * Update rules_daml/daml.bzl * bytes.replace does not operate in place
- Loading branch information
Showing
12 changed files
with
221 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
f4cbef8a91a8767297778db25b029ac70ebba248c1a5fd10464966e75bf9c245 META-INF/MANIFEST.MF | ||
b5c40ce08e30cf16a8cad16e2341d01d6ee49984fb8670cd12d7bea4984fae91 platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/compiler/damlc/tests/PlatformIndependence.daml | ||
0000000000000000000000000000000000000000000000000000000000000000 platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/compiler/damlc/tests/PlatformIndependence.hi | ||
0000000000000000000000000000000000000000000000000000000000000000 platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/compiler/damlc/tests/PlatformIndependence.hie | ||
dafb098481022814bddcd8796d0b5568e9795f178b3dc21c4d7ba3e88b20528d platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/daml-prim-041ddaabb3926f0b666d5e0a36bc1ae8dbf7191d2889afed5d1631af4172fa6b.dalf | ||
6458feec418d71e834dfa5b56a32b640f0595d1cf9bef29c3456cf9eac1c921e platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/daml-prim-DA-Exception-ArithmeticError-cb0552debf219cc909f51cbb5c3b41e9981d39f8f645b1f35e2ef5be2e0b858a.dalf | ||
ce477181ed187d31fb71e2819cd8af24b3bee3ff55b02950c23363849cf86a47 platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/daml-prim-DA-Exception-AssertionFailed-3f4deaf145a15cdcfa762c058005e2edb9baa75bb7f95a4f8f6f937378e86415.dalf | ||
a5dafa3128e153955c2360201cb700b09d170914847b184184e4413be848cecb platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/daml-prim-DA-Exception-GeneralError-86828b9843465f419db1ef8a8ee741d1eef645df02375ebf509cdc8c3ddd16cb.dalf | ||
9ec4a0044ebf1002e47c5119b06c8650535f0bd841d8a0c7189455a3720169f3 platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/daml-prim-DA-Exception-PreconditionFailed-f20de1e4e37b92280264c08bf15eca0be0bc5babd7a7b5e574997f154c00cb78.dalf | ||
9a6861aa98233c2fd6a446edd4255c2891ab3db5eec355955381f35088956a23 platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/daml-prim-DA-Internal-Erased-76bf0fd12bd945762a01f8fc5bbcdfa4d0ff20f8762af490f8f41d6237c6524f.dalf | ||
e66c79fc41a6bd6350ab265ee3bd15c0a6d5cd1748757194577448c89ce9e6a7 platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/daml-prim-DA-Internal-NatSyn-38e6274601b21d7202bb995bc5ec147decda5a01b68d57dda422425038772af7.dalf | ||
608e8efb2ed17a67eae9ddb74ca235a848195da170f47bf4d18d33bc7e96cc44 platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/daml-prim-DA-Internal-PromotedText-d58cf9939847921b2aab78eaa7b427dc4c649d25e6bee3c749ace4c3f52f5c97.dalf | ||
42105a59d0c9c7088a8860693f6da3d60ca62da5ccac1b9cf0dde8f975b984a5 platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/daml-prim-DA-Types-40f452260bef3f29dede136108fc08a88d5a5250310281067087da6f0baddff7.dalf | ||
12906f0e43060e26f823f03c2bbfe4d541db833d370db4caae2c66f38acae440 platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/daml-prim-GHC-Prim-e491352788e56ca4603acc411ffe1a49fefd76ed8b163af86cf5ee5f4c38645b.dalf | ||
bdc8c66d0511eff0262d3a133269e655bf47ba742e98ced5bc76a3fcd0211a73 platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/daml-prim-GHC-Tuple-6839a6d3d430c569b2425e9391717b44ca324b88ba621d597778811b2d05031d.dalf | ||
e99c27f6b9d297aaf747b572356e08376ce8d7a994ff00242749978b8a8a9ab0 platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/daml-prim-GHC-Types-518032f41fd0175461b35ae0c9691e08b4aea55e62915f8360af2cc7a1f2ba6c.dalf | ||
05e7e12f02e455d1efedcab3ea7c2de10807dc4d71d413f99eb885e0f8835148 platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/daml-stdlib-0.0.0-71147aee3f0eeacf21152ebb2c5fe34b27462ddcfc2145e012d23dec7bfcba0d.dalf | ||
dc4bd12915aea953a4ae6fb5e3b31fd3ec99605ae402c8b6350035ed9bbdeda7 platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/daml-stdlib-DA-Action-State-Type-10e0333b52bba1ff147fc408a6b7d68465b157635ee230493bd6029b750dcb05.dalf | ||
6d9d1309c57dab98cb34fda6b26d3c6d5b2e5fb1357333bce2c0b26c262fc372 platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/daml-stdlib-DA-Date-Types-bfcd37bd6b84768e86e432f5f6c33e25d9e7724a9d42e33875ff74f6348e733f.dalf | ||
acb729cf88297d61a52ba5852019326077f682e914052449d75142447b89b964 platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/daml-stdlib-DA-Internal-Any-cc348d369011362a5190fe96dd1f0dfbc697fdfd10e382b9e9666f0da05961b7.dalf | ||
5625ab94e607b99fd03cfb3a618c3ec8227cf35dc917cc310d12c34691d10c9d platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/daml-stdlib-DA-Internal-Down-057eed1fd48c238491b8ea06b9b5bf85a5d4c9275dd3f6183e0e6b01730cc2ba.dalf | ||
fb97292e2989cf6b046d0c07355a86741ba327231b13596e646f6aed3c65b726 platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/daml-stdlib-DA-Internal-Interface-AnyView-Types-6df2d1fd8ea994ed048a79587b2722e3a887ac7592abf31ecf46fe09ac02d689.dalf | ||
e6817a705c974eea0b05051e919e18cab97df616f3d8c8e590b41cde1147b7bf platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/daml-stdlib-DA-Internal-Template-d14e08374fc7197d6a0de468c968ae8ba3aadbf9315476fd39071831f5923662.dalf | ||
542ba5ef4d1707d77dbaa2c457adc06f28bad394968bae25635a982b7b1f6916 platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/daml-stdlib-DA-Logic-Types-c1f1f00558799eec139fb4f4c76f95fb52fa1837a5dd29600baa1c8ed1bdccfd.dalf | ||
a70854a646e926e98a102a6d332c67872b4bc5978700bf946ce58dfc94ba993c platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/daml-stdlib-DA-Monoid-Types-6c2c0667393c5f92f1885163068cd31800d2264eb088eb6fc740e11241b2bf06.dalf | ||
e80bf135b35aa8a1eca973e1b57b95b2ff3c6f9b1039be8b0a8e6a1810bfc613 platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/daml-stdlib-DA-NonEmpty-Types-e22bce619ae24ca3b8e6519281cb5a33b64b3190cc763248b4c3f9ad5087a92c.dalf | ||
77210bf43703a6883586997dfab07154c988f294b144337d056f99ba14fa6150 platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/daml-stdlib-DA-Random-Types-e4cc67c3264eba4a19c080cac5ab32d87551578e0f5f58b6a9460f91c7abc254.dalf | ||
aea033031e908d0a9b7c4701bc4a563c5f25b0f626ab3abb11725fe6525d4f79 platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/daml-stdlib-DA-Semigroup-Types-8a7806365bbd98d88b4c13832ebfa305f6abaeaf32cfa2b7dd25c4fa489b79fb.dalf | ||
41970cee0963cbf25ffb1d35601b4200631aedf794f80ab22f999416b48d8531 platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/daml-stdlib-DA-Set-Types-97b883cd8a2b7f49f90d5d39c981cf6e110cf1f1c64427a28a6d58ec88c43657.dalf | ||
e198664748ca9a14de3cf197a0bac3aec6deb3d4097db73dfbf300bb97e30b9a platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/daml-stdlib-DA-Stack-Types-5921708ce82f4255deb1b26d2c05358b548720938a5a325718dc69f381ba47ff.dalf | ||
826cad481a81e8e1fd7151a0f9c3bf5c14cc14e2983e1abc143387dafe4b8282 platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/daml-stdlib-DA-Time-Types-733e38d36a2759688a4b2c4cec69d48e7b55ecc8dedc8067b815926c917a182a.dalf | ||
348c6f5fcd6b3b2753a8418cdb980b3a8c73fcc37ff1ffc63c0a9625159ca067 platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/daml-stdlib-DA-Validation-Types-99a2705ed38c1c26cbb8fe7acf36bbf626668e167a33335de932599219e0a235.dalf | ||
1d1014d0027a3582e15a7e23a3e96101cb2c100f1550b776bfc189e583db6c9e platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/data/platform-independence-1.0.0.conf | ||
7c1281de1ce291c14bb08a84d1d0f990cf3ccfc541380b380352e90a76533be1 platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71/platform-independence-1.0.0-aeeeb8902241c9454cba7a1594d2ba19aae4aaa92824bf0dffd513d3f4eb1d71.dalf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
# Copyright (c) 2023 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
set -euo pipefail | ||
|
||
if [ "$RUN_PLATFORM_INDEPENDENCE_CHECK" = "yes" ]; then | ||
bazel test //compiler/damlc/tests:platform-independence-dar-hash-file-matches | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Copyright (c) 2023 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from argparse import ArgumentParser | ||
from zipfile import ZipFile | ||
from pathlib import PurePath | ||
from hashlib import sha256 | ||
|
||
|
||
def parse_args(): | ||
parser = ArgumentParser(description="generate-dar-hash") | ||
parser.add_argument('dar', metavar='DAR', type=str) | ||
return parser.parse_args() | ||
|
||
|
||
def entry(filename, bytes): | ||
extension = PurePath(filename).suffix | ||
if extension in ['.hi', '.hie']: | ||
# hie/hi files may differ, so we ignore their contents. | ||
hash = 64 * '0' | ||
else: | ||
if extension in ['.daml']: | ||
# on text files, newlines will be encoded differently depending | ||
# on platform, so we canonicalize them here | ||
bytes = bytes.replace(b'\r\n', b'\n') | ||
hash = sha256(bytes).hexdigest() | ||
return f"{hash} {filename}" | ||
|
||
|
||
def main(): | ||
args = parse_args() | ||
with ZipFile(args.dar) as dar: | ||
for filename in dar.namelist(): | ||
print(entry(filename, dar.read(filename))) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |