# A workflow to run our check script.

name: check

on: [pull_request, push]

defaults:
  run:
    shell: bash
    working-directory: source

jobs:
  run-checks:
    name: Run checks on ${{matrix.cfg.name}}
    runs-on: ${{matrix.cfg.os}}

    strategy:
      matrix:
        cfg:
          - { name: 'Linux', os: 'ubuntu-24.04' }
          - { name: 'MacOS', os: 'macos-15' }

    steps:
      - name: checkout
        uses: actions/checkout@v4

      - name: install GNU tools
        if: matrix.cfg.os == 'macos-15'
        run: |
          brew install gnu-sed
          echo "/opt/homebrew/opt/gnu-sed/libexec/gnubin" >> ${GITHUB_PATH}

      - name: check-source.sh
        run: ../tools/check-source.sh

      - name: update brew
        if: matrix.cfg.os == 'macos-15'
        run: brew update

      - name: update-apt-cache
        if: matrix.cfg.os == 'ubuntu-24.04'
        run: sudo apt-get update

      - name: install (Linux)
        if: matrix.cfg.os == 'ubuntu-24.04'
        run: sudo apt-get install latexmk texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended lmodern

      - name: install (MacOS)
        if: matrix.cfg.os == 'macos-15'
        run: |
          brew install basictex
          eval "$(/usr/libexec/path_helper)"
          echo "PATH=${PATH}" >> ${GITHUB_ENV}
          sudo tlmgr update --self
          sudo tlmgr install latexmk isodate substr relsize ulem fixme rsfs environ layouts enumitem l3packages l3kernel imakeidx splitindex xstring

      - name: make (Linux)
        if: matrix.cfg.os == 'ubuntu-24.04'
        run: make quiet

      - name: make (MacOS)
        if: matrix.cfg.os == 'macos-15'
        run: make full

      - name: check-output.sh
        run: ../tools/check-output.sh

      - name: upload PDF
        if: matrix.cfg.os == 'ubuntu-24.04'
        uses: actions/upload-artifact@v4
        with:
          name: draft-snapshot
          path: source/std.pdf
