Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion .github/workflows/phpunit-sqlite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,23 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set up dependencies
- name: Enable HEIC support in ImageMagick
run: |
# The HEIC preview tests need ImageMagick to actually decode HEIC files.
# GitHub-hosted runners register the HEIC coder (so the tests are not
# skipped) but decoding fails because the libheif delegate is missing
# and/or the coder is blocked by ImageMagick's security policy. Install
# the delegate and allow the HEIC/HEIF/AVIF coders so decoding succeeds.
sudo apt-get update
sudo apt-get install -y --no-install-recommends libheif1 libheif-dev
for policy in /etc/ImageMagick-{6,7}/policy.xml; do
if [ -f "$policy" ]; then
sudo sed -i -E 's/rights="none" pattern="(HEIC|HEIF|AVIF)"/rights="read|write" pattern="\1"/g' "$policy"
fi
done

- name: Set up dependencies
run: |
sudo apt-get install -y ghostscript
composer i

Expand Down
29 changes: 21 additions & 8 deletions tests/lib/Preview/HEICTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,27 @@ class HEICTest extends Provider {
protected function setUp(): void {
if (!in_array('HEIC', \Imagick::queryFormats('HEI*'))) {
$this->markTestSkipped('ImageMagick is not HEIC aware. Skipping tests');
} else {
parent::setUp();

$fileName = 'testimage.heic';
$this->imgPath = $this->prepareTestFile($fileName, \OC::$SERVERROOT . '/tests/data/' . $fileName);
$this->width = 1680;
$this->height = 1050;
$this->provider = new HEIC;
}

$fileName = 'testimage.heic';
$sourcePath = \OC::$SERVERROOT . '/tests/data/' . $fileName;

// queryFormats() only reports that the HEIC coder is registered, not that
// ImageMagick can actually decode a HEIC file: the libheif delegate may be
// missing or the coder may be disabled by ImageMagick's policy.xml. In that
// case decoding throws, the provider returns null and the tests fail instead
// of being skipped. Verify a real decode before running the tests.
try {
(new \Imagick())->readImage($sourcePath . '[0]');
} catch (\ImagickException $e) {
$this->markTestSkipped('ImageMagick cannot decode HEIC in this environment: ' . $e->getMessage() . '. Skipping tests');
}

parent::setUp();

$this->imgPath = $this->prepareTestFile($fileName, $sourcePath);
$this->width = 1680;
$this->height = 1050;
$this->provider = new HEIC;
}
}
Loading