From 9e74cc9e26a573db018fc392f339fa821139346e Mon Sep 17 00:00:00 2001 From: Mathieu Dubois Date: Wed, 2 Oct 2024 23:31:12 +0200 Subject: [PATCH 1/6] Use autoload on tests They can be launched from the base dir with: php tests/png.php --- tests/canvas_body.php | 6 +++--- tests/gradients.php | 2 +- tests/imagemap.php | 2 +- tests/jpg.php | 4 ++-- tests/lineends.php | 2 +- tests/pdf.php | 4 ++-- tests/png.php | 4 ++-- tests/ps.php | 4 ++-- tests/svg.php | 4 ++-- tests/text.php | 2 +- 10 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/canvas_body.php b/tests/canvas_body.php index 1aee67d..2147baf 100644 --- a/tests/canvas_body.php +++ b/tests/canvas_body.php @@ -305,11 +305,11 @@ $canvas->addText(array('x' => 375, 'y' => 455, 'text' => 'Image')); -$canvas->image(array('x' => 445, 'y' => 455, 'filename' => './pear-icon.png', 'url' => 'http://pear.veggerby.dk/', 'target' => '_blank')); +$canvas->image(array('x' => 445, 'y' => 455, 'filename' => __DIR__ . '/pear-icon.png', 'url' => 'http://pear.veggerby.dk/', 'target' => '_blank')); -$canvas->image(array('x' => 445, 'y' => 495, 'filename' => './pear-icon.png', 'width' => 20, 'height' => 20)); +$canvas->image(array('x' => 445, 'y' => 495, 'filename' => __DIR__ . '/pear-icon.png', 'width' => 20, 'height' => 20)); -$canvas->image(array('x' => 445, 'y' => 523, 'filename' => './pear-icon.png', 'width' => 40, 'height' => 40)); +$canvas->image(array('x' => 445, 'y' => 523, 'filename' => __DIR__ . '/pear-icon.png', 'width' => 40, 'height' => 40)); //$canvas->show(); $type = basename($_SERVER['SCRIPT_NAME'], '.php'); diff --git a/tests/gradients.php b/tests/gradients.php index 93cd110..307047d 100644 --- a/tests/gradients.php +++ b/tests/gradients.php @@ -27,7 +27,7 @@ * @link http://pear.php.net/package/Image_Canvas */ -require_once 'Image/Canvas.php'; +require_once 'vendor/autoload.php'; $canvas =& Image_Canvas::factory( 'png', diff --git a/tests/imagemap.php b/tests/imagemap.php index 7e27efb..c3bb1e9 100644 --- a/tests/imagemap.php +++ b/tests/imagemap.php @@ -27,7 +27,7 @@ * @link http://pear.php.net/package/Image_Canvas */ -require_once 'Image/Canvas.php'; +require_once 'vendor/autoload.php'; $canvas =& Image_Canvas::factory( 'png', diff --git a/tests/jpg.php b/tests/jpg.php index a451b75..8dd1054 100644 --- a/tests/jpg.php +++ b/tests/jpg.php @@ -30,10 +30,10 @@ // SPECIFY HERE WHERE A TRUETYPE FONT CAN BE FOUND $testFont = 'c:/windows/fonts/Arial.ttf'; -require_once 'Image/Canvas.php'; +require_once 'vendor/autoload.php'; $canvas =& Image_Canvas::factory('jpg', array('width' => 600, 'height' => 600, 'quality' => 90)); -require_once './canvas_body.php'; +require_once __DIR__ . '/canvas_body.php'; ?> diff --git a/tests/lineends.php b/tests/lineends.php index ec4c25e..aa6d886 100644 --- a/tests/lineends.php +++ b/tests/lineends.php @@ -27,7 +27,7 @@ * @link http://pear.php.net/package/Image_Canvas */ -require_once 'Image/Canvas.php'; +require_once 'vendor/autoload.php'; $font = array('name' => 'Verdana', 'size' => 10); diff --git a/tests/pdf.php b/tests/pdf.php index aea0e8e..9e37d51 100644 --- a/tests/pdf.php +++ b/tests/pdf.php @@ -30,10 +30,10 @@ // SPECIFY HERE WHERE A TRUETYPE FONT CAN BE FOUND $testFont = 'c:/windows/fonts/Arial.ttf'; -require_once 'Image/Canvas.php'; +require_once 'vendor/autoload.php'; $canvas =& Image_Canvas::factory('pdf', array('page' => 'A4', 'align' => 'center', 'width' => 600, 'height' => 600)); -require_once './canvas_body.php'; +require_once __DIR__ . '/canvas_body.php'; ?> diff --git a/tests/png.php b/tests/png.php index 7c99b60..80f7da0 100644 --- a/tests/png.php +++ b/tests/png.php @@ -30,10 +30,10 @@ // SPECIFY HERE WHERE A TRUETYPE FONT CAN BE FOUND $testFont = 'c:/windows/fonts/Arial.ttf'; -require_once 'Image/Canvas.php'; +require_once 'vendor/autoload.php'; $canvas =& Image_Canvas::factory('png', array('width' => 600, 'height' => 600)); -require_once './canvas_body.php'; +require_once __DIR__ . '/canvas_body.php'; ?> diff --git a/tests/ps.php b/tests/ps.php index 08b1566..8226233 100644 --- a/tests/ps.php +++ b/tests/ps.php @@ -30,10 +30,10 @@ // SPECIFY HERE WHERE A TRUETYPE FONT CAN BE FOUND $testFont = 'c:/windows/fonts/Arial.ttf'; -require_once 'Image/Canvas.php'; +require_once 'vendor/autoload.php'; $canvas =& Image_Canvas::factory('ps', array('page' => 'A4', 'align' => 'center', 'width' => 600, 'height' => 600, 'filename'=>'testps.ps')); -require_once './canvas_body.php'; +require_once __DIR__ . '/canvas_body.php'; ?> diff --git a/tests/svg.php b/tests/svg.php index 162968f..b72bcec 100644 --- a/tests/svg.php +++ b/tests/svg.php @@ -30,10 +30,10 @@ // SPECIFY HERE WHERE A TRUETYPE FONT CAN BE FOUND $testFont = 'c:/windows/fonts/Arial.ttf'; -require_once 'Image/Canvas.php'; +require_once 'vendor/autoload.php'; $canvas =& Image_Canvas::factory('svg', array('width' => 600, 'height' => 600)); -require_once './canvas_body.php'; +require_once __DIR__ . '/canvas_body.php'; ?> diff --git a/tests/text.php b/tests/text.php index 61cf45a..608c951 100644 --- a/tests/text.php +++ b/tests/text.php @@ -27,7 +27,7 @@ * @link http://pear.php.net/package/Image_Canvas */ -require_once 'Image/Canvas.php'; +require_once 'vendor/autoload.php'; $canvas =& Image_Canvas::factory( 'png', From edae6bc1880ea42b1cbe7c0f42307762fbbc983e Mon Sep 17 00:00:00 2001 From: Mathieu Dubois Date: Wed, 2 Oct 2024 23:38:42 +0200 Subject: [PATCH 2/6] Remove PHPUnit from dev requirements as it's not required --- composer.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/composer.json b/composer.json index da1e4b1..563126f 100644 --- a/composer.json +++ b/composer.json @@ -25,8 +25,5 @@ "require": { "pear/pear_exception": "*", "pear/image_color": "*" - }, - "require-dev": { - "phpunit/phpunit": "*" } } From 0c8f32dd22ac93571d58f98c12dfc728bb11e306 Mon Sep 17 00:00:00 2001 From: Mathieu Dubois Date: Sat, 5 Oct 2024 00:52:08 +0200 Subject: [PATCH 3/6] Add GitHub actions --- .github/workflows/main.yaml | 65 +++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/main.yaml diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 0000000..ca964e1 --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,65 @@ +name: Main + +on: + workflow_dispatch: + push: + branches: + - main + - master + - release/** + pull_request: + branches: + - main + - master + - release/** + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + run: + runs-on: ${{ matrix.operating-system }} + strategy: + matrix: + operating-system: ['ubuntu-latest'] + php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4'] + steps: + - name: Get source code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + coverage: none + ini-values: post_max_size=256M, max_execution_time=180 + - run: sudo pear list + - run: sudo pear channel-update pear.php.net + - run: sudo pear upgrade --force pear/pear + - run: sudo pear list + - run: sudo pear install --force package.xml + - run: sudo pear list + - run: sudo pear package + - run: sudo pear package-validate + - run: sudo pear install --force *.tgz + - run: sudo pear list + # Prepare fonts (see https://askubuntu.com/a/25614) + - run: echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | sudo debconf-set-selections + - run: sudo apt install -y ttf-mscorefonts-installer + - run: sudo cp -rp /usr/share/fonts/truetype/msttcorefonts/verdana.ttf Image/Canvas/Fonts/ + - run: sudo cp -rp /usr/share/fonts/truetype/msttcorefonts/verdanab.ttf Image/Canvas/Fonts/ + - run: sudo cp -rp /usr/share/fonts/truetype/msttcorefonts/verdanai.ttf Image/Canvas/Fonts/ + - run: sudo cp -rp /usr/share/fonts/truetype/msttcorefonts/verdanaz.ttf Image/Canvas/Fonts/ + # Install pre-requisites and run test scripts + - run: composer install + - run: php tests/gradients.php > gradients.png + - run: php tests/imagemap.php > imagemap.html + - run: php tests/png.php + - run: php tests/jpg.php + # - run: php tests/ps.php + # - run:php tests/pdf.php + - run: php tests/svg.php + - run: php tests/text.php > text.png + - run: php tests/lineends.php > lineends.png From 6779459d98df0a5e4d1cf75f8dd0d2f99953b0cf Mon Sep 17 00:00:00 2001 From: Mathieu Dubois Date: Sat, 5 Oct 2024 02:21:48 +0200 Subject: [PATCH 4/6] Only download and extract Verdana font --- .github/workflows/main.yaml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index ca964e1..239847d 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -45,13 +45,11 @@ jobs: - run: sudo pear package-validate - run: sudo pear install --force *.tgz - run: sudo pear list - # Prepare fonts (see https://askubuntu.com/a/25614) - - run: echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | sudo debconf-set-selections - - run: sudo apt install -y ttf-mscorefonts-installer - - run: sudo cp -rp /usr/share/fonts/truetype/msttcorefonts/verdana.ttf Image/Canvas/Fonts/ - - run: sudo cp -rp /usr/share/fonts/truetype/msttcorefonts/verdanab.ttf Image/Canvas/Fonts/ - - run: sudo cp -rp /usr/share/fonts/truetype/msttcorefonts/verdanai.ttf Image/Canvas/Fonts/ - - run: sudo cp -rp /usr/share/fonts/truetype/msttcorefonts/verdanaz.ttf Image/Canvas/Fonts/ + # Download and install Verdana font (for some reason ttf-mscorefonts-installer doesn't work) + - run: sudo apt install cabextract + - run: curl -L -o verdan32.exe 'http://download.sourceforge.net/corefonts/verdan32.exe' + - run: cabextract -d Image/Canvas/Fonts/ verdan32.exe + - run: mv Image/Canvas/Fonts/Verdana.TTF Image/Canvas/Fonts/verdana.ttf # Install pre-requisites and run test scripts - run: composer install - run: php tests/gradients.php > gradients.png From a9af33226cc30c579ad1dc3a0e97fed31a1a02ba Mon Sep 17 00:00:00 2001 From: Mathieu Dubois Date: Sat, 5 Oct 2024 16:20:18 +0200 Subject: [PATCH 5/6] Group CI commands --- .github/workflows/main.yaml | 58 ++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 239847d..7905a61 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -35,29 +35,35 @@ jobs: php-version: ${{ matrix.php-versions }} coverage: none ini-values: post_max_size=256M, max_execution_time=180 - - run: sudo pear list - - run: sudo pear channel-update pear.php.net - - run: sudo pear upgrade --force pear/pear - - run: sudo pear list - - run: sudo pear install --force package.xml - - run: sudo pear list - - run: sudo pear package - - run: sudo pear package-validate - - run: sudo pear install --force *.tgz - - run: sudo pear list - # Download and install Verdana font (for some reason ttf-mscorefonts-installer doesn't work) - - run: sudo apt install cabextract - - run: curl -L -o verdan32.exe 'http://download.sourceforge.net/corefonts/verdan32.exe' - - run: cabextract -d Image/Canvas/Fonts/ verdan32.exe - - run: mv Image/Canvas/Fonts/Verdana.TTF Image/Canvas/Fonts/verdana.ttf - # Install pre-requisites and run test scripts - - run: composer install - - run: php tests/gradients.php > gradients.png - - run: php tests/imagemap.php > imagemap.html - - run: php tests/png.php - - run: php tests/jpg.php - # - run: php tests/ps.php - # - run:php tests/pdf.php - - run: php tests/svg.php - - run: php tests/text.php > text.png - - run: php tests/lineends.php > lineends.png + - name: Check package + run: | + sudo pear list + sudo pear channel-update pear.php.net + sudo pear upgrade --force pear/pear + sudo pear list + sudo pear install --force package.xml + sudo pear list + sudo pear package + sudo pear package-validate + sudo pear install --force *.tgz + sudo pear list + # For some reason ttf-mscorefonts-installer doesn't work + # so we only install Verdana + - name: Download and install Verdana font + run: | + sudo apt install cabextract + curl -L -o verdan32.exe 'http://download.sourceforge.net/corefonts/verdan32.exe' + cabextract -d Image/Canvas/Fonts/ verdan32.exe + mv Image/Canvas/Fonts/Verdana.TTF Image/Canvas/Fonts/verdana.ttf + - name: Install pre-requisites and run test scripts + run: | + composer install + php tests/gradients.php > gradients.png + php tests/imagemap.php > imagemap.html + php tests/png.php + php tests/jpg.php + # php tests/ps.php + # php tests/pdf.php + php tests/svg.php + php tests/text.php > text.png + php tests/lineends.php > lineends.png From e13aa6737a567b9b1adfe49d55554c991bcb0ce8 Mon Sep 17 00:00:00 2001 From: Mathieu Dubois Date: Sat, 5 Oct 2024 16:25:07 +0200 Subject: [PATCH 6/6] Exclude PHP 8 and above as the code is not compatible --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 563126f..8199897 100644 --- a/composer.json +++ b/composer.json @@ -23,6 +23,7 @@ }, "type": "library", "require": { + "php": ">=5.6, < 8.0", "pear/pear_exception": "*", "pear/image_color": "*" }