Skip to content

Add task for downloading membrane demos - #1067

Merged
Noarkhh merged 9 commits into
masterfrom
mix-task-demo
Mar 9, 2026
Merged

Add task for downloading membrane demos#1067
Noarkhh merged 9 commits into
masterfrom
mix-task-demo

Conversation

@Noarkhh

@Noarkhh Noarkhh commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

mix membrane.demo task pulls specific or all demos available. It can also list available demos with -l option and the "manifest" of available demos it the membrane_demo readme.

@Noarkhh Noarkhh self-assigned this Feb 5, 2026
@Noarkhh Noarkhh added this to Smackore Feb 5, 2026
@Noarkhh Noarkhh moved this to In Progress in Smackore Feb 5, 2026
@Noarkhh Noarkhh linked an issue Feb 5, 2026 that may be closed by this pull request
@Noarkhh
Noarkhh force-pushed the mix-task-demo branch 2 times, most recently from f3b5fe7 to 735be2f Compare February 6, 2026 14:18
@Noarkhh
Noarkhh changed the base branch from master to membrane-elements-tasks February 6, 2026 14:18
@Noarkhh
Noarkhh marked this pull request as ready for review February 6, 2026 16:43
@Noarkhh
Noarkhh requested a review from mat-hek as a code owner February 6, 2026 16:43
@Noarkhh Noarkhh moved this from In Progress to In Review in Smackore Feb 6, 2026
@mat-hek
mat-hek removed their request for review February 10, 2026 09:56
Comment thread lib/mix/tasks/membrane.demo.ex Outdated
@moduledoc """
Download Membrane demos and examples. Requires `git` installed.

$ mix membrane.demo [-a] [-l] [-d <repo_dir>] <demos> ...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mix membrane.demo -l shouldn't require passing <demos>

Comment thread lib/mix/tasks/membrane.demo.ex Outdated
## 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.

@varsill varsill Feb 12, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the default directory? Please mention it in task description

Comment thread mix.exs
Comment thread lib/mix/tasks/membrane.demo.ex Outdated

defp copy_specific_demos(repo_dir, demos_names) do
{_output, 0} =
System.cmd("git", ["clone", "-q", "--depth", "1", "-n", @demos_clone_url, repo_dir])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 FelonEkonom left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about adding a test? 🙂

Comment on lines +18 to +33
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)

@FelonEkonom FelonEkonom Feb 23, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's check at least if pulled demo contains lib directory, to ensure it didn't fail at some step

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Noarkhh
Noarkhh requested a review from FelonEkonom March 5, 2026 10:00

@FelonEkonom FelonEkonom left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome 🎉

Comment thread lib/mix/tasks/membrane.demo.ex Outdated
## 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what is the default directory? :D

@Noarkhh Noarkhh Mar 6, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cwd, it's in the moduledoc

@varsill
varsill self-requested a review March 9, 2026 14:36

@varsill varsill left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥇

@Noarkhh
Noarkhh force-pushed the membrane-elements-tasks branch from b84e862 to e34bcd6 Compare March 9, 2026 15:29
Base automatically changed from membrane-elements-tasks to master March 9, 2026 15:42
@Noarkhh
Noarkhh merged commit 9c81d5a into master Mar 9, 2026
5 of 6 checks passed
@Noarkhh
Noarkhh deleted the mix-task-demo branch March 9, 2026 15:44
@github-project-automation github-project-automation Bot moved this from In Review to Done in Smackore Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Add mix tasks for easier start with membrane

3 participants