Skip to content

Commit dab6b3b

Browse files
committed
support newer 8.3+, minor fixes
1 parent 36b0f05 commit dab6b3b

33 files changed

+259
-227
lines changed

.github/workflows/phpunit.yml

Lines changed: 14 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,20 @@ on:
1919
env:
2020
ALL_DRIVERS: "gd gmagick imagick"
2121
IMAGINE_TEST_WEBSERVERURL: http://localhost:8013
22-
# Uncomment the following line to save test files as artifacts
23-
#IMAGINE_TEST_KEEP_TEMPFILES: yes
24-
22+
2523
jobs:
26-
ubuntu:
24+
test:
2725
name: PHP ${{ matrix.php-version }} - ${{ matrix.extensions }} (Ubuntu)
2826
runs-on: ubuntu-latest
2927
strategy:
3028
fail-fast: false
3129
matrix:
3230
php-version:
33-
- "5.3"
34-
- "5.4"
31+
- "8.3"
32+
- "8.4"
3533
extensions:
3634
- gd,imagick
35+
- gd,gmagick
3736
steps:
3837
- name: Setup PHP
3938
uses: shivammathur/setup-php@v2
@@ -42,6 +41,7 @@ jobs:
4241
extensions: exif,${{ matrix.extensions }}
4342
tools: composer:v2
4443
coverage: none
44+
4545
- name: Inspect environment
4646
id: inspect
4747
run: |
@@ -53,128 +53,27 @@ jobs:
5353
fi
5454
echo ''
5555
done
56-
echo "::set-output name=excluded-groups::$EXCLUDED_GROUPS"
57-
- name: Checkout
58-
uses: actions/checkout@v2
59-
- name: Install composer dependencies
60-
run: composer update --ansi --no-interaction
61-
- name: Start test web server
62-
uses: Eun/http-server-action@v1
63-
with:
64-
directory: ${{ github.workspace }}/tests
65-
port: 8013
66-
- name: PHPUnit
67-
run: composer run test --ansi --no-interaction -- --exclude-group "${{ steps.inspect.outputs.excluded-groups }}" --stop-on-error --stop-on-failure
68-
- name: Save tests temporary files
69-
if: always() && env.IMAGINE_TEST_KEEP_TEMPFILES == 'yes'
70-
uses: actions/upload-artifact@v2
71-
with:
72-
name: ubuntu-${{ matrix.php-version }}-${{ matrix.extensions }}
73-
path: tests/tmp/
74-
retention-days: 1
75-
76-
windows:
77-
name: PHP ${{ matrix.php-version }} - ${{ matrix.extensions }} (Windows)
78-
runs-on: windows-latest
79-
strategy:
80-
fail-fast: false
81-
matrix:
82-
php-version:
83-
- "5.6"
84-
- "7.4"
85-
extensions:
86-
- gd,imagick
87-
steps:
88-
- name: Setup PHP
89-
uses: shivammathur/setup-php@v2
90-
with:
91-
php-version: ${{ matrix.php-version }}
92-
extensions: exif,${{ matrix.extensions }}
93-
tools: composer:v2
94-
coverage: none
95-
- name: Inspect environment
96-
id: inspect
97-
run: |
98-
$EXCLUDED_GROUPS='always-skipped'
99-
foreach ($DRIVER in $Env:ALL_DRIVERS.split()) {
100-
Write-Output "### CHECKING $DRIVER"
101-
php --ri $DRIVER
102-
if ($LASTEXITCODE -ne 0) {
103-
$EXCLUDED_GROUPS="$EXCLUDED_GROUPS,$DRIVER"
104-
$Global:LASTEXITCODE = 0
105-
}
106-
Write-Output ''
107-
}
108-
Write-Output "::set-output name=excluded-groups::$EXCLUDED_GROUPS"
56+
echo "excluded-groups=$EXCLUDED_GROUPS" >> $GITHUB_OUTPUT
10957
11058
- name: Checkout
111-
uses: actions/checkout@v2
59+
uses: actions/checkout@v4
60+
11261
- name: Install composer dependencies
11362
run: composer update --ansi --no-interaction
63+
11464
- name: Start test web server
11565
uses: Eun/http-server-action@v1
11666
with:
11767
directory: ${{ github.workspace }}/tests
11868
port: 8013
119-
- name: PHPUnit
120-
run: composer run test --ansi --no-interaction -- --exclude-group "${{ steps.inspect.outputs.excluded-groups }}"
121-
- name: Save tests temporary files
122-
if: always() && env.IMAGINE_TEST_KEEP_TEMPFILES == 'yes'
123-
uses: actions/upload-artifact@v2
124-
with:
125-
name: windows-${{ matrix.php-version }}-${{ matrix.extensions }}
126-
path: tests/tmp/
127-
retention-days: 1
12869

