From 76dd306ac1182662299a5d11f3330aa0a40d9798 Mon Sep 17 00:00:00 2001 From: Puneeth Chaganti Date: Mon, 25 Nov 2024 12:39:44 +0530 Subject: [PATCH] Extract lint functionality as a separate library Co-authored-by: Shon Feder --- opam-ci-check-lint.opam | 41 +++++++++++++++++++ opam-ci-check/lib/dune | 10 ++++- opam-ci-check/lib/opam_ci_check.ml | 4 +- opam-ci-check/lint/dune | 4 ++ opam-ci-check/{lib => lint}/lint_error.ml | 0 .../lint.ml => lint/opam_ci_check_lint.ml} | 5 ++- .../lint.mli => lint/opam_ci_check_lint.mli} | 4 ++ opam-ci-check/{lib => lint}/opam_helpers.ml | 0 8 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 opam-ci-check-lint.opam create mode 100644 opam-ci-check/lint/dune rename opam-ci-check/{lib => lint}/lint_error.ml (100%) rename opam-ci-check/{lib/lint.ml => lint/opam_ci_check_lint.ml} (99%) rename opam-ci-check/{lib/lint.mli => lint/opam_ci_check_lint.mli} (95%) rename opam-ci-check/{lib => lint}/opam_helpers.ml (100%) diff --git a/opam-ci-check-lint.opam b/opam-ci-check-lint.opam new file mode 100644 index 00000000..1ed54269 --- /dev/null +++ b/opam-ci-check-lint.opam @@ -0,0 +1,41 @@ +opam-version: "2.0" +synopsis: + "Library to lint opam files submitted to the opam repository" +description: + "opam-ci-check-lint exposes the lint functionality used in the opam repo CI and opam-ci-check. It can be used in other packages such as opam publishing tools to ensure that the published package opam files are correct." +maintainer: [ + "Puneeth Chaganti " + "Shon Feder " +] +authors: [ + "Puneeth Chaganti " + "Shon Feder " +] +license: "Apache-2.0" +tags: ["opam" "ci" "lint"] +homepage: "https://github.com/ocurrent/opam-repo-ci/tree/master/opam-ci-check" +doc: "https://www.ocurrent.org/opam-repo-ci/opam-ci-check-lint/index.html" +bug-reports: "https://github.com/ocurrent/opam-repo-ci/issues" +depends: [ + "ocaml" {>= "4.14.0"} + "dune" {>= "3.16"} + "sexplib" + "opam-state" {>= "2.3.0~alpha1"} + "opam-format" {>= "2.3.0~alpha1"} + "odoc" {with-doc} +] +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] +] +dev-repo: "git+https://github.com/ocurrent/opam-repo-ci.git" diff --git a/opam-ci-check/lib/dune b/opam-ci-check/lib/dune index 82ff94f3..b204a82f 100644 --- a/opam-ci-check/lib/dune +++ b/opam-ci-check/lib/dune @@ -3,4 +3,12 @@ (public_name opam-ci-check) (preprocess (pps ppx_deriving.std ppx_deriving_yojson)) - (libraries opam-client sexplib bos fpath str ocaml-version obuilder-spec)) + (libraries + opam-client + sexplib + bos + fpath + str + ocaml-version + obuilder-spec + opam-ci-check-lint)) diff --git a/opam-ci-check/lib/opam_ci_check.ml b/opam-ci-check/lib/opam_ci_check.ml index d0b65550..17c45004 100644 --- a/opam-ci-check/lib/opam_ci_check.ml +++ b/opam-ci-check/lib/opam_ci_check.ml @@ -4,10 +4,10 @@ module Revdeps = Revdeps module Test = Test -module Lint = Lint +module Lint = Opam_ci_check_lint +module Opam_helpers = Opam_ci_check_lint.Opam_helpers module Opam_build = Opam_build module Variant = Variant module Opam_version = Opam_version module Compiler_version = Compiler_version module Spec = Spec -module Opam_helpers = Opam_helpers diff --git a/opam-ci-check/lint/dune b/opam-ci-check/lint/dune new file mode 100644 index 00000000..fec555db --- /dev/null +++ b/opam-ci-check/lint/dune @@ -0,0 +1,4 @@ +(library + (name opam_ci_check_lint) + (public_name opam-ci-check-lint) + (libraries opam-state opam-format sexplib str)) diff --git a/opam-ci-check/lib/lint_error.ml b/opam-ci-check/lint/lint_error.ml similarity index 100% rename from opam-ci-check/lib/lint_error.ml rename to opam-ci-check/lint/lint_error.ml diff --git a/opam-ci-check/lib/lint.ml b/opam-ci-check/lint/opam_ci_check_lint.ml similarity index 99% rename from opam-ci-check/lib/lint.ml rename to opam-ci-check/lint/opam_ci_check_lint.ml index e0ce11bd..5f880470 100644 --- a/opam-ci-check/lib/lint.ml +++ b/opam-ci-check/lint/opam_ci_check_lint.ml @@ -2,7 +2,8 @@ * Copyright (c) 2024 Puneeth Chaganti , Shon Feder , Tarides *) -module O = Opam_helpers +module Opam_helpers = Opam_helpers + let ( // ) = Filename.concat let get_files dir = dir |> Sys.readdir |> Array.to_list @@ -303,7 +304,7 @@ module Checks = struct | _ -> false let check_package_dir ~opam_repo_dir ~pkg _opam = - let dir = O.path_from_pkg ~opam_repo_dir pkg in + let dir = Opam_helpers.path_from_pkg ~opam_repo_dir pkg in let check_file = function | "opam" -> let path = dir // "opam" in diff --git a/opam-ci-check/lib/lint.mli b/opam-ci-check/lint/opam_ci_check_lint.mli similarity index 95% rename from opam-ci-check/lib/lint.mli rename to opam-ci-check/lint/opam_ci_check_lint.mli index ae4a6194..69fefc8d 100644 --- a/opam-ci-check/lib/lint.mli +++ b/opam-ci-check/lint/opam_ci_check_lint.mli @@ -2,6 +2,10 @@ * Copyright (c) 2024 Puneeth Chaganti , Shon Feder , Tarides *) +module Opam_helpers : sig + val path_from_pkg : opam_repo_dir:string -> OpamPackage.t -> string +end + include module type of Lint_error module Checks : sig diff --git a/opam-ci-check/lib/opam_helpers.ml b/opam-ci-check/lint/opam_helpers.ml similarity index 100% rename from opam-ci-check/lib/opam_helpers.ml rename to opam-ci-check/lint/opam_helpers.ml