Files
stack/tests/dev/test_gen_config_lean_pay.py
kert df29e8d958
All checks were successful
CI / lint (push) Successful in 52s
CI / notebooks-smoke (push) Successful in 2m11s
Deploy / changes (push) Successful in 18s
CI / test (push) Successful in 6m2s
Deploy / notebooks (push) Has been skipped
Deploy / zotero (push) Has been skipped
Deploy / docs (push) Has been skipped
Deploy / api (push) Has been skipped
Deploy / bcda (push) Has been skipped
Deploy / llm (push) Has been skipped
Deploy / mc (push) Has been skipped
Lean Pay / pay (push) Successful in 2m51s
Deploy / report (push) Successful in 15s
fix(ci): run lean from lean/Pay so elan finds the toolchain
The install step called lean at the repo root. Elan has no default
toolchain, so the job died before typecheck. Run 2121, issue #1657.
2026-11-17 14:08:55 -05:00

74 lines
2.7 KiB
Python

"""The Lean Pay typecheck is emitted by the Gitea backend.
Gitea Actions ignores ``paths:`` filters on push, so the job itself
diffs ``github.event.before`` and skips the toolchain unless ``lean/``
or this workflow changed. ``workflow_dispatch`` always typechecks.
"""
from __future__ import annotations
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(ROOT / "dev" / "scripts"))
from backends import gitea # noqa: E402
def test_lean_pay_workflow() -> None:
path, content = gitea._gen_lean_pay(runner="ubuntu-latest", uv_version="0.5")
assert path == ".gitea/workflows/lean-pay.yml"
assert "name: Lean Pay" in content
assert "workflow_dispatch:" in content
assert "branches: [main]" in content
assert "schedule:" not in content
assert "releases.lean-lang.org" not in content
assert (
"https://github.com/leanprover/lean4/releases/download/"
"v4.34.0/lean-4.34.0-linux.tar.zst"
) in content
assert "--default-toolchain none" in content
assert 'elan toolchain link "leanprover/lean4:v4.34.0"' in content
# No default toolchain is installed. `lean` at the repo root errors
# with "no default toolchain configured"; the pin lives in lean/Pay.
install = content.split("Install Lean 4.34.0", 1)[1].split("Typecheck Pay", 1)[0]
assert install.index("cd lean/Pay") < install.index("lean --version")
assert "lake update" in content
assert "lake exe cache get" in content
assert "lake build" in content
assert "lake exe pay-cases" in content
assert "diff -u cases.json" in content
assert "github.event.before" in content
assert "lean/*" in content
assert ".gitea/workflows/lean-pay.yml" in content
assert "steps.filter.outputs.pay == 'true'" in content
# A skipped push is a green job. It must not close a real Lean Pay issue.
close = next(
line
for line in content.splitlines()
if line.strip().startswith("if:")
and "Close" not in line
and "success()" in line
)
assert "steps.filter.outputs.pay == 'true'" in close
assert '--workflow "Lean Pay" --job "pay"' in content
def test_emitted_with_the_others() -> None:
files = gitea.emit(
images=[],
scans=[],
platform={
"registry": "r",
"domain": "d",
"host_ip": "1.1.1.1",
"image_prefix": "p",
"repo": "o/n",
},
ci_cfg={"runner": "ubuntu-latest", "registry": "r", "uv_version": "0.5"},
)
assert ".gitea/workflows/lean-pay.yml" in files
committed = (ROOT / ".gitea" / "workflows" / "lean-pay.yml").read_text()
assert committed == files[".gitea/workflows/lean-pay.yml"]