#ps auxwww | grep fpm
#pwd
#sudo env
+ #systemctl list-units --all --type=service --no-pager | grep running
#systemctl status apache2.service
#ls -la /etc/apache2/mods-enabled
#ls -la /etc/apache2/conf-enabled
#- dependency: phpxmlrpc/jsonrpc
- dependency: phpxmlrpc/polyfill-xmlrpc
steps:
+ # NB: unusually, but intentionally, we do _not_ download the code of this very own repo into the workspace!
+
- name: download dependency, build its test vm and run its tests against the current commit
run: |
- systemctl list-units --all --type=service --no-pager | grep running
# We test against the latest available release of dependents.
# Arguably, we could (also?) test against their master branch, in case some fixes were pushed there
# and not released yet, which make them work ok with us, but those tend to be tested when pushing
sed -i -E -e 's|"phpxmlrpc/phpxmlrpc" *: *"source"|"phpxmlrpc/phpxmlrpc_": "source"|g' composer.json
sed -i -E -e 's|"phpxmlrpc/phpxmlrpc" *: *".+|"phpxmlrpc/phpxmlrpc": "dev-master#${{ github.ref_name }} as 4.999"|g' composer.json
sed -i -E -e 's|"phpxmlrpc/phpxmlrpc_" *: *"source"|"phpxmlrpc/phpxmlrpc": "source"|g' composer.json
+ # @todo either set COMPOSER_ROOT_VERSION env var, or inject `version` into composer.json, to allow
+ # composer to know that the top-level project is on `dev-master`
chmod 755 ./tests/ci/vm.sh
./tests/ci/vm.sh build
./tests/ci/vm.sh start
- # @todo this should not be necessary any more, as `start` waits for the app to be set up
- sleep 30
- # echo the logs of the bootstrap of the container, as there might be useful info
- ./tests/ci/vm.sh logs
+ # this should not be necessary any more, as `start` waits for the app to be set up
+ #sleep 30
./tests/ci/vm.sh runtests
+ # NB: we do not stop the container, nor clean up the current folder, as we rely on each matrix case
+ # being executed in its own runner instance
+
+ - name: failure troubleshooting
+ if: ${{ failure() }}
+ run: |
+ docker --version
+ docker ps
+ docker ps -a
+ ./tests/ci/vm.sh top
+ #./tests/ci/vm.sh exec env
+ ./tests/ci/vm.sh logs
curl_setopt($ch, CURLOPT_VERBOSE, 1);
}
$page = curl_exec($ch);
+ $info = curl_getinfo($ch);
curl_close($ch);
- $this->assertNotFalse($page);
+ $this->assertNotFalse($page, 'Curl request should not fail. Url: ' . @$info['url'] . ', Http code: ' . @$info['http_code']);
if (!$emptyPageOk) {
- $this->assertNotEquals('', $page);
+ $this->assertNotEquals('', $page, 'Retrieved web page should not be empty');
}
- $this->assertStringNotContainsStringIgnoringCase('Fatal error', $page);
- $this->assertStringNotContainsStringIgnoringCase('Notice:', $page);
+ $this->assertStringNotContainsStringIgnoringCase('Fatal error', $page, 'Retrieved web page should not contain a fatal error string');
+ $this->assertStringNotContainsStringIgnoringCase('Notice:', $page, 'Retrieved web page should not contain a notice string');
return $page;
}
echo "[$(date)] Stopping FPM"
service php-fpm stop
+ if [ -f "${TESTS_ROOT_DIR}/tests/ci/var/bootstrap_ok" ]; then
+ rm "${TESTS_ROOT_DIR}/tests/ci/var/bootstrap_ok"
+ fi
+
echo "[$(date)] Exiting"
exit
}
echo "[$(date)] Fixing filesystem permissions..."
-ORIGPASSWD=$(cat /etc/passwd | grep "^${USERNAME}:")
-ORIG_UID=$(echo "$ORIGPASSWD" | cut -f3 -d:)
-ORIG_GID=$(echo "$ORIGPASSWD" | cut -f4 -d:)
-CONTAINER_USER_HOME=$(echo "$ORIGPASSWD" | cut -f6 -d:)
-CONTAINER_USER_UID=${CONTAINER_USER_UID:=$ORIG_UID}
-CONTAINER_USER_GID=${CONTAINER_USER_GID:=$ORIG_GID}
+ORIGPASSWD="$(grep "^${USERNAME}:" /etc/passwd)"
+ORIG_UID="$(echo "$ORIGPASSWD" | cut -f3 -d:)"
+ORIG_GID="$(echo "$ORIGPASSWD" | cut -f4 -d:)"
+CONTAINER_USER_HOME="$(echo "$ORIGPASSWD" | cut -f6 -d:)"
+CONTAINER_USER_UID="${CONTAINER_USER_UID:=$ORIG_UID}"
+CONTAINER_USER_GID="${CONTAINER_USER_GID:=$ORIG_GID}"
-if [ "$CONTAINER_USER_UID" != "$ORIG_UID" -o "$CONTAINER_USER_GID" != "$ORIG_GID" ]; then
+if [ "$CONTAINER_USER_UID" != "$ORIG_UID" ] || [ "$CONTAINER_USER_GID" != "$ORIG_GID" ]; then
groupmod -g "$CONTAINER_USER_GID" "${USERNAME}"
usermod -u "$CONTAINER_USER_UID" -g "$CONTAINER_USER_GID" "${USERNAME}"
fi
-if [ "$(stat -c '%u' "${CONTAINER_USER_HOME}")" != "${CONTAINER_USER_UID}" -o "$(stat -c '%g' "${CONTAINER_USER_HOME}")" != "${CONTAINER_USER_GID}" ]; then
+if [ "$(stat -c '%u' "${CONTAINER_USER_HOME}")" != "${CONTAINER_USER_UID}" ] || [ "$(stat -c '%g' "${CONTAINER_USER_HOME}")" != "${CONTAINER_USER_GID}" ]; then
chown "${CONTAINER_USER_UID}":"${CONTAINER_USER_GID}" "${CONTAINER_USER_HOME}"
chown -R "${CONTAINER_USER_UID}":"${CONTAINER_USER_GID}" "${CONTAINER_USER_HOME}"/.*
if [ -d /usr/local/php ]; then
sed -e "s?^listen.owner =.*?listen.owner = ${USERNAME}?g" --in-place "${FPMCONF}"
sed -e "s?^listen.group =.*?listen.group = ${USERNAME}?g" --in-place "${FPMCONF}"
-echo "[$(date)] Running Composer..."
+if [ -f "${TESTS_ROOT_DIR}/composer.json" ]; then
+ echo "[$(date)] Running Composer..."
-# @todo if there is a composer.lock file present, there are chances it might be a leftover from when running the
-# container using a different php version. We should then back it up / do some symlink magic to make sure that
-# it matches the current php version and a hash of composer.json...
-su "${USERNAME}" -c "cd ${TESTS_ROOT_DIR} && composer install"
+ # @todo if there is a composer.lock file present, there are chances it might be a leftover from when running the
+ # container using a different php version. We should then back it up / do some symlink magic to make sure that
+ # it matches the current php version and a hash of composer.json...
+ su "${USERNAME}" -c "cd ${TESTS_ROOT_DIR} && composer install"
+else
+ # @todo should we exit?
+ echo "Missing file '${TESTS_ROOT_DIR}/composer.json' - was the container started without the correct mount?" >&2
+fi
trap clean_up TERM
echo "Installing base software packages..."
+# @todo make updating of preinstalled sw optional, so that we can have faster builds as part of CI
+
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y \
CONTAINER_USER=docker
CONTAINER_WORKSPACE_DIR="/home/${CONTAINER_USER}/workspace"
ROOT_DIR="$(dirname -- "$(dirname -- "$(dirname -- "$(readlink -f "$0")")")")"
+# @todo (low priority) allow passing in a custom prefix for image name, container name
IMAGE_NAME=phpxmlrpc:${UBUNTU_VERSION}-${PHP_VERSION}
CONTAINER_NAME=phpxmlrpc_${UBUNTU_VERSION}_${PHP_VERSION}
docker run -d \
-p 80:80 -p 443:443 -p 8080:8080 \
--name "${CONTAINER_NAME}" \
- --env CONTAINER_USER_UID=$(id -u) --env CONTAINER_USER_GID=$(id -g) \
- --env TESTS_ROOT_DIR=${CONTAINER_WORKSPACE_DIR} \
+ --env "CONTAINER_USER_UID=$(id -u)" --env "CONTAINER_USER_GID=$(id -g)" \
+ --env "TESTS_ROOT_DIR=${CONTAINER_WORKSPACE_DIR}" \
--env HTTPSERVER=localhost \
--env HTTPURI=/tests/index.php?demo=server/server.php \
--env HTTPSSERVER=localhost \