From 31cc540cf9adaeb5509bf6071df8e8d8a4649de1 Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Fri, 26 Nov 2021 19:46:33 +0100 Subject: [PATCH] Turn package name & version warnings into an error (#11859) * Turn package name & version warnings into an error fixes #11321 changelog_begin changelog_end * . changelog_begin changelog_end --- .../daml-package-config/src/DA/Daml/Package/Config.hs | 10 +++++----- compiler/damlc/lib/DA/Cli/Damlc.hs | 6 ++++-- daml-script/test/BUILD.bazel | 2 +- docs/daml-intro-7.yaml | 2 +- language-support/java/codegen/BUILD.bazel | 1 + ledger/test-common/test-common.bzl | 2 +- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/compiler/damlc/daml-package-config/src/DA/Daml/Package/Config.hs b/compiler/damlc/daml-package-config/src/DA/Daml/Package/Config.hs index 85bd4f7dd4dc..8861d053f85e 100644 --- a/compiler/damlc/daml-package-config/src/DA/Daml/Package/Config.hs +++ b/compiler/damlc/daml-package-config/src/DA/Daml/Package/Config.hs @@ -68,15 +68,15 @@ parseProjectConfig project = do pSdkVersion <- queryProjectConfigRequired ["sdk-version"] project Right PackageConfigFields {..} -checkPkgConfig :: PackageConfigFields -> [String] +checkPkgConfig :: PackageConfigFields -> [T.Text] checkPkgConfig PackageConfigFields {pName, pVersion} = - [ unlines $ - ["WARNING: Package names should have the format " <> T.unpack packageNameRegex <> "."] + [ T.unlines $ + ["Invalid package name: " <> T.pack (show pName) <> ". Package names should have the format " <> packageNameRegex <> "."] ++ errDescription | not $ LF.unPackageName pName =~ packageNameRegex ] ++ - [ unlines $ - ["WARNING: Package versions should have the format " <> T.unpack versionRegex <> "."] + [ T.unlines $ + ["Invalid package version: " <> T.pack (show pVersion) <> ". Package versions should have the format " <> versionRegex <> "."] ++ errDescription | Just version <- [pVersion] , not $ LF.unPackageVersion version =~ versionRegex diff --git a/compiler/damlc/lib/DA/Cli/Damlc.hs b/compiler/damlc/lib/DA/Cli/Damlc.hs index 65a23a2398d4..ee720a53cb60 100644 --- a/compiler/damlc/lib/DA/Cli/Damlc.hs +++ b/compiler/damlc/lib/DA/Cli/Damlc.hs @@ -614,8 +614,10 @@ execBuild projectOpts opts mbOutFile incrementalBuild initPkgDb = withPackageConfig defaultProjectPath $ \pkgConfig@PackageConfigFields{..} -> do loggerH <- getLogger opts "build" Logger.logInfo loggerH $ "Compiling " <> LF.unPackageName pName <> " to a DAR." - let warnings = checkPkgConfig pkgConfig - unless (null warnings) $ putStrLn $ unlines warnings + let errors = checkPkgConfig pkgConfig + unless (null errors) $ do + mapM_ (Logger.logError loggerH) errors + exitFailure withDamlIdeState opts { optMbPackageName = Just pName diff --git a/daml-script/test/BUILD.bazel b/daml-script/test/BUILD.bazel index 30e0c14a0827..d8e5ada549dd 100644 --- a/daml-script/test/BUILD.bazel +++ b/daml-script/test/BUILD.bazel @@ -58,7 +58,7 @@ genrule( cp -L $(location //daml-script/daml:daml-script-1.dev.dar) $$TMP_DIR/ cat << EOF > $$TMP_DIR/daml.yaml sdk-version: {sdk} -name: script-test-1dev +name: script-test-v1dev version: 0.0.1 source: daml build-options: diff --git a/docs/daml-intro-7.yaml b/docs/daml-intro-7.yaml index f20883f79e14..761a9cf773e7 100644 --- a/docs/daml-intro-7.yaml +++ b/docs/daml-intro-7.yaml @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 sdk-version: __VERSION__ -name: 7Dependencies +name: Dependencies7 source: docs/source/daml/intro/daml/daml-intro-7/daml/ version: 1.0.0 dependencies: diff --git a/language-support/java/codegen/BUILD.bazel b/language-support/java/codegen/BUILD.bazel index 8d7db21c9430..ae99c585dec1 100644 --- a/language-support/java/codegen/BUILD.bazel +++ b/language-support/java/codegen/BUILD.bazel @@ -182,6 +182,7 @@ scala_source_jar( ], exclude = test_exclusions.get(ver, []), ), + project_name = "integration-tests-model", target = ver, ) for ver in LF_VERSIONS diff --git a/ledger/test-common/test-common.bzl b/ledger/test-common/test-common.bzl index b308a4ec4c17..92aaa7dfc71a 100644 --- a/ledger/test-common/test-common.bzl +++ b/ledger/test-common/test-common.bzl @@ -23,7 +23,7 @@ def da_scala_dar_resources_library( # 1. Compile daml files daml_compile_name = "%s-tests-%s" % (daml_dir_name, lf_version) daml_compile_kwargs = { - "project_name": "%s-tests" % daml_dir_name, + "project_name": "%s-tests" % daml_dir_name.replace("_", "-"), "srcs": native.glob(["%s/%s/*.daml" % (daml_root_dir, daml_dir_name)]), "target": lf_version, }