Skip to content

Commit

Permalink
Use setup-ocaml@v2 (#5005)
Browse files Browse the repository at this point in the history
* Use setup-ocaml@v2

Signed-off-by: Sora Morimoto <sora@morimoto.io>
Signed-off-by: Etienne Millon <me@emillon.org>

* Remove ci.ml

Signed-off-by: Etienne Millon <me@emillon.org>

* Disable dune cache

Signed-off-by: Etienne Millon <me@emillon.org>

* Do not install fswatch

Signed-off-by: Etienne Millon <me@emillon.org>

* Reformat code

Signed-off-by: Etienne Millon <me@emillon.org>

Co-authored-by: Etienne Millon <me@emillon.org>
  • Loading branch information
smorimoto and emillon authored Apr 7, 2022
1 parent f94ea99 commit 3b2c64a
Show file tree
Hide file tree
Showing 12 changed files with 103 additions and 175 deletions.
53 changes: 0 additions & 53 deletions .github/workflows/ci.ml

This file was deleted.

82 changes: 42 additions & 40 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,59 +15,48 @@ jobs:
- windows-latest
# Please keep the list in sync with the minimal version of OCaml in
# dune-project, dune.opam.template and bootstrap.ml
ocaml-version:
- 4.13.1
#
# We don't run tests on all versions of the Windows environment and on
# 4.02.x and 4.07.x in other environments
ocaml-compiler:
- 4.13.x
skip_test:
- false
include:
- ocaml-version: 4.12.1
- ocaml-compiler: 4.12.x
os: ubuntu-latest
skip_test: true
- ocaml-version: 4.11.1
- ocaml-compiler: 4.11.x
os: ubuntu-latest
skip_test: true
- ocaml-version: 4.10.0
- ocaml-compiler: 4.10.x
os: ubuntu-latest
skip_test: true
- ocaml-version: 4.09.1
- ocaml-compiler: 4.09.x
os: ubuntu-latest
skip_test: true
- ocaml-version: 4.08.1
- ocaml-compiler: 4.08.x
os: ubuntu-latest
skip_test: true
- ocaml-version: 4.04.2
- ocaml-compiler: 4.04.x
os: ubuntu-latest
skip_test: true
configurator: true
- ocaml-version: 4.02.3
- ocaml-compiler: 4.02.x
os: ubuntu-latest
skip_test: true

# We don't run tests on all versions of the Windows environment and on
# 4.02.3 and 4.07.1 in other environments
env:
# Note that this environment variable is recognized as a string by GitHub
# Actions, so the following doesn't actually work:
#
# if: env.SKIP_TEST
#
# To skip an action, the following should be used:
# if: ${{ env.SKIP_TEST != "false" }}
SKIP_TEST: ${{ matrix.skip_test }}
OCAML_VERSION: ${{ matrix.ocaml-version }}
OS: ${{ matrix.os }}
CONFIGURATOR: ${{ matrix.configurator }}

runs-on: ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Use OCaml ${{ matrix.ocaml-version }}
uses: ocaml/setup-ocaml@v1
- name: Use OCaml ${{ matrix.ocaml-compiler }}
uses: ocaml/setup-ocaml@v2
with:
ocaml-version: ${{ matrix.ocaml-version }}
ocaml-compiler: ${{ matrix.ocaml-compiler }}
opam-depext: false

# git user needs to be configured for the following tests:
# otherlibs/build-info/test/run.t
Expand All @@ -76,16 +65,15 @@ jobs:
# test/expect-tests/vcs_tests.ml
- name: Set git user
run: |
git config --global user.name github-actions
git config --global user.email github-actions-bot@users.noreply.github.com
- run: opam exec -- ocaml .github/workflows/ci.ml pin
git config --global user.name github-actions[bot]
git config --global user.email github-actions[bot]@users.noreply.github.com
# Install ocamlfind-secondary and ocaml-secondary-compiler, if needed
- run: opam install ./dune.opam --deps-only --with-test

- run: brew install fswatch coreutils
if: env.OS == 'macos-latest'
- name: Install system deps on macOS
run: brew install coreutils
if: ${{ matrix.os == 'macos-latest' }}

# dune doesn't have any additional dependencies so we can build it right
# away this makes it possible to see build errors as soon as possible
Expand All @@ -94,14 +82,28 @@ jobs:
# Ensure Dune can build itself
- run: opam exec -- ./dune.exe build -p dune --profile dune-bootstrap

- name: run test suite
run: opam exec -- ocaml .github/workflows/ci.ml test
if: env.SKIP_TEST != 'true'
- name: Install deps on Unix
run: |
opam install . --deps-only --with-test
opam exec -- make dev-deps
if: ${{ matrix.os != 'windows-latest' && matrix.skip_test == false }}

- name: Install deps on Win32
run: opam install ./dune-configurator.opam --deps-only --with-test
if: ${{ matrix.os == 'windows-latest' && matrix.skip_test == false }}

- name: Run test suite on Unix
run: opam exec -- make test
if: ${{ matrix.os != 'windows-latest' && matrix.skip_test == false }}

- name: Run test suite on Win32
run: opam exec -- make test-windows
if: ${{ matrix.os == 'windows-latest' && matrix.skip_test == false }}

- name: test source is well formatted
- name: Test source is well formatted
run: opam exec -- make fmt
if: env.OCAML_VERSION == '4.12.0' && env.OS == 'ubuntu-latest'
if: ${{ matrix.os == 'ubuntu-latest' && matrix.ocaml-compiler == '4.13.x' }}

- name: build configurator
- name: Build configurator
run: opam install ./dune-configurator.opam
if: env.CONFIGURATOR == 'true'
if: ${{ matrix.configurator == true }}
18 changes: 4 additions & 14 deletions bin/coq.ml
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
open Import

let doc =
"Command group related to Coq."
let doc = "Command group related to Coq."

let sub_commands_synopsis =
Common.command_synopsis
[ "coq top FILE -- ARGS"
]
let sub_commands_synopsis = Common.command_synopsis [ "coq top FILE -- ARGS" ]

let man =
[ `Blocks sub_commands_synopsis
]
let man = [ `Blocks sub_commands_synopsis ]

let info = Term.info ~doc ~man "coq"

let group =
( Term.Group.Group
[ in_group Coqtop.command
]
, info )
let group = (Term.Group.Group [ in_group Coqtop.command ], info)
46 changes: 22 additions & 24 deletions bin/coqtop.ml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
open Stdune
open Import

let doc =
"Execute the Coq toplevel with the local configuration."
let doc = "Execute the Coq toplevel with the local configuration."

let man =
[ `S "DESCRIPTION"
Expand Down Expand Up @@ -40,7 +39,7 @@ let term =
let context = Dune_rules.Super_context.context sctx in
(* Try to compute a relative path if we got an absolute path. *)
let coq_file_arg =
let cwd = Path.external_ (Path.External.initial_cwd) in
let cwd = Path.external_ Path.External.initial_cwd in
let file =
(* Best-effort symbolic link unfolding. *)
let file = Fpath.follow_symlinks coq_file_arg in
Expand All @@ -62,7 +61,7 @@ let term =
let p = Common.prefix_target common dir in
Path.Build.relative context.build_dir p
in
let* (coqtop, args) =
let* coqtop, args =
let open Memo.Build.O in
Build_system.run_exn (fun () ->
let* dc = Dune_rules.Dir_contents.get sctx ~dir in
Expand All @@ -72,37 +71,38 @@ let term =
match Dune_rules.Coq_sources.find_module ~source coq_src with
| Some m -> snd m
| None ->
let hints =
[ Pp.textf "is the file part of a stanza?"
; Pp.textf "has the file been written to disk?" ]
in
User_error.raise ~hints
[ Pp.textf "cannot find file: %s" coq_file_arg ]
let hints =
[ Pp.textf "is the file part of a stanza?"
; Pp.textf "has the file been written to disk?"
]
in
User_error.raise ~hints
[ Pp.textf "cannot find file: %s" coq_file_arg ]
in
let stanza =
Dune_rules.Coq_sources.lookup_module coq_src coq_module
in
let* (args, boot_type) =
let* args, boot_type =
match stanza with
| None ->
User_error.raise
[ Pp.textf "file not part of any stanza: %s" coq_file_arg ]
User_error.raise
[ Pp.textf "file not part of any stanza: %s" coq_file_arg ]
| Some (`Theory theory) ->
Dune_rules.Coq_rules.coqtop_args_theory ~sctx ~dir
~dir_contents:dc theory coq_module
Dune_rules.Coq_rules.coqtop_args_theory ~sctx ~dir
~dir_contents:dc theory coq_module
| Some (`Extraction extr) ->
Dune_rules.Coq_rules.coqtop_args_extraction ~sctx ~dir
~dir_contents:dc extr
Dune_rules.Coq_rules.coqtop_args_extraction ~sctx ~dir
~dir_contents:dc extr
in
let* _ : unit * Dep.Fact.t Dep.Map.t =
let* (_ : unit * Dep.Fact.t Dep.Map.t) =
let deps =
Dune_rules.Coq_rules.deps_of ~dir ~boot_type coq_module
in
Action_builder.run deps Eager
in
let* (args, _) : string list * Dep.Fact.t Dep.Map.t =
let args =
let dir = Path.external_ (Path.External.initial_cwd) in
let dir = Path.external_ Path.External.initial_cwd in
Dune_rules.Command.expand ~dir (S args)
in
Action_builder.run args.build Eager
Expand All @@ -111,14 +111,12 @@ let term =
Super_context.resolve_program sctx ~dir ~loc:None coqtop
in
let prog = Action.Prog.ok_exn prog in
let+ _ : Digest.t = Build_system.build_file prog in
let+ (_ : Digest.t) = Build_system.build_file prog in
(Path.to_string prog, args))
in
let argv =
let topfile =
Path.to_absolute_filename (Path.build coq_file_build)
in
coqtop :: "-topfile" :: topfile :: args @ extra_args
let topfile = Path.to_absolute_filename (Path.build coq_file_build) in
(coqtop :: "-topfile" :: topfile :: args) @ extra_args
in
let env = Super_context.context_env sctx in
Fiber.return (coqtop, argv, env))
Expand Down
24 changes: 11 additions & 13 deletions otherlibs/stdune/fpath.ml
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,22 @@ let rec follow_symlinks path =
let parent = Filename.dirname path in
let file = Filename.basename path in
(* If we reached the root, just return the path. *)
if parent = path then Some path else
if parent = Filename.current_dir_name then
if parent = path then Some path
else if parent = Filename.current_dir_name then
(* Only keep the initial ["."] if it was in the path. *)
if path = Filename.concat Filename.current_dir_name file then
Some path
else
Some file
if path = Filename.concat Filename.current_dir_name file then Some path
else Some file
else
(* Recurse on parent, and re-add toplevel file. *)
match follow_symlinks parent with
| None -> None
| Some parent ->
let path = Filename.concat parent file in
(* Nomalize the result. *)
match follow_symlink path with
| Ok p -> Some p
| Error Max_depth_exceeded -> None
| Error _ -> Some path
| Some parent -> (
let path = Filename.concat parent file in
(* Nomalize the result. *)
match follow_symlink path with
| Ok p -> Some p
| Error Max_depth_exceeded -> None
| Error _ -> Some path)

let win32_unlink fn =
try Unix.unlink fn
Expand Down
6 changes: 3 additions & 3 deletions otherlibs/stdune/fpath.mli
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ type follow_symlink_error =

val follow_symlink : string -> (string, follow_symlink_error) result

(** [follow_symlinks path] returns a file path that is equivalent to [path],
but free of symbolic links. The value [None] is returned if the maximum
symbolic link dept is reached (i.e., [follow_symlink] returns the value
(** [follow_symlinks path] returns a file path that is equivalent to [path], but
free of symbolic links. The value [None] is returned if the maximum symbolic
link dept is reached (i.e., [follow_symlink] returns the value
[Error Max_depth_exceeded] on some intermediate path). *)
val follow_symlinks : string -> string option

Expand Down
5 changes: 3 additions & 2 deletions otherlibs/stdune/map.ml
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,12 @@ module Make (Key : Key) : S with type key = Key.t = struct
| Some x -> List.append x entries))

let find_elt : type a. a t -> f:(a -> bool) -> (key * a) option =
fun m ~f ->
fun m ~f ->
let exception Found of (key * a) in
try
let check_found k e = if f e then raise_notrace (Found (k, e)) in
iteri ~f:(fun k -> List.iter ~f:(check_found k)) m; None
iteri ~f:(fun k -> List.iter ~f:(check_found k)) m;
None
with Found p -> Some p
end

Expand Down
4 changes: 1 addition & 3 deletions src/dune_rules/command.mli
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,4 @@ end
corresponding strings, assuming they will be used as arguments to run a
command in directory [dir]. *)
val expand :
dir:Path.t ->
'a Args.t ->
string list Action_builder.With_targets.t
dir:Path.t -> 'a Args.t -> string list Action_builder.With_targets.t
Loading

0 comments on commit 3b2c64a

Please sign in to comment.