Skip to content

Commit 8d6a118

Browse files
committed
Make some updates on CI and bootstrapping to use docker-based ImageMagick
1 parent 0e88856 commit 8d6a118

File tree

4 files changed

+10
-20
lines changed

4 files changed

+10
-20
lines changed

.github/workflows/php.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,10 @@ jobs:
1818
steps:
1919
- uses: actions/checkout@v2
2020

21-
- name: Install ImageMagick dependencies
21+
- name: Install ImageMagick
2222
run: |
2323
sudo apt-get update
2424
sudo apt-get upgrade -y libjpeg-dev libpng-dev libgif-dev make wget
25-
26-
- name: Install ImageMagick
27-
run: |
2825
wget https://www.imagemagick.org/download/ImageMagick.tar.gz
2926
tar xvzf ImageMagick.tar.gz
3027
cd ImageMagick-*
@@ -51,4 +48,6 @@ jobs:
5148

5249
- run: composer install
5350

54-
- run: vendor/bin/phpunit
51+
- run: |
52+
# export IMAGEMAGICK_PATH="docker run --rm --volume `pwd`:`pwd` --workdir=`pwd` --entrypoint="`pwd`/docker_entrypoint.sh" --user=$UID:$GID dpokidov/imagemagick:latest magick"
53+
vendor/bin/phpunit

Tests/bootstrap.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727

2828
// Check if ImageMagick is installed. Instead, we cannot run tests suite.
2929
$possibleDirectories = [
30+
getenv('IMAGEMAGICK_PATH') ?: null,
3031
null,// In the PATH variable, default behavior
3132
'/usr/bin/magick',
3233
'/usr/local/bin/magick',
33-
getenv('IMAGEMAGICK_PATH') ?: null, // Fall back again to PATH
3434
];
3535
foreach ($possibleDirectories as $path) {
36-
echo 'Check "'.$path.'" binary'."\n";
36+
echo 'Check for ImageMagick with path "'.$path."\"\n";
3737
try {
3838
$path = Command::findMagickBinaryPath($path);
3939
exec($path.' -version', $o, $code);
@@ -42,6 +42,7 @@
4242
break;
4343
}
4444
} catch (MagickBinaryNotFoundException $e) {
45+
echo 'Did not find ImageMagick with path "'.$path.'". '.$e->getMessage()."\n";
4546
}
4647
}
4748

@@ -53,5 +54,5 @@
5354
);
5455
}
5556

56-
echo 'Analyzed ImageMagick directory: '.IMAGEMAGICK_DIR."\n";
57+
echo 'ImageMagick resolved to: "'.IMAGEMAGICK_DIR."\"\n";
5758
system(IMAGEMAGICK_DIR.' -version');

src/Command.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function __construct(?string $magickBinaryPath = '')
8080
{
8181
$magickBinaryPath = self::findMagickBinaryPath($magickBinaryPath);
8282

83-
$process = new Process([$magickBinaryPath, '-version']);
83+
$process = Process::fromShellCommandline($magickBinaryPath.' -version');
8484

8585
try {
8686
$code = $process->run();
@@ -115,16 +115,6 @@ public static function findMagickBinaryPath(?string $magickBinaryPath): string
115115
throw new MagickBinaryNotFoundException((string) $magickBinaryPath);
116116
}
117117

118-
// Add a proper directory separator at the end if path is not empty.
119-
// If it's empty, then it's set in the global path.
120-
if (!\is_file($magickBinaryPath)) {
121-
throw new MagickBinaryNotFoundException($magickBinaryPath);
122-
}
123-
124-
if (!\is_executable($magickBinaryPath)) {
125-
throw new \InvalidArgumentException(\sprintf('The specified script (%s) is not executable.', $magickBinaryPath));
126-
}
127-
128118
return $magickBinaryPath;
129119
}
130120

src/MagickBinaryNotFoundException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class MagickBinaryNotFoundException extends Exception
2020
public function __construct(string $magickBinaryPath)
2121
{
2222
parent::__construct(\sprintf(
23-
'The specified path (%s) is not a file.'."\n".
23+
'The specified path ("%s") is not a file.'."\n".
2424
'You must set the "magickBinaryPath" parameter as the main "magick" binary installed by ImageMagick.',
2525
$magickBinaryPath
2626
));

0 commit comments

Comments
 (0)