Skip to content

Commit

Permalink
Merge pull request ocaml#4766 from kit-ty-kate/lint-license
Browse files Browse the repository at this point in the history
opam lint: Warn if the license field is not present
  • Loading branch information
kit-ty-kate authored Jul 26, 2021
2 parents 8ce42c8 + 37a598b commit 775eb71
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/scripts/solvers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
. .github/scripts/preamble.sh

export OPAMYES=1
export OPAMCONFIRMLEVEL=unsafe-yes
export OCAMLRUNPARAM=b

# All environment variable are overwritten in job description
Expand All @@ -23,6 +24,7 @@ case "$SOLVER" in
;;
esac

opam update --depexts
opam switch create $SOLVER ocaml-system || true
opam install $PKGS
opam install . --deps
Expand Down
2 changes: 1 addition & 1 deletion master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Prefixes used to help generate release notes, changes, and blog posts:
*

## Lint
*
* W68: add warning for missing license field [#4766 @kit-ty-kate - partial fix #4598]

## Lock
*
Expand Down
3 changes: 3 additions & 0 deletions src/state/opamFileTools.ml
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,9 @@ let t_lint ?check_extra_files ?(check_upstream=false) ?(all=false) t =
| Some urlf ->
(OpamFile.URL.checksum urlf <> [])
&& url_is_archive <> Some true);
cond 68 `Warning
"Missing field 'license'"
(t.license = []);
]
in
format_errors @
Expand Down
17 changes: 17 additions & 0 deletions tests/reftests/dune.inc
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,23 @@
%{targets}
(run ./run.exe %{bin:opam} %{dep:legacy-local.test} %{read-lines:testing-env}))))

(alias
(name reftest-lint)
(action
(diff lint.test lint.out)))

(alias
(name reftest)
(deps (alias reftest-lint)))

(rule
(targets lint.out)
(deps root-N0REP0)
(action
(with-stdout-to
%{targets}
(run ./run.exe %{bin:opam} %{dep:lint.test} %{read-lines:testing-env}))))

(alias
(name reftest-opamroot-versions)
(action
Expand Down
29 changes: 29 additions & 0 deletions tests/reftests/lint.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
N0REP0
### <lint.opam>
opam-version: "2.0"
name: "lint"
version: "1.0"
synopsis: "A word"
description: "Two words."
maintainer: "[email protected]"
authors: [ "Z" "A" "R" ]
homepage: "x"
bug-reports: "x"
depends: [
"ocaml" {>= "4.02.3"}
"base-unix"
"base-bigarray"
"ocamlgraph"
"re" {>= "1.5.0"}
"dune" {>= "1.2.1"}
"cppo" {build}
]
conflicts: ["extlib-compat"]
build: [
[ "./configure" ]
[ make ]
]
dev-repo: "git+https://github.com/ocaml/opam.git"
### opam lint ./lint.opam
${BASEDIR}/lint.opam: Warnings.
warning 68: Missing field 'license'
6 changes: 6 additions & 0 deletions tests/reftests/show.test
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ synopsis: "A word"
description: "Two words."
maintainer: "[email protected]"
authors: [ "Z" "A" "R" ]
license: "ISC"
homepage: "x"
bug-reports: "x"
depends: [
Expand All @@ -151,6 +152,7 @@ synopsis: "A word"
description: "Two words."
maintainer: "[email protected]"
authors: ["A" "R" "Z"]
license: "ISC"
homepage: "x"
bug-reports: "x"
depends: [
Expand Down Expand Up @@ -182,6 +184,7 @@ bug-reports "x"
dev-repo "git+https://github.com/ocaml/opam.git"
authors "A" "R" "Z"
maintainer "[email protected]"
license "ISC"
depends "base-bigarray"
"base-unix"
"ocamlgraph"
Expand All @@ -200,6 +203,7 @@ synopsis: "A word"
description: "Two words."
maintainer: "[email protected]"
authors: ["A" "R" "Z"]
license: "ISC"
homepage: "x"
bug-reports: "x"
depends: [
Expand Down Expand Up @@ -233,6 +237,7 @@ synopsis: "A word"
description: "Two words."
maintainer: "[email protected]"
authors: ["Z" "A" "R"]
license: "ISC"
homepage: "x"
bug-reports: "x"
depends: [
Expand Down Expand Up @@ -265,6 +270,7 @@ bug-reports "x"
dev-repo "git+https://github.com/ocaml/opam.git"
authors "Z" "A" "R"
maintainer "[email protected]"
license "ISC"
depends "ocaml" {>= "4.02.3"}
"base-unix"
"base-bigarray"
Expand Down
2 changes: 2 additions & 0 deletions tests/reftests/upgrade-format.test
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
### <opam-core.opam>
opam-version: "1.2"
version: "2.0.7"
license: "ISC"
maintainer: "[email protected]"
authors: [
"Vincent Bernardoff <[email protected]>"
Expand Down Expand Up @@ -51,6 +52,7 @@ authors: [
"Ralf Treinen <[email protected]>"
"Frederic Tuong <[email protected]>"
]
license: "ISC"
homepage: "https://opam.ocaml.org/"
bug-reports: "https://github.com/ocaml/opam/issues"
depends: [
Expand Down

0 comments on commit 775eb71

Please sign in to comment.