129-
docker:
130-
name: PHP ${{ matrix.php-version }} - ${{ matrix.image-suffix }} (Docker)
131-
runs-on: ubuntu-latest
132-
strategy:
133-
fail-fast: false
134-
matrix:
135-
php-version:
136-
- "5.5"
137-
- "5.6"
138-
- "7.0"
139-
- "7.1"
140-
- "7.2"
141-
- "7.3"
142-
- "7.4"
143-
- "8.0"
144-
- "8.1"
145-
image-suffix:
146-
- gd-gmagick
147-
- gd-imagick
148-
container: ghcr.io/php-imagine/test:${{ matrix.php-version }}-${{ matrix.image-suffix }}
149-
steps:
150-
- name: Inspect environment
151-
id: inspect
152-
run: |
153-
EXCLUDED_GROUPS=always-skipped
154-
for DRIVER in $ALL_DRIVERS; do
155-
echo "### CHECKING $DRIVER"
156-
if ! php --ri $DRIVER; then
157-
EXCLUDED_GROUPS="$EXCLUDED_GROUPS,$DRIVER"
158-
fi
159-
echo ''
160-
done
161-
echo "::set-output name=excluded-groups::$EXCLUDED_GROUPS"
162-
- name: Checkout
163-
uses: actions/checkout@v2
164-
- name: Install composer dependencies
165-
run: composer update --ansi --no-interaction
166-
- name: Start test web server
167-
id: start-webserver
168-
run: |
169-
cd ./tests
170-
php -n -S 0.0.0.0:8013 &
171-
cd - >/dev/null
17270
- name: PHPUnit
173-
run: composer run test --ansi --no-interaction -- --exclude-group "${{ steps.inspect.outputs.excluded-groups }}"
71+
run: composer run test --ansi --no-interaction -- --exclude-group "${{ steps.inspect.outputs.excluded-groups }}" --stop-on-error --stop-on-failure
72+
17473
- name: Save tests temporary files
17574
if: always() && env.IMAGINE_TEST_KEEP_TEMPFILES == 'yes'
176-
uses: actions/upload-artifact@v2
75+
uses: actions/upload-artifact@v4
17776
with:
178-
name: docker-${{ matrix.php-version }}-${{ matrix.image-suffix }}
77+
name: ubuntu-${{ matrix.php-version }}-${{ matrix.extensions }}
17978
path: tests/tmp/
18079
retention-days: 1

