Skip to content

fix: render labs(tag:) above the title #228

fix: render labs(tag:) above the title

fix: render labs(tag:) above the title #228

Workflow file for this run

name: Checks
on:
push:
branches:
- main
paths:
- "src/**"
- "lib.typ"
- "examples/**"
- "tests/**"
- "typst.toml"
- "tools/**"
- "README.md"
- "LICENSE"
- ".github/actions/**"
- ".github/workflows/checks.yml"
pull_request:
paths:
- "src/**"
- "lib.typ"
- "examples/**"
- "tests/**"
- "typst.toml"
- "tools/**"
- "README.md"
- "LICENSE"
- ".github/actions/**"
- ".github/workflows/checks.yml"
permissions:
contents: read
# One active run per branch; cancel superseded runs on the same ref.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
typstdoc-tests:
name: Run typstdoc tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Lua
uses: leafo/gh-actions-lua@v11
with:
luaVersion: "5.4"
- name: Run typstdoc tests
id: typstdoc
shell: bash
run: |
set -euo pipefail
lua tools/typstdoc/test/run.lua 2>&1 | tee "${RUNNER_TEMP}/typstdoc.log"
- name: Validate docstrings and example gallery
shell: bash
run: |
set -euo pipefail
lua tools/typstdoc/main.lua --check
- name: Summary
if: always()
shell: bash
run: |
set -euo pipefail
log="${RUNNER_TEMP}/typstdoc.log"
if [[ ! -f "${log}" ]]; then
{
echo "## typstdoc tests"
echo "- Status: failed (no log captured)"
} >> "${GITHUB_STEP_SUMMARY}"
exit 0
fi
totals_line=$(grep -E '^[0-9]+ passed, [0-9]+ failed$' "${log}" | tail -1 || true)
passed=$(awk '{print $1}' <<< "${totals_line:-0 passed, 0 failed}")
failed=$(awk '{print $3}' <<< "${totals_line:-0 passed, 0 failed}")
total=$((passed + failed))
{
echo "## typstdoc tests"
if [[ "${failed}" -gt 0 ]]; then
echo "- Status: failed (${passed}/${total})"
echo ""
echo "### Failures"
grep -E '^ FAIL ' "${log}" | sed -E 's/^ FAIL (.*)$/- `\1`/'
else
echo "- Status: passed (${passed}/${total})"
fi
} >> "${GITHUB_STEP_SUMMARY}"
typst-compile:
name: Compile Typst sources
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Read Typst version from typst.toml
id: typst-version
uses: ./.github/actions/typst-version
- name: Set up Typst
uses: typst-community/setup-typst@v5
with:
typst-version: ${{ steps.typst-version.outputs.version }}
- name: Compile unit tests
id: unit
uses: ./.github/actions/typst-compile
with:
label: unit
glob: "tests/unit/*.typ"
- name: Compile examples
id: examples
if: always()
uses: ./.github/actions/typst-compile
with:
label: example
glob: "examples/*.typ"
- name: Summary
if: always()
shell: bash
env:
UNIT_PASSED: ${{ steps.unit.outputs.passed }}
UNIT_TOTAL: ${{ steps.unit.outputs.total }}
UNIT_FAILED: ${{ steps.unit.outputs.failed }}
UNIT_FAILURES: ${{ steps.unit.outputs.failures }}
EXAMPLES_PASSED: ${{ steps.examples.outputs.passed }}
EXAMPLES_TOTAL: ${{ steps.examples.outputs.total }}
EXAMPLES_FAILED: ${{ steps.examples.outputs.failed }}
EXAMPLES_FAILURES: ${{ steps.examples.outputs.failures }}
run: |
set -euo pipefail
render_section() {
local title="$1" passed="$2" total="$3" failed="$4" failures="$5"
passed="${passed:-0}"
total="${total:-0}"
failed="${failed:-0}"
echo ""
echo "### ${title}"
if [[ "${failed}" -gt 0 ]]; then
echo "- Status: failed (${passed}/${total})"
echo ""
echo "#### Failures"
while IFS= read -r line; do
[[ -n "${line}" ]] && echo "- \`${line}\`"
done <<< "${failures}"
else
echo "- Status: passed (${passed}/${total})"
fi
}
{
echo "## Typst compile"
render_section "Unit tests" "${UNIT_PASSED}" "${UNIT_TOTAL}" "${UNIT_FAILED}" "${UNIT_FAILURES}"
render_section "Examples" "${EXAMPLES_PASSED}" "${EXAMPLES_TOTAL}" "${EXAMPLES_FAILED}" "${EXAMPLES_FAILURES}"
} >> "${GITHUB_STEP_SUMMARY}"
visual-snapshots:
name: Visual snapshot diff
runs-on: ubuntu-latest
# Serialise against the refresh workflow on the same ref so a
# `snapshot-refresh` push and a checks run can't fight over goldens.
concurrency:
group: snapshot-refresh-${{ github.ref }}
cancel-in-progress: false
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Read Typst version from typst.toml
id: typst-version
uses: ./.github/actions/typst-version
- name: Set up Typst
uses: typst-community/setup-typst@v5
with:
typst-version: ${{ steps.typst-version.outputs.version }}
- name: Set up Lua
uses: leafo/gh-actions-lua@v11
with:
luaVersion: "5.4"
- name: Run visual snapshot harness
uses: ./.github/actions/typst-snapshot
with:
mode: check
- name: Summary
if: always()
shell: bash
run: |
set -euo pipefail
log="${RUNNER_TEMP}/snapshot.log"
if [[ ! -f "${log}" ]]; then
{
echo "## Visual snapshots"
echo "- Status: failed (no log captured)"
} >> "${GITHUB_STEP_SUMMARY}"
exit 0
fi
totals_line=$(grep -E '^snapshots: [0-9]+/[0-9]+ ok$' "${log}" | tail -1 || true)
passed=$(sed -E 's|^snapshots: ([0-9]+)/[0-9]+ ok$|\1|' <<< "${totals_line:-snapshots: 0/0 ok}")
total=$(sed -E 's|^snapshots: [0-9]+/([0-9]+) ok$|\1|' <<< "${totals_line:-snapshots: 0/0 ok}")
failures=$(grep -E '^(COMPILE-FAIL|DIFF|MISSING|COMPARE-ERR) ' "${log}" || true)
{
echo "## Visual snapshots"
if [[ -n "${failures}" ]]; then
echo "- Status: failed (${passed}/${total})"
echo ""
echo "### Failures"
while IFS= read -r line; do
key=$(awk '{print $2}' <<< "${line}")
echo "- \`${key}\`"
done <<< "${failures}"
else
echo "- Status: passed (${passed}/${total})"
fi
} >> "${GITHUB_STEP_SUMMARY}"
package-check:
name: Run typst-package-check
runs-on: ubuntu-latest
# Repository URL check fails with 404 while `mcanouil/gribouille` stays
# private; keep the job informational rather than blocking until then.
continue-on-error: true
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: Install typst-package-check
shell: bash
run: cargo install --git https://github.com/typst/package-check --locked
- name: Read versions from manifest
id: versions
shell: bash
run: |
set -euo pipefail
version=$(awk -F'"' '/^version[[:space:]]*=/ { print $2; exit }' typst.toml)
[[ -n "$version" ]] || { echo "::error::version not found in typst.toml"; exit 1; }
compiler=$(awk -F'"' '/^compiler[[:space:]]*=/ { print $2; exit }' typst.toml)
[[ -n "$compiler" ]] || { echo "::error::compiler not found in typst.toml"; exit 1; }
{
echo "version=${version}"
echo "compiler=${compiler}"
} >> "${GITHUB_OUTPUT}"
- name: Set up Typst
uses: typst-community/setup-typst@v5
with:
typst-version: ${{ steps.versions.outputs.compiler }}
- name: Seed package cache
shell: bash
# typst-package-check refuses to download `@preview/*` itself; warm
# the local cache by compiling a tiny file that imports each pinned
# dependency listed in src/deps.typ.
run: |
set -euo pipefail
{
grep -E '^#import[[:space:]]+"@preview/' src/deps.typ
printf '\nseed\n'
} > /tmp/seed.typ
typst compile /tmp/seed.typ /tmp/seed.pdf
- name: Stage published payload
env:
VERSION: ${{ steps.versions.outputs.version }}
shell: bash
run: |
set -euo pipefail
STAGE="/tmp/stage/gribouille/${VERSION}"
tools/package.sh stage "${STAGE}"
echo "STAGE=${STAGE}" >> "${GITHUB_ENV}"
- name: Run typst-package-check
id: pkgcheck
shell: bash
run: |
set -euo pipefail
typst-package-check check "${STAGE}" 2>&1 | tee "${RUNNER_TEMP}/pkgcheck.log"
- name: Summary
if: always()
shell: bash
env:
OUTCOME: ${{ steps.pkgcheck.outcome }}
run: |
set -euo pipefail
log="${RUNNER_TEMP}/pkgcheck.log"
{
echo "## Package check"
if [[ "${OUTCOME}" == "success" ]]; then
echo "- Status: passed"
else
echo "- Status: failed"
if [[ -f "${log}" ]]; then
echo ""
echo "### Failures"
echo ""
echo '```'
tail -n 30 "${log}"
echo '```'
fi
fi
} >> "${GITHUB_STEP_SUMMARY}"