Skip to content

Commit

Permalink
Upgrade to PHP 8.3 and PHPUnit 10 (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
mk-mxp authored Apr 26, 2024
1 parent 51476e1 commit 39c158f
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 141 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Ignore PHPUnit bin download and run cache artifact
bin/phpunit-9.phar
bin/phpunit-*
.phpunit*.cache

# Ignore run artifacts
Expand All @@ -10,4 +10,4 @@ output.json
results.xml
results.json

*.scratch
*.scratch
17 changes: 9 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:8.2.7-cli-alpine3.18 AS build
FROM php:8.3.4-cli-alpine3.19 AS build

RUN apk update && \
apk add --no-cache ca-certificates curl jo zip unzip
Expand All @@ -7,22 +7,23 @@ WORKDIR /usr/local/bin

RUN curl -L -o install-php-extensions https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \
chmod +x install-php-extensions && \
install-php-extensions ds-1.4.0 intl
install-php-extensions ds-1.5.0 intl

RUN curl -L -o phpunit-9.phar https://phar.phpunit.de/phpunit-9.phar && \
chmod +x phpunit-9.phar
RUN curl -L -o phpunit-10.phar https://phar.phpunit.de/phpunit-10.phar && \
chmod +x phpunit-10.phar

WORKDIR /usr/local/bin/junit-handler/
COPY --from=composer:2.5.8 /usr/bin/composer /usr/local/bin/composer
COPY --from=composer:2.7.2 /usr/bin/composer /usr/local/bin/composer
COPY junit-handler/ .
# We need PHPUnit from junit-handler/ to run test-runner tests in CI / locally
RUN composer install --no-interaction
# composer warns about missing a "root version" to resolve dependencies. Fake to stop warning
RUN COMPOSER_ROOT_VERSION=1.0.0 composer install --no-interaction

FROM php:8.2.7-cli-alpine3.18 AS runtime
FROM php:8.3.4-cli-alpine3.19 AS runtime

COPY --from=build /usr/bin/jo /usr/bin/jo
COPY --from=build /usr/local/lib/php/extensions /usr/local/lib/php/extensions
COPY --from=build /usr/local/bin/phpunit-9.phar /opt/test-runner/bin/phpunit-9.phar
COPY --from=build /usr/local/bin/phpunit-10.phar /opt/test-runner/bin/phpunit-10.phar
COPY --from=build /usr/local/bin/junit-handler /opt/test-runner/junit-handler

# Use the default production configuration
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ It meets the complete spec for testing all exercises.

### Docker image

The website uses isolated docker images to run untrusted code in a sandbox.
The image provided by this repository consists of PHP 8.2.7 (PHPUnit 9/10).
The website uses isolated Docker images to run untrusted code in a sandbox.
The image provided by this repository consists of PHP 8.3.4 (PHPUnit 10).
All final assets are built into the image, because the image does not have network access once in use.

Includes PHP extensions: ds, intl
Expand Down
5 changes: 3 additions & 2 deletions bin/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

set -euo pipefail

PHPUNIT_BIN="./bin/phpunit-9.phar"
PHPUNIT_BIN="./bin/phpunit-10.phar"
XML_RESULTS='results.xml'
JSON_RESULTS='results.json'
# shellcheck disable=SC2034 # Modifies XDebug behaviour when invoking PHP
XDEBUG_MODE='off'

function main {
local output=""
Expand All @@ -25,7 +27,6 @@ function main {
output=$(eval "${PHPUNIT_BIN}" \
-d memory_limit=300M \
--log-junit "${output_dir%/}/${XML_RESULTS}" \
--verbose \
--no-configuration \
--do-not-cache-result \
"${test_files%%*( )}" 2>&1)
Expand Down
Loading

0 comments on commit 39c158f

Please sign in to comment.