diff --git a/lib/dune b/lib/dune index 05cdf1a..7f3412d 100644 --- a/lib/dune +++ b/lib/dune @@ -1,4 +1,4 @@ (library (name opam_ci_check) (public_name opam-ci-check) - (libraries opam-client sexplib mula)) + (libraries opam-client sexplib mula str)) diff --git a/lib/lint.ml b/lib/lint.ml index 4f50f4d..815b381 100644 --- a/lib/lint.ml +++ b/lib/lint.ml @@ -260,6 +260,14 @@ module Checks = struct if is_build then [ (pkg, DuneIsBuild) ] else errors | None -> [] + let check_maintainer_email ~pkg opam = + let maintainers = OpamFile.OPAM.maintainer opam in + List.filter_map + (fun m -> + if Str.string_match (Str.regexp ".*?") m 0 then None + else Some (pkg, MaintainerEmailMissing m)) + maintainers + let opam_lint ~pkg opam = OpamFileTools.lint ~check_upstream:true opam |> List.map (fun x -> (pkg, OpamLint x)) @@ -343,6 +351,7 @@ module Checks = struct check_checksums; check_package_dir ~repo_dir; opam_lint; + check_maintainer_email; check_no_pin_depends; check_no_extra_files; Prefix.check_prefix_conflict_class_mismatch; diff --git a/lib/lint_error.ml b/lib/lint_error.ml index c07e5fb..3eac9b7 100644 --- a/lib/lint_error.ml +++ b/lib/lint_error.ml @@ -21,6 +21,7 @@ type error = | UnexpectedFile of string | ForbiddenPerm of string | OpamLint of (int * [ `Warning | `Error ] * string) + | MaintainerEmailMissing of string | FailedToDownload of string | NameCollision of string | WeakChecksum of string @@ -137,5 +138,10 @@ let msg_of_error (package, (err : error)) = | OpamLint warn -> let warn = OpamFileTools.warns_to_string [ warn ] in Printf.sprintf "Error in %s: %s" pkg warn + | MaintainerEmailMissing maintainer -> + Printf.sprintf + "Error in %s: Maintainer email missing. Please add a maintainer email \ + to the opam file. Maintainer: %s" + pkg maintainer | ParseError -> Printf.sprintf "Error in %s: Failed to parse the opam file" pkg diff --git a/test/lint.t b/test/lint.t index 7aabe36..4b48bc0 100644 --- a/test/lint.t +++ b/test/lint.t @@ -43,6 +43,7 @@ Setup repo for incorrect b package tests Test the following: - [b.0.0.1] is missing the [author] field +- [b.0.0.1] is missing the maintainer's email in the [maintainer] field - [b.0.0.2] has an extra unknown field - [b.0.0.3] has a pin-depends present, and a conflict class without the required prefix; use of extra-files and a weak checksum algorithm - [system-b.0.0.1] is using a restricted prefix in its name @@ -54,6 +55,7 @@ Test the following: $ opam-ci-check lint -r . -c b.0.0.1 Linting opam-repository at $TESTCASE_ROOT/. ... Error in b.0.0.1: warning 25: Missing field 'authors' + Error in b.0.0.1: Maintainer email missing. Please add a maintainer email to the opam file. Maintainer: Jane [1] $ opam-ci-check lint -r . -c b.0.0.2 Linting opam-repository at $TESTCASE_ROOT/. ... diff --git a/test/patches/a-1.patch b/test/patches/a-1.patch index 695ed58..db9cb0a 100644 --- a/test/patches/a-1.patch +++ b/test/patches/a-1.patch @@ -19,7 +19,7 @@ index 0000000..58229e8 +opam-version: "2.0" +synopsis: "Synopsis" +description: "Description" -+maintainer: "Maintainer" ++maintainer: "Maintainer " +author: "Author" +license: "Apache-2.0" +homepage: "https://github.com/ocurrent/opam-repo-ci" @@ -37,7 +37,7 @@ index 0000000..58229e8 +opam-version: "2.0" +synopsis: "Synopsis" +description: "Description" -+maintainer: "Maintainer" ++maintainer: "Maintainer " +author: "Author" +license: "Apache-2.0" +homepage: "https://github.com/ocurrent/opam-repo-ci" diff --git a/test/patches/a_1-name-collision.patch b/test/patches/a_1-name-collision.patch index bb152fd..1af52a3 100644 --- a/test/patches/a_1-name-collision.patch +++ b/test/patches/a_1-name-collision.patch @@ -17,7 +17,7 @@ index 0000000..58229e8 +opam-version: "2.0" +synopsis: "Synopsis" +description: "Description" -+maintainer: "Maintainer" ++maintainer: "Maintainer " +author: "Author" +license: "Apache-2.0" +homepage: "https://github.com/ocurrent/opam-repo-ci" diff --git a/test/patches/b-correct.patch b/test/patches/b-correct.patch index 01ac333..0dcf52d 100644 --- a/test/patches/b-correct.patch +++ b/test/patches/b-correct.patch @@ -21,7 +21,7 @@ index 0000000..69040f4 +opam-version: "2.0" +synopsis: "Synopsis" +description: "Description" -+maintainer: "Maintainer" ++maintainer: "Maintainer " +author: "Author" +license: "Apache-2.0" +homepage: "https://github.com/ocurrent/opam-repo-ci" @@ -41,7 +41,7 @@ index 0000000..1581508 +opam-version: "2.0" +synopsis: "Synopsis" +description: "Description" -+maintainer: "Maintainer" ++maintainer: "Maintainer " +author: "Author" +license: "Apache-2.0" +homepage: "https://github.com/ocurrent/opam-repo-ci" @@ -61,7 +61,7 @@ index 0000000..5ec1dc4 +opam-version: "2.0" +synopsis: "Synopsis" +description: "Description" -+maintainer: "Maintainer" ++maintainer: "Maintainer " +author: "Author" +license: "Apache-2.0" +homepage: "https://github.com/ocurrent/opam-repo-ci" diff --git a/test/patches/b-incorrect-opam.patch b/test/patches/b-incorrect-opam.patch index 4b4c654..6ceba85 100644 --- a/test/patches/b-incorrect-opam.patch +++ b/test/patches/b-incorrect-opam.patch @@ -7,7 +7,7 @@ index 0000000..3697498 +opam-version: "2.0" +synopsis: "Synopsis" +description: "Description" -+maintainer: "Maintainer" ++maintainer: "Jane" +license: "Apache-2.0" +homepage: "https://github.com/ocurrent/opam-repo-ci" +bug-reports: "https://github.com/ocurrent/opam-repo-ci/issues" @@ -26,7 +26,7 @@ index 0000000..a47aabf +opam-version: "2.0" +synopsis: "Synopsis" +description: "Description" -+maintainer: "Maintainer" ++maintainer: "Maintainer " +author: "Author" +license: "Apache-2.0" +homepage: "https://github.com/ocurrent/opam-repo-ci" @@ -54,7 +54,7 @@ index 0000000..5bab63e +opam-version: "2.0" +synopsis: "Synopsis" +description: "Description" -+maintainer: "Maintainer" ++maintainer: "Maintainer " +author: "Author" +license: "Apache-2.0" +homepage: "https://github.com/ocurrent/opam-repo-ci" @@ -84,7 +84,7 @@ index 0000000..0808e56 +opam-version: "2.0" +synopsis: "Synopsis" +description: "Description" -+maintainer: "Maintainer" ++maintainer: "Maintainer " +author: "Author" +license: "Apache-2.0" +homepage: "https://github.com/ocurrent/opam-repo-ci" @@ -104,7 +104,7 @@ index 0000000..5bab63e +opam-version: "2.0" +synopsis: "Synopsis" +description: "Description" -+maintainer: "Maintainer" ++maintainer: "Maintainer " +author: "Author" +license: "Apache-2.0" +homepage: "https://github.com/ocurrent/opam-repo-ci" @@ -129,7 +129,7 @@ index 0000000..5bab63e +opam-version: "2.0" +synopsis: "Synopsis" +description: "Description" -+maintainer: "Maintainer" ++maintainer: "Maintainer " +author: "Author" +license: "Apache-2.0" +homepage: "https://github.com/ocurrent/opam-repo-ci" @@ -153,7 +153,7 @@ index 0000000..5bab63e +opam-version: "2.0" +synopsis: "Synopsis" +description: "Description" -+maintainer: "Maintainer" ++maintainer: "Maintainer " +author: "Author" +license: "Apache-2.0" +homepage: "https://github.com/ocurrent/opam-repo-ci" diff --git a/test/patches/levenshtein-2.patch b/test/patches/levenshtein-2.patch index 8166550..739ec10 100644 --- a/test/patches/levenshtein-2.patch +++ b/test/patches/levenshtein-2.patch @@ -7,7 +7,7 @@ index 0000000..5246a83 +opam-version: "2.0" +synopsis: "Synopsis" +description: "Description" -+maintainer: "Maintainer" ++maintainer: "Maintainer " +author: "Author" +license: "Apache-2.0" +homepage: "https://github.com/ocurrent/opam-repo-ci" @@ -25,7 +25,7 @@ index 0000000..5246a83 +opam-version: "2.0" +synopsis: "Synopsis" +description: "Description" -+maintainer: "Maintainer" ++maintainer: "Maintainer " +author: "Author" +license: "Apache-2.0" +homepage: "https://github.com/ocurrent/opam-repo-ci" @@ -43,7 +43,7 @@ index 0000000..5246a83 +opam-version: "2.0" +synopsis: "Synopsis" +description: "Description" -+maintainer: "Maintainer" ++maintainer: "Maintainer " +author: "Author" +license: "Apache-2.0" +homepage: "https://github.com/ocurrent/opam-repo-ci" @@ -61,7 +61,7 @@ index 0000000..5246a83 +opam-version: "2.0" +synopsis: "Synopsis" +description: "Description" -+maintainer: "Maintainer" ++maintainer: "Maintainer " +author: "Author" +license: "Apache-2.0" +homepage: "https://github.com/ocurrent/opam-repo-ci"