Skip to content

Commit c0daf6a

Browse files
committed
GitHub workflow: use Homebrew on Linux
... so that Linux runners can also use ImageMagick 7.
1 parent 1541956 commit c0daf6a

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

.github/workflows/tests.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,13 @@ jobs:
268268
path: ${{ steps.cache-dirs-windows.outputs.dir }}
269269
key: ${{ runner.os }}-scoop
270270

271+
- name: Set up Homebrew
272+
if: startsWith(runner.os, 'Linux')
273+
uses: Homebrew/actions/setup-homebrew@main
271274
- name: Install tools required by the regression tests (Linux)
272275
if: startsWith(runner.os, 'Linux')
273276
run: |
274-
sudo apt-get install mupdf-tools imagemagick
277+
brew install mupdf-tools imagemagick
275278
- name: Install tools required by the regression tests (macOS)
276279
if: startsWith(runner.os, 'macOS')
277280
run: |

tests_regression/helpers/diffpdf.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# usage: diffpdf.py file1.pdf file2.pdf
44

55
# requirements:
6-
# - ImageMagick (convert, compare or magick on Windows)
6+
# - ImageMagick 7
77
# - MuPDF's mutool >= 1.13.0
88
# or poppler's pdftoppm (known to work: 0.18.4, 0.41.0, 0.85.0, 0.89.0;
99
# known to fail: 0.42.0)
@@ -24,7 +24,6 @@
2424

2525
DIFF_DIR = 'pdfdiff'
2626
SHELL = sys.platform == 'win32'
27-
MAGICK = ['magick'] if sys.platform == 'win32' else []
2827

2928

3029
def diff_pdf(a_filename, b_filename, depth=None):
@@ -130,8 +129,8 @@ def diff_page(a_filename, b_filename, ab_page):
130129
page_number = a_page
131130
diff_jpg_path = os.path.join(DIFF_DIR, '{}.jpg'.format(page_number))
132131
# http://stackoverflow.com/a/28779982/438249
133-
diff = Popen(MAGICK + ['convert', '-', '(', '-clone', '0-1', '-compose',
134-
'darken', '-composite', ')',
132+
diff = Popen(['magick', 'convert', '-', '(', '-clone', '0-1', '-compose',
133+
'darken', '-composite', ')',
135134
'-channel', 'RGB', '-combine', diff_jpg_path],
136135
shell=SHELL, stdin=PIPE)
137136
a_page = pdf_page_to_ppm(a_filename, page_number, diff.stdin, gray=True)
@@ -141,15 +140,15 @@ def diff_page(a_filename, b_filename, ab_page):
141140
diff.stdin.close()
142141
if b_page.wait() != 0 or diff.wait() != 0:
143142
raise CommandFailed(page_number)
144-
grayscale = Popen(MAGICK + ['convert', diff_jpg_path, '-colorspace', 'HSL',
143+
grayscale = Popen(['magick', diff_jpg_path, '-colorspace', 'HSL',
145144
'-channel', 'g', '-separate', '+channel', '-format',
146145
'%[fx:mean]', 'info:'], shell=SHELL, stdout=PIPE)
147146
return Decimal(grayscale.stdout.read().decode('ascii'))
148147

149148

150149
def compare_page(a_filename, b_filename, a_page, b_page):
151150
"""Returns ``True`` if the pages at ``page_number`` are identical"""
152-
compare = Popen(MAGICK + ['compare', '-', '-metric', 'AE', 'null:'],
151+
compare = Popen(['magick', '-', '-metric', 'AE', 'null:'],
153152
shell=SHELL, stdin=PIPE, stdout=DEVNULL, stderr=DEVNULL)
154153
a_page = pdf_page_to_ppm(a_filename, a_page, compare.stdin)
155154
if a_page.wait() != 0:
@@ -187,7 +186,7 @@ def mutool(pdf_path, page_number, stdout, gray=False):
187186
raise SystemExit(2)
188187

189188

190-
if (MAGICK and not which(*MAGICK)) or not which('compare'):
189+
if not which('magick'):
191190
print("ImageMagick is required", file=sys.stderr)
192191
raise SystemExit(2)
193192

0 commit comments

Comments
 (0)