From 66531958a65b324e804725c9502ff1df3b5ca3a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonin=20D=C3=A9cimo?= Date: Fri, 29 Sep 2023 14:11:21 +0200 Subject: [PATCH 1/2] Stop detecting ocaml-ci specifically There's no specific integration to be made with ocaml-ci, apart from generic CI integration. --- CHANGES.md | 4 ++++ alcotest-help.txt | 4 ---- src/alcotest-engine/cli.ml | 14 ++------------ src/alcotest-engine/config.ml | 20 ++++++-------------- src/alcotest-engine/config_intf.ml | 2 +- 5 files changed, 13 insertions(+), 31 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 1b9f3931..c0f49b55 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -15,6 +15,10 @@ - Allow overriding the number of columns with `ALCOTEST_COLUMNS` env var. (#322, #381, @MisterDA) +- Stop detecting ocamlci specifically, since there's nothing specific + about it. Simply use the `CI` env var to detect CIs. + (#397, @MisterDA) + ### 1.7.0 (2023-02-24) - Allow skipping a test case from inside the test case (#368, @apeschar) diff --git a/alcotest-help.txt b/alcotest-help.txt index 394b215b..31920740 100644 --- a/alcotest-help.txt +++ b/alcotest-help.txt @@ -108,7 +108,3 @@ ENVIRONMENT Whether Alcotest is running in GitHub Actions, if set to 'true'. Display tests errors and outputs GitHub Actions annotations. - OCAMLCI - Whether Alcotest is running in OCaml-CI, if set to 'true'. Display - tests errors. - diff --git a/src/alcotest-engine/cli.ml b/src/alcotest-engine/cli.ml index 1d7b2e57..202150dd 100644 --- a/src/alcotest-engine/cli.ml +++ b/src/alcotest-engine/cli.ml @@ -44,7 +44,7 @@ module Make (P : Platform.MAKER) (M : Monad.S) : in Cmdliner.Cmd.Env.info "CI" ~doc - let github_action_env = + let github_actions_env = let doc = Printf.sprintf "Whether Alcotest is running in GitHub Actions, if set to %s. Display \ @@ -53,15 +53,6 @@ module Make (P : Platform.MAKER) (M : Monad.S) : in Cmdliner.Cmd.Env.info "GITHUB_ACTIONS" ~doc - let ocamlci_env = - let doc = - Printf.sprintf - "Whether Alcotest is running in OCaml-CI, if set to %s. Display tests \ - errors." - (Arg.doc_quote "true") - in - Cmdliner.Cmd.Env.info "OCAMLCI" ~doc - let alcotest_source_code_position = let doc = "Whether Alcotest should guess the source code position of test \ @@ -80,8 +71,7 @@ module Make (P : Platform.MAKER) (M : Monad.S) : let envs = [ ci_env; - github_action_env; - ocamlci_env; + github_actions_env; alcotest_source_code_position; alcotest_columns; ] diff --git a/src/alcotest-engine/config.ml b/src/alcotest-engine/config.ml index 4ba58321..e8899b0b 100644 --- a/src/alcotest-engine/config.ml +++ b/src/alcotest-engine/config.ml @@ -52,23 +52,15 @@ module Key = struct type t = ci let default = - let ci = - match Sys.getenv "CI" with - | "true" -> true - | _ | (exception Not_found) -> false - and github_actions = - match Sys.getenv "GITHUB_ACTIONS" with - | "true" -> true - | _ | (exception Not_found) -> false - and ocamlci = - match Sys.getenv "OCAMLCI" with + let getenv var = + match Sys.getenv var with | "true" -> true | _ | (exception Not_found) -> false in - match (ci, github_actions, ocamlci) with - | true, true, false -> `Github_actions - | true, false, true -> `OCamlci - | true, false, false -> `Unknown + let ci = getenv "CI" and github_actions = getenv "GITHUB_ACTIONS" in + match (ci, github_actions) with + | true, true -> `Github_actions + | true, false -> `Unknown | _ -> `Disabled end diff --git a/src/alcotest-engine/config_intf.ml b/src/alcotest-engine/config_intf.ml index adfdf79e..498c33e5 100644 --- a/src/alcotest-engine/config_intf.ml +++ b/src/alcotest-engine/config_intf.ml @@ -2,7 +2,7 @@ module Types = struct type bound = [ `Unlimited | `Limit of int ] type filter = name:string -> index:int -> [ `Run | `Skip ] - type ci = [ `Github_actions | `OCamlci | `Unknown | `Disabled ] + type ci = [ `Github_actions | `Unknown | `Disabled ] (** All supported Continuous Integration (CI) systems. *) type t = From 154f207b79f7b6bf5d061bca8cce5fc1377b852a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonin=20D=C3=A9cimo?= Date: Fri, 29 Sep 2023 14:50:03 +0200 Subject: [PATCH 2/2] Improve CI detection - AppVeyor uses `CI=True`. https://www.appveyor.com/docs/environment-variables/ - GitHub Actions, GitLab CI, CircleCI, ocaml-ci, opam-repo-ci, opam-health-check use `CI=true`. https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables https://docs.gitlab.com/ee/ci/variables/predefined_variables.html https://circleci.com/docs/variables/ --- CHANGES.md | 3 ++- src/alcotest-engine/config.ml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index c0f49b55..99f6312a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -16,7 +16,8 @@ var. (#322, #381, @MisterDA) - Stop detecting ocamlci specifically, since there's nothing specific - about it. Simply use the `CI` env var to detect CIs. + about it. Simply use the `CI` env var to detect CIs. Improve CI + detection. (#397, @MisterDA) ### 1.7.0 (2023-02-24) diff --git a/src/alcotest-engine/config.ml b/src/alcotest-engine/config.ml index e8899b0b..6d422a1b 100644 --- a/src/alcotest-engine/config.ml +++ b/src/alcotest-engine/config.ml @@ -54,7 +54,7 @@ module Key = struct let default = let getenv var = match Sys.getenv var with - | "true" -> true + | "true" | "True" -> true | _ | (exception Not_found) -> false in let ci = getenv "CI" and github_actions = getenv "GITHUB_ACTIONS" in