Skip to content

Commit 6bef95a

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

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

Diff for: 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:

Diff for: check-diffs.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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', 'https://github.com/matplotlib/cheatsheets.git',
16+
'gh-pages:upstream-gh-pages'], check=True)
17+
subprocess.run(['git', 'worktree', 'add', gh_pages, 'upstream-gh-pages'],
18+
check=True)
19+
20+
for original in gh_pages.glob('*.png'):
21+
subprocess.run(['compare',
22+
original,
23+
ROOT_DIR / 'docs/_build/html' / original.name,
24+
ROOT_DIR / 'docs/_build/html' / f'{original.stem}-diff.png'],
25+
check=True)
26+
27+
subprocess.run(['git', 'worktree', 'remove', gh_pages])

0 commit comments

Comments
 (0)