Skip to content

Define a new Functoria.Action module and use it everywhere#1077

Merged
samoht merged 1 commit intomirage:masterfrom
samoht:actions
Mar 15, 2020
Merged

Define a new Functoria.Action module and use it everywhere#1077
samoht merged 1 commit intomirage:masterfrom
samoht:actions

Conversation

@samoht
Copy link
Copy Markdown
Member

@samoht samoht commented Mar 9, 2020

Follow up from #930

@samoht
Copy link
Copy Markdown
Member Author

samoht commented Mar 9, 2020

What remains to be done:

@samoht samoht force-pushed the actions branch 2 times, most recently from 9329977 to a3d714b Compare March 10, 2020 17:40
@samoht
Copy link
Copy Markdown
Member Author

samoht commented Mar 10, 2020

Updated, now the only module using Bos is Functoria.Action. There are too much Action.run in the current code, but they are a bit hard to remove (as doing will propagate 'a Action.t a bit everywhere, especially inside 'a Cmdliner.Term.t where they become a pain to manipulate).

Current use of Action.run:

lib/functoria/app.ml:    build_and_execute ~state ?help_ppf ?err_ppf argv |> Action.run |> function
lib/functoria/app.ml:      run_configure_with_argv ~state Action.run Sys.argv c
lib/functoria/app.ml:    run () |> Action.run |> exit_err
lib/functoria/opam.ml:    match Action.run @@ find_git () with
lib/mirage/mirage_key.ml:    ( match Action.run @@ Action.run_cmd_out Bos.Cmd.(v "uname" % "-s") with
test/f0/f0.ml:    match Action.run @@ split_root () with
test/functoria/gen-1/test.ml:  match Action.run (test ()) with Ok () -> () | Error (`Msg e) -> failwith e
test/functoria/gen-2/test.ml:  match Action.run (test ()) with Ok () -> () | Error (`Msg e) -> failwith e
test/mirage/gen-1/test.ml:  match Functoria.Action.run (test ()) with

The one in functoria/opam.ml are filesystem access to guess the repository root ; and the one in mirage/mirage_key.ml is to find the kind of OS we are running on. I think that's ok to keep them like this for now on. The important ones are the one in functoria/app.ml where they are used in register and run_with_argv. We could expose similar functions which are interpreted instead to ease testing, I'll experiment with this next.

@samoht
Copy link
Copy Markdown
Member Author

samoht commented Mar 10, 2020

Tests have been added, but it seems that something is a bit off, as test/mirage/action/test.expected is truncated vs. https://github.com/mirage/mirage/pull/930/files#diff-7661350cdd5ae1288a23149c76a53107

@samoht
Copy link
Copy Markdown
Member Author

samoht commented Mar 12, 2020

I've just pushed a few tests for Functoria.Action. It should now have a good test coverage.

Still need to inspect the mirage test results before merging this, as they look a bit empty to me.

@dinosaure
Copy link
Copy Markdown
Member

The goal of this PR is to track any operations on the system (like copy, open_file, etc.) ?

@samoht
Copy link
Copy Markdown
Member Author

samoht commented Mar 12, 2020

Yes the goal is to never use Bos directly. 'a Action.t actions can be introspected, so we can compute the set of generated files automatically. It's also makes the whole thing much easier to test (just print the trace instead of calling Bos) and it also allow to add a --dry-run command to list the commands before running them.

@samoht samoht force-pushed the actions branch 2 times, most recently from 1cc0d7a to 023ed95 Compare March 12, 2020 22:46
@samoht samoht force-pushed the actions branch 2 times, most recently from ca64612 to 197d3c8 Compare March 14, 2020 17:51
@samoht
Copy link
Copy Markdown
Member Author

samoht commented Mar 14, 2020

Pushed a new version, with more tests and a small fix on mirage-skeleton which should make Travis happt.

@samoht samoht force-pushed the actions branch 10 times, most recently from 436c4bf to bea012d Compare March 14, 2020 22:20
@samoht
Copy link
Copy Markdown
Member Author

samoht commented Mar 15, 2020

All green! I'll squash and merge here and in mirage-skeleton

Initial draft implementation from @emillon (mirage#930)
@samoht samoht merged commit 888a659 into mirage:master Mar 15, 2020
@samoht samoht deleted the actions branch March 15, 2020 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants