Skip to content

Add route B, a pandoc filter per folder, and compare it with route A #32

Add route B, a pandoc filter per folder, and compare it with route A

Add route B, a pandoc filter per folder, and compare it with route A #32

Workflow file for this run

# The merge gate. Every push to main and every pull request runs the tests and
# then replays the three folders of ci-corpus, the committed corpus, which
# ci-baseline.json names. The job is CI's report on a branch and nothing
# merges on it: the workbench merges with `gh pr merge` as soon as its own
# check passes, and that check replays the private corpus, whose folders a
# runner cannot read, on the machine that holds it.
name: gate
on:
push:
branches: [main]
pull_request:
jobs:
gate:
name: gate
# Pinned rather than ubuntu-latest: the runner's TeX Live decides what
# xelatex writes, and the PDF's bytes are the OCR cache's key.
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
# Pandoc reads every source document, so its version decides the blocks
# a spec selects. ubuntu-24.04 packages pandoc 3.1.3, under which every
# ci-corpus document faults on a block no selector reaches, and the
# tests fail with it. This release is the one the baselines were
# recorded under.
- name: Install pandoc
run: |
curl -fsSL -o "${RUNNER_TEMP}/pandoc.deb" \
https://github.com/jgm/pandoc/releases/download/3.9.0.2/pandoc-3.9.0.2-1-amd64.deb
sudo dpkg -i "${RUNNER_TEMP}/pandoc.deb"
pandoc --version | head -1
# The Dockerfile's package list, which is the one record of what the PDF
# generator's template.latex loads.
- name: Install poppler and TeX Live
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y \
poppler-utils \
texlive-xetex \
texlive-latex-recommended \
texlive-latex-extra \
texlive-science \
texlive-lang-chinese \
texlive-lang-arabic \
texlive-bibtex-extra \
texlive-plain-generic \
texlive-fonts-recommended \
lmodern \
fonts-noto-core \
fonts-noto-cjk
- uses: actions/setup-node@v4
with:
node-version: "20"
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install poetry
run: pipx install poetry
- name: Install the package
run: poetry install --with dev
# SOURCE_DATE_EPOCH fixes the timestamp xelatex writes into the PDF, so
# the same tex source compiles to the same bytes and the OCR cache key
# does not change between runs.
- name: Compile the CI corpus PDF
run: |
cd ci-corpus/tex
SOURCE_DATE_EPOCH=0 FORCE_SOURCE_DATE=1 \
xelatex -interaction=nonstopmode -output-directory=../pdf sheet-1.tex
rm -f ../pdf/sheet-1.aux ../pdf/sheet-1.log
# Keyed by the PDF's bytes, which is also how ocr_pdf names its entry
# inside the directory. A restored entry for another PDF is unused.
- name: Restore the OCR cache
uses: actions/cache@v4
with:
path: ~/.cache/in2lambda-agent
key: ocr-${{ hashFiles('ci-corpus/pdf/*.pdf') }}
restore-keys: ocr-
- name: Tests
run: poetry run pytest -q
- name: Gate
env:
MATHPIX_APP_ID: ${{ secrets.MATHPIX_APP_ID }}
MATHPIX_API_KEY: ${{ secrets.MATHPIX_API_KEY }}
run: poetry run in2lambda-agent gate ci-baseline.json
# What this run would record, so that a baseline change is committed from
# what CI saw. Written whether or not the gate passed. The file is
# recorded where it is checked out, because a baseline names its specs
# relative to its own directory and a copy under RUNNER_TEMP would find
# none; the job throws the checkout away.
- name: Record what this run did
if: always()
env:
MATHPIX_APP_ID: ${{ secrets.MATHPIX_APP_ID }}
MATHPIX_API_KEY: ${{ secrets.MATHPIX_API_KEY }}
run: poetry run in2lambda-agent gate --record ci-baseline.json
- name: Upload it
if: always()
uses: actions/upload-artifact@v4
with:
name: recorded-baseline
path: ci-baseline.json