Skip to content

Commit ae368f9

Browse files
committed
Add image diffs against previous build to CI results
1 parent 3d7d3ff commit ae368f9

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ check:
4242
./check-num-pages.sh handout-beginner.pdf 1
4343
./check-num-pages.sh handout-intermediate.pdf 1
4444
./check-links.py cheatsheets.pdf
45+
./check-diffs.py
4546

4647
.PHONY: docs
4748
docs:

check-diffs.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env python
2+
import os
3+
import subprocess
4+
import sys
5+
from pathlib import Path
6+
7+
8+
ROOT_DIR = Path(__file__).parent
9+
10+
if os.environ.get('GITHUB_ACTION', '') == '':
11+
print('Not running when not in GitHub Actions.')
12+
sys.exit()
13+
14+
gh_pages = ROOT_DIR.parent / 'pages'
15+
subprocess.run(['git', 'fetch', 'origin', 'gh-pages'], check=True)
16+
subprocess.run(['git', 'worktree', 'add', gh_pages, 'gh-pages'], check=True)
17+
18+
for original in gh_pages.glob('*.png'):
19+
subprocess.run(['compare',
20+
original,
21+
ROOT_DIR / 'docs/_build/html' / original.name,
22+
ROOT_DIR / 'docs/_build/html' / f'{original.stem}-diff.png'],
23+
check=True)
24+
25+
subprocess.run(['git', 'worktree', 'remove', gh_pages])

0 commit comments

Comments
 (0)