Skip to content

Commit

Permalink
Add image diffs against previous build to CI results
Browse files Browse the repository at this point in the history
  • Loading branch information
QuLogic committed Mar 29, 2023
1 parent 3d7d3ff commit ae368f9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ check:
./check-num-pages.sh handout-beginner.pdf 1
./check-num-pages.sh handout-intermediate.pdf 1
./check-links.py cheatsheets.pdf
./check-diffs.py

.PHONY: docs
docs:
Expand Down
25 changes: 25 additions & 0 deletions check-diffs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python
import os
import subprocess
import sys
from pathlib import Path


ROOT_DIR = Path(__file__).parent

if os.environ.get('GITHUB_ACTION', '') == '':
print('Not running when not in GitHub Actions.')
sys.exit()

gh_pages = ROOT_DIR.parent / 'pages'
subprocess.run(['git', 'fetch', 'origin', 'gh-pages'], check=True)
subprocess.run(['git', 'worktree', 'add', gh_pages, 'gh-pages'], check=True)

for original in gh_pages.glob('*.png'):
subprocess.run(['compare',
original,
ROOT_DIR / 'docs/_build/html' / original.name,
ROOT_DIR / 'docs/_build/html' / f'{original.stem}-diff.png'],
check=True)

subprocess.run(['git', 'worktree', 'remove', gh_pages])

0 comments on commit ae368f9

Please sign in to comment.