Skip to content

Commit

Permalink
Allow changing the PHP version for CI tests
Browse files Browse the repository at this point in the history
Both useful for the integration & unit tests.

(cherry picked from commit 765291a)
  • Loading branch information
vmcj committed Dec 9, 2024
1 parent 683dfc8 commit d4061a6
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 24 deletions.
26 changes: 2 additions & 24 deletions .github/jobs/baseinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,11 @@ MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-root}

set -eux

section_start "Update packages"
sudo apt update
section_end

section_start "Install needed packages"
sudo apt install -y acl zip unzip nginx php php-fpm php-gd \
php-cli php-intl php-mbstring php-mysql php-curl php-json \
php-xml php-zip ntp make sudo debootstrap \
libcgroup-dev lsof php-cli php-curl php-json php-xml \
php-zip procps gcc g++ default-jre-headless \
default-jdk-headless ghc fp-compiler autoconf automake bats \
python3-sphinx python3-sphinx-rtd-theme rst2pdf fontconfig \
python3-yaml latexmk curl
section_end

if [ -z "$phpversion" ]; then
phpversion=$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION."\n";')
PHPVERSION=$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION."\n";')
fi

show_phpinfo "$phpversion"

section_start "Install composer"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
HASH="$(wget -q -O - https://composer.github.io/installer.sig)"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
section_end
show_phpinfo "$PHPVERSION"

section_start "Run composer"
export APP_ENV="dev"
Expand Down
58 changes: 58 additions & 0 deletions .github/jobs/ci_settings.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/sh

# Store artifacts/logs
export ARTIFACTS="/tmp/artifacts"
mkdir -p "$ARTIFACTS"

# Functions to annotate the Github actions logs
trace_on () {
set -x
}
trace_off () {
{
set +x
} 2>/dev/null
}

section_start_internal () {
echo "::group::$1"
trace_on
}

section_end_internal () {
echo "::endgroup::"
trace_on
}

mysql_root () {
# shellcheck disable=SC2086
echo "$1" | mysql -uroot -proot ${2:-} | tee -a "$ARTIFACTS"/mysql.txt
}

mysql_user () {
# shellcheck disable=SC2086
echo "$1" | mysql -udomjudge -pdomjudge ${2:-} | tee -a "$ARTIFACTS"/mysql.txt
}

show_phpinfo() {
phpversion=$1
section_start "Show the new PHP info"
update-alternatives --set php /usr/bin/php"${phpversion}"
php -v
php -m
section_end
}

section_start () {
if [ "$#" -ne 1 ]; then
echo "Only 1 argument is needed for GHA, 2 was needed for GitLab."
exit 1
fi
trace_off
section_start_internal "$1"
}

section_end () {
trace_off
section_end_internal
}

0 comments on commit d4061a6

Please sign in to comment.