Skip to content

Commit

Permalink
Fix bugs and add features (#9)
Browse files Browse the repository at this point in the history
* add community_ver and extra_repos options

* support other types output (.mov .png)

* fix multi args' bug
  • Loading branch information
TonyCrane authored Jul 30, 2020
1 parent c633fe2 commit c46b105
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 10 deletions.
23 changes: 22 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
scene_names: "WriteStuff"
args: "--high_quality"
fonts_dir: test/fonts/
extra_repos: "https://github.com/manim-kindergarten/manim_sandbox"
- name: Save output as artifacts
uses: actions/upload-artifact@v2
if: success()
Expand All @@ -34,10 +35,30 @@ jobs:
args: "--high_quality"
fonts_dir: test/fonts/
manim_repo: "https://github.com/ManimCommunity/manim"
community_ver: true
- name: Save output as artifacts
uses: actions/upload-artifact@v2
if: success()
with:
name: Videos_cmver
path: ${{ steps.renderer.outputs.video_path }}

test-other-types:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Test rendering example_scenes.py
uses: ./
id: renderer
with:
source_file: test/example_scenes.py
scene_names: "WriteStuff"
args: "--high_quality -t"
fonts_dir: test/fonts/
extra_repos: "https://github.com/manim-kindergarten/manim_sandbox"
- name: Save output as artifacts
uses: actions/upload-artifact@v2
if: success()
with:
name: OtherTypeOutputs
path: ${{ steps.renderer.outputs.video_path }}

8 changes: 8 additions & 0 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
可以改为任何manim源码的repo(确保可以直接运行,并且含有文件`manim.py`以使用`python manim.py ... ...`命令)<br/>
目前支持 https://github.com/ManimCommunity/manim ,但无法使用https://github.com/3b1b/manim

* `community_ver`

使用的`manim_repo`是否是community版(比如一个ManimCommunity/manim的fork)

* `extra_packages`

需要用到的额外python模块,使用`pip`安装。每两个之间用空格隔开,例如:`"packageA packageB"`。
Expand All @@ -40,6 +44,10 @@

需要用到的系统文件,使用`apk`安装。

* `extra_repos`

需要clone到当前工作区的额外存储库,每两个之间用空格隔开。

* `pre_render`

在渲染前要执行的shell命令。
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ It runs on [a docker image](https://github.com/manim-kindergarten/manim_texlive_

**Required**, the source file with the scenes you want to render (relative to the current repo). E.g.:
```yaml
-uses: manim-kindergarten/manim_action_renderer@master
- uses: manim-kindergarten/manim_action_renderer@master
with:
source_file: path/to/your/file.py
```
Expand All @@ -35,6 +35,10 @@ It runs on [a docker image](https://github.com/manim-kindergarten/manim_texlive_
This can be changed to https://github.com/ManimCommunity/manim now. <br/>
But at present, this will throw an error when set to https://github.com/3b1b/manim .

* `community_ver`

Whether the manim repo is a community version (e.g. a fork of ManimCommunity/manim) or not. The default is false.

* `extra_packages`

Additional python modules that need to be used, use `pip` to install them. Use a space to separate every two, e.g.: `"packageA packageB"`.
Expand All @@ -43,6 +47,10 @@ It runs on [a docker image](https://github.com/manim-kindergarten/manim_texlive_

The system packages that need to be used, use the `apk` to install them.

* `extra_repos`

Extra repositories you want to clone to the current workspace. Use a space to separate every two repos.

* `pre_render`

The shell command to be executed before rendering.
Expand Down
7 changes: 7 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ inputs:
manim_repo:
description: The manim engine repo you want to use to render
default: https://github.com/manim-kindergarten/manim
community_ver:
description: Whether the manim repo is a fork of ManimCommunity/manim or not
default: false
extra_packages:
description: Install extra python packages by pip
extra_system_packages:
description: Install extra packages by apk
extra_repos:
description: Clone extra repo to workspace
pre_render:
description: Arbitrary bash codes to be executed before rendering
post_render:
Expand All @@ -46,6 +51,8 @@ runs:
- ${{ inputs.post_render }}
- ${{ inputs.merge_assets }}
- ${{ inputs.fonts_dir }}
- ${{ inputs.extra_repos }}
- ${{ inputs.community_ver }}
branding:
icon: camera
color: blue
21 changes: 14 additions & 7 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ pre_render="${7}"
post_render="${8}"
merge_assets="${9}"
fonts_dir="${10}"
extra_repos="${11}"
community="${12}"

if [[ "$manim_repo" == "https://github.com/ManimCommunity/manim" || "$manim_repo" == "https://github.com/ManimCommunity/manim/" ]]; then
community=true
else
community=false
fi
echo $community
echo "Community? $community"

if [[ -z "$source_file" ]]; then
error "Input 'source_file' is missing."
Expand Down Expand Up @@ -69,7 +69,7 @@ merge() {
fi
}

if [[ $merge_assets && $community == false ]]; then
if [[ $merge_assets == true && $community == false ]]; then
merge "assets/" "manim/assets/"
fi

Expand Down Expand Up @@ -100,6 +100,13 @@ if [[ -n "$extra_packages" ]]; then
done
fi

if [[ -n "$extra_repos" ]]; then
for repo in $extra_repos; do
info "Cloning $repo by git..."
git clone "$repo" --depth=1
done
fi

if [[ -n "$pre_render" ]]; then
info "Run pre compile commands"
eval "$pre_render"
Expand All @@ -108,14 +115,14 @@ fi
info "Rendering..."
if [[ $community == true ]]; then
for sce in $scene_names; do
python -m manim "$source_file" "$sce" "$args"
python -m manim "$source_file" $sce ${args[@]}
if [ $? -ne 0 ]; then
error "manim render error"
fi
done
else
for sce in $scene_names; do
python manim.py "$source_file" "$sce" "$args"
python manim.py "$source_file" $sce ${args[@]}
if [ $? -ne 0 ]; then
error "manim render error"
fi
Expand All @@ -131,7 +138,7 @@ info "Searching outputs..."
cnt=0
videos_path="/github/workspace/media/videos/"
for sce in $scene_names; do
video=$(find ${videos_path} -name "${sce}.mp4")
video=$(find ${videos_path} -name "${sce}.mp4" -o -name "${sce}.mov" -o -name "${sce}.png")
output[$cnt]=$video
cnt=$cnt+1
done
Expand Down
2 changes: 1 addition & 1 deletion test/example_scenes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from manimlib.imports import *

from manim_sandbox.utils.imports import *

class WriteStuff(Scene):
def construct(self):
Expand Down

0 comments on commit c46b105

Please sign in to comment.