From e0047f07f0fb6d8d1a950c39002c7231e04109cb Mon Sep 17 00:00:00 2001 From: Rasmus Schultz Date: Tue, 28 May 2024 09:36:57 +0200 Subject: [PATCH] build on multiple versions of PHP --- .github/workflows/ci.yml | 5 ++++- Dockerfile | 3 ++- test.sh | 8 +++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fc0e277..e46b1d9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,9 @@ on: [push, pull_request] jobs: test: runs-on: ubuntu-latest + strategy: + matrix: + php_version: [8.1, 8.2, 8.3] steps: - name: Checkout code @@ -14,4 +17,4 @@ jobs: run: sudo apt-get update && sudo apt-get install -y docker-compose - name: Run tests - run: ./test.sh + run: ./test.sh ${{ matrix.php_version }} diff --git a/Dockerfile b/Dockerfile index 396ea1a..ef2d682 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ # Dockerfile -FROM php:8.1-cli +ARG php_version=8.3 +FROM php:${php_version}-cli # Install dependencies RUN apt-get update && apt-get install -y \ diff --git a/test.sh b/test.sh index a4b0f72..d03216d 100755 --- a/test.sh +++ b/test.sh @@ -3,9 +3,11 @@ # Ensure the script exits on any error set -e -# Uncomment this while changing the Dockerfile -#docker compose down -#docker compose build +# If a PHP version is passed as an argument, rebuild with the new PHP version +if [ -n "$1" ]; then + docker compose down + docker compose build --build-arg php_version=$1 +fi # Start the Docker services if not already running docker compose up -d