Skip to content

Take additional composer arguments into account #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ The JSON string should represent an object with the following information:
"dependencies": "dependencies to test against; one of lowest, locked, latest",
"ignore_platform_reqs_on_8": "(boolean; OPTIONAL; DEPRECATED) Whether or not to ignore platform requirements on PHP 8; defaults to true",
"ignore_php_platform_requirement": "(boolean; OPTIONAL) Whether or not to ignore PHP platform requirement; defaults to false",
"command": "command to run to perform the check (empty in case you dont want to excecute any command)"
"command": "command to run to perform the check (empty in case you dont want to excecute any command)",
"additional_composer_arguments": [
"arguments which will be passed to `composer install` or `composer update`, passed as a list or as a list; e.g. --no-scripts"
]
}
```

Expand Down
22 changes: 13 additions & 9 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ function help {
echo ""
echo "Run a QA JOB as specified in a JSON object."
echo "The JSON should include each of the following elements:"
echo " - command: command to run"
echo " - php: the PHP version to use"
echo " - extensions: a list of additional extensions to enable"
echo " - ini: a list of php.ini directives"
echo " - dependencies: the dependency set to run against (lowest, latest, locked)"
echo " - command: command to run"
echo " - php: the PHP version to use"
echo " - extensions: a list of additional extensions to enable"
echo " - ini: a list of php.ini directives"
echo " - dependencies: the dependency set to run against (lowest, latest, locked)"
echo " - ignore_php_platform_requirement: flag to enable/disable the PHP platform requirement when executing composer \`install\` or \`update\`"
echo " - additional_composer_arguments: a list of composer arguments to be added when \`install\` or \`update\` is called."
echo ""
}

Expand Down Expand Up @@ -77,10 +79,11 @@ function checkout {
fi
}

function composer_install {
function composer_install_dependencies {
local DEPS=$1
local IGNORE_PHP_PLATFORM_REQUIREMENT=$2
local COMPOSER_ARGS="--ansi --no-interaction --no-progress --prefer-dist"
local ADDITIONAL_COMPOSER_ARGUMENTS=$3
local COMPOSER_ARGS="--ansi --no-interaction --no-progress --prefer-dist ${ADDITIONAL_COMPOSER_ARGUMENTS}"
if [[ "${IGNORE_PHP_PLATFORM_REQUIREMENT}" == "true" ]];then
COMPOSER_ARGS="${COMPOSER_ARGS} --ignore-platform-req=php"
fi
Expand All @@ -99,7 +102,7 @@ function composer_install {
*)
echo "Installing dependencies as specified in lockfile via Composer"
# shellcheck disable=SC2086
composer install ${COMPOSER_ARGS}
echo composer install ${COMPOSER_ARGS}
;;
esac

Expand Down Expand Up @@ -148,6 +151,7 @@ INI=$(echo "${JOB}" | jq -r '.ini // [] | join("\n")')
DEPS=$(echo "${JOB}" | jq -r '.dependencies // "locked"')
IGNORE_PLATFORM_REQS_ON_8=$(echo "${JOB}" | jq -r 'if has("ignore_platform_reqs_8") | not then "yes" elif .ignore_platform_reqs_8 then "yes" else "no" end')
IGNORE_PHP_PLATFORM_REQUIREMENT=$(echo "${JOB}" | jq -r '.ignore_php_platform_requirement')
ADDITIONAL_COMPOSER_ARGUMENTS=$(echo "${JOB}" | jq -r '.additional_composer_arguments // [] | join("\n")')

# Old matrix generation
if [ "${IGNORE_PHP_PLATFORM_REQUIREMENT}" == "null" ]; then
Expand Down Expand Up @@ -177,7 +181,7 @@ if [[ "${GITHUB_TOKEN}" != "" ]];then
composer config --global github-oauth.github.com "${GITHUB_TOKEN}"
fi

composer_install "${DEPS}" "${IGNORE_PHP_PLATFORM_REQUIREMENT}"
composer_install_dependencies "${DEPS}" "${IGNORE_PHP_PLATFORM_REQUIREMENT}" "${ADDITIONAL_COMPOSER_ARGUMENTS}"

if [[ "${COMMAND}" =~ phpunit ]];then
echo "Setting up PHPUnit problem matcher"
Expand Down