Skip to content

Commit d4061a6

Browse files
committed
Allow changing the PHP version for CI tests
Both useful for the integration & unit tests. (cherry picked from commit 765291a)
1 parent 683dfc8 commit d4061a6

File tree

2 files changed

+60
-24
lines changed

2 files changed

+60
-24
lines changed

.github/jobs/baseinstall.sh

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,11 @@ MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-root}
3030

3131
set -eux
3232

33-
section_start "Update packages"
34-
sudo apt update
35-
section_end
36-
37-
section_start "Install needed packages"
38-
sudo apt install -y acl zip unzip nginx php php-fpm php-gd \
39-
php-cli php-intl php-mbstring php-mysql php-curl php-json \
40-
php-xml php-zip ntp make sudo debootstrap \
41-
libcgroup-dev lsof php-cli php-curl php-json php-xml \
42-
php-zip procps gcc g++ default-jre-headless \
43-
default-jdk-headless ghc fp-compiler autoconf automake bats \
44-
python3-sphinx python3-sphinx-rtd-theme rst2pdf fontconfig \
45-
python3-yaml latexmk curl
46-
section_end
47-
4833
if [ -z "$phpversion" ]; then
49-
phpversion=$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION."\n";')
34+
PHPVERSION=$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION."\n";')
5035
fi
5136

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

6139
section_start "Run composer"
6240
export APP_ENV="dev"

.github/jobs/ci_settings.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/sh
2+
3+
# Store artifacts/logs
4+
export ARTIFACTS="/tmp/artifacts"
5+
mkdir -p "$ARTIFACTS"
6+
7+
# Functions to annotate the Github actions logs
8+
trace_on () {
9+
set -x
10+
}
11+
trace_off () {
12+
{
13+
set +x
14+
} 2>/dev/null
15+
}
16+
17+
section_start_internal () {
18+
echo "::group::$1"
19+
trace_on
20+
}
21+
22+
section_end_internal () {
23+
echo "::endgroup::"
24+
trace_on
25+
}
26+
27+
mysql_root () {
28+
# shellcheck disable=SC2086
29+
echo "$1" | mysql -uroot -proot ${2:-} | tee -a "$ARTIFACTS"/mysql.txt
30+
}
31+
32+
mysql_user () {
33+
# shellcheck disable=SC2086
34+
echo "$1" | mysql -udomjudge -pdomjudge ${2:-} | tee -a "$ARTIFACTS"/mysql.txt
35+
}
36+
37+
show_phpinfo() {
38+
phpversion=$1
39+
section_start "Show the new PHP info"
40+
update-alternatives --set php /usr/bin/php"${phpversion}"
41+
php -v
42+
php -m
43+
section_end
44+
}
45+
46+
section_start () {
47+
if [ "$#" -ne 1 ]; then
48+
echo "Only 1 argument is needed for GHA, 2 was needed for GitLab."
49+
exit 1
50+
fi
51+
trace_off
52+
section_start_internal "$1"
53+
}
54+
55+
section_end () {
56+
trace_off
57+
section_end_internal
58+
}

0 commit comments

Comments
 (0)