Skip to content

[ImgBot] Optimize images #5

[ImgBot] Optimize images

[ImgBot] Optimize images #5

name: Visual regression checks
on:
pull_request:
branches: [main, master, v1.0-dev]
paths:
- "_config.yml"
- "_data/**"
- "_bibliography/**"
- "_pages/**"
- "_posts/**"
- "_projects/**"
- "assets/**"
- "test/visual/**"
- ".github/workflows/visual-regression.yml"
- "package.json"
- "package-lock.json"
- "Gemfile"
- "Gemfile.lock"
push:
branches: [v1.0-dev]
paths:
- "_config.yml"
- "_data/**"
- "_bibliography/**"
- "_pages/**"
- "_posts/**"
- "_projects/**"
- "assets/**"
- "test/visual/**"
- ".github/workflows/visual-regression.yml"
- "package.json"
- "package-lock.json"
- "Gemfile"
- "Gemfile.lock"
jobs:
visual-regression:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout candidate πŸ›ŽοΈ
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Ruby πŸ’Ž
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.3.5"
bundler-cache: true
- name: Setup Node 🧰
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install JS deps πŸ“¦
run: npm ci
- name: Prepare baseline worktree (v0.16.3) 🧱
run: |
git worktree add ../al-folio-baseline v0.16.3
(cd ../al-folio-baseline && bundle install && npm ci)
- name: Install Jupyter + ImageMagick runtime deps 🧰
run: |
sudo apt-get update
sudo apt-get install -y imagemagick python3-pip
pip3 install --user jupyter nbconvert
- name: Install Playwright browser πŸ§ͺ
run: npx playwright install --with-deps chromium webkit
- name: Run visual parity checks πŸ‘€
env:
BASELINE_URL: http://127.0.0.1:4100
NO_WEBSERVER: "1"
run: |
set -euo pipefail
export PATH="$HOME/.local/bin:$PATH"
(cd ../al-folio-baseline && bundle exec jekyll serve --host 127.0.0.1 --port 4100 --baseurl /al-folio --quiet > /tmp/jekyll-baseline.log 2>&1) &
BASELINE_PID=$!
(bundle exec jekyll serve --host 127.0.0.1 --port 4000 --baseurl /al-folio --quiet > /tmp/jekyll-candidate.log 2>&1) &
CANDIDATE_PID=$!
cleanup() {
kill "$BASELINE_PID" "$CANDIDATE_PID" >/dev/null 2>&1 || true
}
trap cleanup EXIT
READY=0
for _ in {1..150}; do
if curl -fsS http://127.0.0.1:4000/al-folio/ >/dev/null && curl -fsS http://127.0.0.1:4100/al-folio/ >/dev/null; then
READY=1
break
fi
if ! kill -0 "$BASELINE_PID" >/dev/null 2>&1 || ! kill -0 "$CANDIDATE_PID" >/dev/null 2>&1; then
echo "Jekyll server exited before becoming ready."
echo "--- baseline log ---"
cat /tmp/jekyll-baseline.log || true
echo "--- candidate log ---"
cat /tmp/jekyll-candidate.log || true
exit 1
fi
sleep 2
done
if [ "$READY" -ne 1 ]; then
echo "Timed out waiting for Jekyll servers (5 minutes)."
echo "--- baseline log ---"
cat /tmp/jekyll-baseline.log || true
echo "--- candidate log ---"
cat /tmp/jekyll-candidate.log || true
exit 1
fi
npm run test:visual -- --reporter=line
- name: Upload Playwright report πŸ“„
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: playwright-report
if-no-files-found: ignore
- name: Upload Jekyll logs πŸ“„
if: always()
uses: actions/upload-artifact@v4
with:
name: jekyll-visual-logs
path: |
/tmp/jekyll-baseline.log
/tmp/jekyll-candidate.log
if-no-files-found: ignore