.php-cs-fixer.dist.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/*
34
* This document has been generated with
45
* https://mlocati.github.io/php-cs-fixer-configurator/#version:3.1.0|configurator

Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
ARG PHP_VERSION=8.3
2+
FROM php:${PHP_VERSION}-cli
3+
4+
ARG DEBIAN_FRONTEND=noninteractive
5+
ARG IMAGE_DRIVER=imagick
6+
7+
RUN apt-get update && apt-get install -y --no-install-recommends \
8+
libpng-dev \
9+
libjpeg-dev \
10+
libfreetype6-dev \
11+
libwebp-dev \
12+
libmagickwand-dev \
13+
libgraphicsmagick1-dev \
14+
imagemagick \
15+
git \
16+
unzip \
17+
&& rm -rf /var/lib/apt/lists/*
18+
19+
RUN docker-php-ext-configure gd \
20+
--with-freetype \
21+
--with-jpeg \
22+
--with-webp \
23+
&& docker-php-ext-install -j$(nproc) gd exif
24+
25+
RUN if [ "$IMAGE_DRIVER" = "imagick" ]; then \
26+
pecl install imagick && docker-php-ext-enable imagick; \
27+
elif [ "$IMAGE_DRIVER" = "gmagick" ]; then \
28+
pecl install gmagick-2.0.6RC1 && docker-php-ext-enable gmagick; \
29+
fi
30+
31+
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
32+
33+
WORKDIR /app

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
}
1818
],
1919
"require": {
20-
"php": ">=5.3.2"
20+
"php": ">=8.3.0"
2121
},
2222
"require-dev": {
23-
"phpunit/phpunit": "^4.8 || ^5.7 || ^6.5 || ^7.5 || ^8.4 || ^9.3"
23+
"phpunit/phpunit": "^9.6"
2424
},
2525
"suggest": {
2626
"ext-exif": "to read EXIF metadata",
@@ -56,6 +56,6 @@
5656
]
5757
},
5858
"scripts": {
59-
"test": "phpunit --verbose"
59+
"test": "phpunit"
6060
}
6161
}

docker-compose.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
services:
2+
php83-imagick:
3+
build:
4+
context: .
5+
args:
6+
PHP_VERSION: "8.3"
7+
IMAGE_DRIVER: "imagick"
8+
volumes:
9+
- .:/app
10+
working_dir: /app
11+
12+
php83-gmagick:
13+
build:
14+
context: .
15+
args:
16+
PHP_VERSION: "8.3"
17+
IMAGE_DRIVER: "gmagick"
18+
volumes:
19+
- .:/app
20+
working_dir: /app
21+
22+
php84-imagick:
23+
build:
24+
context: .
25+
args:
26+
PHP_VERSION: "8.4"
27+
IMAGE_DRIVER: "imagick"
28+
volumes:
29+
- .:/app
30+
working_dir: /app
31+
32+
php84-gmagick:
33+
build:
34+
context: .
35+
args:
36+
PHP_VERSION: "8.4"
37+
IMAGE_DRIVER: "gmagick"
38+
volumes:
39+
- .:/app
40+
working_dir: /app
41+
42+
php85-imagick:
43+
build:
44+
context: .
45+
args:
46+
PHP_VERSION: "8.5"
47+
IMAGE_DRIVER: "imagick"
48+
volumes:
49+
- .:/app
50+
working_dir: /app
51+
52+
# Note: Gmagick 2.0.6RC1 does not compile on PHP 8.5
53+
# php85-gmagick is intentionally omitted

phpunit.xml.dist

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,24 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
3-
<phpunit backupGlobals="false"
4-
backupStaticAttributes="false"
5-
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
9-
processIsolation="false"
10-
stopOnFailure="false"
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
114
bootstrap="tests/bootstrap.php"
12-
>
13-
<php>
14-
<ini name="error_reporting" value="-1" />
15-
</php>
16-
<testsuites>
17-
<testsuite name="Imagine Test Suite">
18-
<directory>./tests/tests/</directory>
19-
</testsuite>
20-
</testsuites>
21-
22-
<filter>
23-
<whitelist>
24-
<directory>./src/</directory>
25-
<exclude>
26-
<directory>./tests/fixtures</directory>
27-
<directory>./tests/tmp</directory>
28-
</exclude>
29-
</whitelist>
30-
</filter>
5+
colors="true"
6+
stopOnFailure="false">
7+
<coverage>
8+
<include>
9+
<directory>./src/</directory>
10+
</include>
11+
<exclude>
12+
<directory>./tests/fixtures</directory>
13+
<directory>./tests/tmp</directory>
14+
</exclude>
15+
</coverage>
16+
<php>
17+
<ini name="error_reporting" value="-1"/>
18+
</php>
19+
<testsuites>
20+
<testsuite name="Imagine Test Suite">
21+
<directory>./tests/tests/</directory>
22+
</testsuite>
23+
</testsuites>
3124
</phpunit>

run-tests.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash
2+
3+
LOG_DIR="/tmp"
4+
5+
# Default test matrix
6+
# Note: gmagick doesn't compile on PHP 8.5, so it's excluded
7+
DEFAULT_SERVICES="php83-imagick php83-gmagick php84-imagick php84-gmagick php85-imagick"
8+
SERVICES="${1:-$DEFAULT_SERVICES}"
9+
10+
echo "=== Imagine PHP Compatibility Tests ===" | tee "${LOG_DIR}/imagine-tests.log"
11+
echo "Services: ${SERVICES}" | tee -a "${LOG_DIR}/imagine-tests.log"
12+
echo "" | tee -a "${LOG_DIR}/imagine-tests.log"
13+
14+
PASSED=0
15+
FAILED=0
16+
RESULTS=""
17+
18+
for SERVICE in ${SERVICES}; do
19+
LOG_FILE="${LOG_DIR}/imagine-${SERVICE}.log"
20+
echo "=== Testing ${SERVICE} ===" | tee -a "${LOG_DIR}/imagine-tests.log"
21+
22+
# Build the image first
23+
docker-compose build "${SERVICE}" 2>&1 | tee "${LOG_FILE}.build"
24+
if [ ${PIPESTATUS[0]} -ne 0 ]; then
25+
RESULTS="${RESULTS}\n${SERVICE}: BUILD FAILED"
26+
echo "${SERVICE}: BUILD FAILED" | tee -a "${LOG_DIR}/imagine-tests.log"
27+
FAILED=$((FAILED + 1))
28+
echo "" | tee -a "${LOG_DIR}/imagine-tests.log"
29+
continue
30+
fi
31+
32+
# Run tests
33+
docker-compose run --rm "${SERVICE}" sh -c \
34+
"php -v && composer install --quiet && composer run test -- --exclude-group always-skipped" 2>&1 | tee "${LOG_FILE}"
35+
if [ ${PIPESTATUS[0]} -eq 0 ]; then
36+
RESULTS="${RESULTS}\n${SERVICE}: PASSED"
37+
echo "${SERVICE}: PASSED" | tee -a "${LOG_DIR}/imagine-tests.log"
38+
PASSED=$((PASSED + 1))
39+
else
40+
RESULTS="${RESULTS}\n${SERVICE}: FAILED"
41+
echo "${SERVICE}: FAILED" | tee -a "${LOG_DIR}/imagine-tests.log"
42+
FAILED=$((FAILED + 1))
43+
fi
44+
echo "" | tee -a "${LOG_DIR}/imagine-tests.log"
45+
done
46+
47+
echo "=== Summary ===" | tee -a "${LOG_DIR}/imagine-tests.log"
48+
echo -e "${RESULTS}" | tee -a "${LOG_DIR}/imagine-tests.log"
49+
echo "" | tee -a "${LOG_DIR}/imagine-tests.log"
50+
echo "Passed: ${PASSED}, Failed: ${FAILED}" | tee -a "${LOG_DIR}/imagine-tests.log"
51+
echo "=== Done ===" | tee -a "${LOG_DIR}/imagine-tests.log"
52+
echo "Logs available at: ${LOG_DIR}/imagine-*.log"
53+
54+
# Exit with failure if any tests failed
55+
[ ${FAILED} -eq 0 ]

0 commit comments

Comments
 (0)