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

Recognize opam-repo-ci #394

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

- Add `match_raises`, a generalized version of `check_raises`
(#88, #386, @JoanThibault)
- Update JaneStreet core and async to v0.16 (#390 @tmcgilchrist)
- Update JaneStreet core and async to v0.16 (#390 @tmcgilchrist)
- Recognize opam-repo-ci. (#394, @MisterDA)

### 1.7.0 (2023-02-24)

Expand Down
4 changes: 4 additions & 0 deletions alcotest-help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,7 @@ ENVIRONMENT
Whether Alcotest is running in OCaml-CI, if set to 'true'. Display
tests errors.

OPAM_REPO_CI
Whether Alcotest is running in opam-repo-ci, if set to 'true'.
Display tests errors.

17 changes: 16 additions & 1 deletion src/alcotest-engine/cli.ml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ module Make (P : Platform.MAKER) (M : Monad.S) :
in
Cmdliner.Cmd.Env.info "OCAMLCI" ~doc

let opam_repo_ci_env =
let doc =
Printf.sprintf
"Whether Alcotest is running in opam-repo-ci, if set to %s. Display \
tests errors."
(Arg.doc_quote "true")
in
Cmdliner.Cmd.Env.info "OPAM_REPO_CI" ~doc

let alcotest_source_code_position =
let doc =
"Whether Alcotest should guess the source code position of test \
Expand All @@ -70,7 +79,13 @@ module Make (P : Platform.MAKER) (M : Monad.S) :
Cmdliner.Cmd.Env.info "ALCOTEST_SOURCE_CODE_POSITION" ~doc

let envs =
[ ci_env; github_action_env; ocamlci_env; alcotest_source_code_position ]
[
ci_env;
github_action_env;
ocamlci_env;
opam_repo_ci_env;
alcotest_source_code_position;
]

let set_color =
let env = Cmd.Env.info "ALCOTEST_COLOR" in
Expand Down
35 changes: 20 additions & 15 deletions src/alcotest-engine/config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,29 @@ 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
| _ -> `Disabled
let ci = getenv "CI"
and github_actions = getenv "GITHUB_ACTIONS"
and ocamlci = getenv "OCAMLCI"
and opam_repo_ci = getenv "OPAM_REPO_CI" in
if ci then
let rec aux ci = function
| [] -> Option.value ~default:`Unknown ci
| (false, _) :: tl -> aux ci tl
| (true, ci') :: tl -> (
match ci with None -> aux (Some ci') tl | Some _ -> `Disabled)
in
aux None
[
(github_actions, `Github_actions);
(ocamlci, `OCamlci);
(opam_repo_ci, `Opam_repo_ci);
]
else `Disabled
end

module Verbose = Flag (struct
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 @@ -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 | `OCamlci | `Opam_repo_ci | `Unknown | `Disabled ]
(** All supported Continuous Integration (CI) systems. *)

type t =
Expand Down
Loading