Skip to content

Commit

Permalink
Turn package name & version warnings into an error (#11859)
Browse files Browse the repository at this point in the history
* Turn package name & version warnings into an error

fixes #11321

changelog_begin
changelog_end

* .

changelog_begin
changelog_end
  • Loading branch information
cocreature authored Nov 26, 2021
1 parent 4e50060 commit 31cc540
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
10 changes: 5 additions & 5 deletions compiler/damlc/daml-package-config/src/DA/Daml/Package/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions compiler/damlc/lib/DA/Cli/Damlc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion daml-script/test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion docs/daml-intro-7.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions language-support/java/codegen/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ scala_source_jar(
],
exclude = test_exclusions.get(ver, []),
),
project_name = "integration-tests-model",
target = ver,
)
for ver in LF_VERSIONS
Expand Down
2 changes: 1 addition & 1 deletion ledger/test-common/test-common.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down

0 comments on commit 31cc540

Please sign in to comment.