diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7f851c4..b871a52 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,6 +39,22 @@ jobs: working_directory: test/ compiler: arara args: "--verbose" + # https://github.com/xu-cheng/latex-action/issues/16 + - name: Test Action with Github Default Template + uses: ./ + with: + # The root LaTeX file to be compiled + root_file: test/test.tex + # The working directory for the LaTeX engine + working_directory: # optional + # The LaTeX engine to be invoked + compiler: # optional, default is latexmk + # Extra arguments to be passed to the LaTeX engine + args: # optional, default is -pdf -file-line-error -interaction=nonstopmode + # [Deprecated] Install extra packages by tlmgr + extra_packages: # optional + # Install extra packages by apk + extra_system_packages: # optional - name: Check pdf files run: | file test/test.pdf | grep -q ' PDF ' diff --git a/entrypoint.sh b/entrypoint.sh index dee8dfa..66717d4 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,6 +2,15 @@ set -e +warn() { + echo "::warning :: $1" +} + +error() { + echo "::error :: $1" + exit 1 +} + root_file="$1" working_directory="$2" compiler="$3" @@ -9,6 +18,16 @@ args="$4" extra_packages="$5" extra_system_packages="$6" +if [ -z "$root_file" ]; then + error "Input 'root_file' is missing." +fi + +if [ -z "$compiler" ] && [ -z "$args" ]; then + warn "Input 'compiler' and 'args' are both empty. Reset them to default values." + compiler="latexmk" + args="-pdf -file-line-error -interaction=nonstopmode" +fi + if [ -n "$extra_system_packages" ]; then for pkg in $extra_system_packages; do echo "Install $pkg by apk" @@ -17,12 +36,16 @@ if [ -n "$extra_system_packages" ]; then fi if [ -n "$extra_packages" ]; then - echo "::warning ::Input 'extra_packages' is deprecated. We now build LaTeX document with full TeXLive installed." + warn "Input 'extra_packages' is deprecated. We now build LaTeX document with full TeXLive installed." fi if [ -n "$working_directory" ]; then cd "$working_directory" fi +if [ ! -f "$root_file" ]; then + error "File '$root_file' cannot be found from the directory '$PWD'." +fi + # shellcheck disable=SC2086 "$compiler" $args "$root_file"