Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't detect ocaml-ci specifically, improve CI detection #397

Merged
merged 3 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
- Be able to allocate and use user's formatters for stdout/stderr
(#399, @dinosaure)

- Stop detecting ocamlci specifically, since there's nothing specific
about it. Simply use the `CI` env var to detect CIs. Improve CI
detection.
(#397, @MisterDA)

### 1.7.0 (2023-02-24)

- Allow skipping a test case from inside the test case (#368, @apeschar)
Expand Down
4 changes: 0 additions & 4 deletions alcotest-help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.

14 changes: 2 additions & 12 deletions src/alcotest-engine/cli.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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 \
Expand All @@ -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;
]
Expand Down
22 changes: 7 additions & 15 deletions src/alcotest-engine/config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
| "true" -> true
let getenv var =
match Sys.getenv var with
| "true" | "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

Expand Down
2 changes: 1 addition & 1 deletion src/alcotest-engine/config_intf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,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 =
Expand Down
Loading