Add task for downloading membrane demos - #1067
Conversation
f3b5fe7 to
735be2f
Compare
| @moduledoc """ | ||
| Download Membrane demos and examples. Requires `git` installed. | ||
|
|
||
| $ mix membrane.demo [-a] [-l] [-d <repo_dir>] <demos> ... |
There was a problem hiding this comment.
mix membrane.demo -l shouldn't require passing <demos>
| ## Options | ||
| * `-l, --list` - List all demos available and their brief descriptions. | ||
| * `-a, --all` - Pull the repository with all demos. | ||
| * `-d, --directory` - Directory where the demos should be placed in. |
There was a problem hiding this comment.
What is the default directory? Please mention it in task description
|
|
||
| defp copy_specific_demos(repo_dir, demos_names) do | ||
| {_output, 0} = | ||
| System.cmd("git", ["clone", "-q", "--depth", "1", "-n", @demos_clone_url, repo_dir]) |
There was a problem hiding this comment.
I would use stderr_to_stdout: true option for this System.cmd and matched against return value - if it's non-zero, I would log the whole output
FelonEkonom
left a comment
There was a problem hiding this comment.
What about adding a test? 🙂
5e8c424 to
401c530
Compare
| receive do | ||
| msg -> assert {:mix_shell, :info, _message} = msg | ||
| end | ||
| end) | ||
| end | ||
|
|
||
| @tag :tmp_dir | ||
| test "all at once", %{tmp_dir: tmp} do | ||
| demos_list = get_available_demos_list() | ||
| Demo.run(["-d", tmp] ++ demos_list) | ||
|
|
||
| Enum.each(demos_list, fn _demo -> | ||
| receive do | ||
| msg -> assert {:mix_shell, :info, _message} = msg | ||
| end | ||
| end) |
There was a problem hiding this comment.
Let's check at least if pulled demo contains lib directory, to ensure it didn't fail at some step
There was a problem hiding this comment.
Not every demo contains lib directory, for examples some demos are livebooks or just .exs scripts, but I added an assertion checking if the demo path actually exists.
| ## Options | ||
| * `-l, --list` - List all demos available and their brief descriptions. | ||
| * `-a, --all` - Pull the repository with all demos. | ||
| * `-d, --directory` - Specify a directory where the demos should be placed in. |
There was a problem hiding this comment.
So what is the default directory? :D
There was a problem hiding this comment.
cwd, it's in the moduledoc
b84e862 to
e34bcd6
Compare
mix membrane.demotask pulls specific or all demos available. It can also list available demos with-loption and the "manifest" of available demos it themembrane_demoreadme.