Skip to content

Commit

Permalink
Merge pull request #161 from boesing/feature/pass-php-version-to-scripts
Browse files Browse the repository at this point in the history
Pass `PHP` version (<major>.<minor>) to the scripts
boesing authored Jul 17, 2023
2 parents de5ce6e + 6948355 commit 625e2b4
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -114,12 +114,14 @@ The `.laminas-ci/pre-install.sh` command runs before any other command is execut
- `$1`: the user the QA command will run under
- `$2`: the WORKDIR path
- `$3`: the `$JOB` passed to the entrypoint (see above)
- `$4`: the `$PHP` (<major>.<minor>) configured for execution

The `.laminas-ci/pre-run.sh` command runs immediately prior to the QA command, and will receive the following arguments:

- `$1`: the user the QA command will run under
- `$2`: the WORKDIR path
- `$3`: the `$JOB` passed to the entrypoint (see above)
- `$4`: the `$PHP` (<major>.<minor>) configured for execution

It is also possible to pass `before_script` with a list of commands via the `$JOB` variable.

@@ -129,6 +131,7 @@ The `.laminas-ci/post-run.sh` command will receive these arguments:
- `$2`: the user the QA command will run under
- `$3`: the WORKDIR path
- `$4`: the `$JOB` passed to the entrypoint (see above)
- `$5`: the `$PHP` (<major>.<minor>) configured for execution

It is also possible to pass `after_script` with a list of commands via the `$JOB` variable.
`$STATUS` is a variable containing the exit code of the command and can be used in the commands listed in `after_script`.
7 changes: 4 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -146,6 +146,7 @@ RECONFIGURE_PHP_DEFAULT="yes"
# If the default PHP version from the container is requested, we do not reconfigure PHP version
if [[ "${PHP}" == "@default" ]]; then
RECONFIGURE_PHP_DEFAULT="no"
PHP=$(php -nr "echo PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION;")
fi

if [[ "${COMMAND}" =~ "^roave-backward-compatibility-check" ]] || [[ "${COMMAND}" =~ "^/usr/bin/env roave-backward-compatibility-check" ]] || [[ "${COMMAND}" =~ "^/usr/local/bin/roave-backward-compatibility-check" ]]; then
@@ -175,7 +176,7 @@ checkout
# Is there a pre-install script available?
if [ -x ".laminas-ci/pre-install.sh" ];then
echo "Executing pre-install commands from .laminas-ci/pre-install.sh"
./.laminas-ci/pre-install.sh testuser "${PWD}" "${JOB}"
./.laminas-ci/pre-install.sh testuser "${PWD}" "${JOB}" "${PHP}"
fi

EXTENSIONS=$(echo "${JOB}" | jq -r ".extensions // [] | join(\" \")")
@@ -237,7 +238,7 @@ chown -R testuser .
# Is there a pre-run script available?
if [ -x ".laminas-ci/pre-run.sh" ];then
echo "Executing pre-run commands from .laminas-ci/pre-run.sh"
./.laminas-ci/pre-run.sh testuser "${PWD}" "${JOB}"
./.laminas-ci/pre-run.sh testuser "${PWD}" "${JOB}" "${PHP}"
fi

for BEFORE_SCRIPT_COMMAND in "${BEFORE_SCRIPT[@]}"; do
@@ -257,7 +258,7 @@ set -e
# Is there a post-run script available?
if [ -x ".laminas-ci/post-run.sh" ];then
echo "Executing post-run commands from .laminas-ci/post-run.sh"
./.laminas-ci/post-run.sh "${STATUS}" testuser "${PWD}" "${JOB}"
./.laminas-ci/post-run.sh "${STATUS}" testuser "${PWD}" "${JOB}" "${PHP}"
fi

for AFTER_SCRIPT_COMMAND in "${AFTER_SCRIPT[@]}"; do

0 comments on commit 625e2b4

Please sign in to comment.