Gitea ignores path filters, so the job diffs the previous push and skips unless lean/ or the workflow changed. Lean 4.34.0 comes from the GitHub release; mathlib is the olean cache.
70 lines
2.4 KiB
Python
70 lines
2.4 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
|
|
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"]
|