diff --git a/action.yml b/action.yml index 1a60611..fa55780 100644 --- a/action.yml +++ b/action.yml @@ -25,11 +25,15 @@ inputs: onlyDiff: description: "only format changed files that differ from the provided branch" required: false - + + parallel: + description: "run Pint in parallel mode (requires Pint >= 1.23)" + required: false + pintVersion: description: "laravel/pint composer version to install a specific version." required: false - + useComposer: description: "Use Laravel Pint version from project composer lock file. Lock file must be preset to use this flag." required: false @@ -42,6 +46,8 @@ runs: - ${{ inputs.config-path }} - ${{ inputs.preset }} - ${{ inputs.only-dirty }} + - ${{ inputs.onlyDiff }} + - ${{ inputs.parallel }} - ${{ inputs.pint-version }} - ${{ inputs.use-composer }} branding: diff --git a/entrypoint.sh b/entrypoint.sh index fff66a7..e506b6a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,7 +2,6 @@ set -e pint_install_command=("composer global require laravel/pint:PINT_VERSION --no-progress --dev") - if [[ "${INPUT_PINTVERSION}" ]] then pint_install_command="${pint_install_command/PINT_VERSION/${INPUT_PINTVERSION}}" @@ -13,8 +12,14 @@ else pint_install_command="${pint_install_command/:PINT_VERSION/}" fi -pint_command=("pint") +echo "Running Command: ${pint_install_command[@]}" +${pint_install_command[@]} +PATH="/tmp/vendor/bin:${PATH}" + +pint_version=$(pint --version | grep -oE '[0-9]+\.[0-9]+(\.[0-9]+)?' | head -1) +version_check=$(printf '%s\n1.23' "$pint_version" | sort -V | head -1) +pint_command=("pint") if [[ "${INPUT_TESTMODE}" == true ]]; then pint_command+=" --test" fi @@ -39,10 +44,14 @@ if [[ "${INPUT_ONLYDIRTY}" == true ]]; then pint_command+=" --dirty" fi -echo "Running Command: " "${pint_install_command[@]}" - -${pint_install_command[@]} -PATH="/tmp/vendor/bin:${PATH}" +if [[ "${INPUT_PARALLEL}" == true ]]; then + if [[ "$version_check" == "1.23" ]]; then + pint_command+=" --parallel" + echo "Parallel mode enabled (Pint version: $pint_version)" + else + echo "Warning: Parallel mode requested but Pint version $pint_version < 1.23. Skipping --parallel flag." + fi +fi echo "Running Command: " "${pint_command[@]}"