ci: lint API maps#1436
Conversation
|
Thank you for this PR, which will now be reviewed. If submitting to ./Physlib or ./QuantumInfo, please see our review guidelines if you are not familiar with the process. You should expect a back and forth with a reviewer before your PR is merged. See also that link for how to add appropriate labels to your PR. The PR will also go through a number of automated checks. You can learn more about these here, including how to run them locally. If you are submitting to ./PhyslibAlpha there will be a lighter review process, though your PR must still pass the automated checks. If you want to bring attention to this PR, please write a message on this thread of the Lean Zulip. Important: If a reviewer adds an |
jstoobysmith
left a comment
There was a problem hiding this comment.
Great! I've done some checks and this seems to work nicely, so have approved. Will merge shortly
Motivation
Related to #1414. API maps record the implemented status and source locations of requirements for an API. A malformed map or a stale source reference is otherwise found only during manual review.
Changes
Adds
scripts/api_map_linter.pyand runs it in the existing Python lint job. For everyAPI-map.yamlit checks that the file parses as YAML, that the top-level and per-requirement keys match the schema, and that each requirement marked done points at a Lean file that exists and contains every declared name or notation token it claims.The map format in #1414 is YAML, so the check lives in the existing Python lint job; the Lean toolchain has no YAML parser. Anonymous instance claims cannot be checked by text search, so the linter counts and reports them instead of treating them as verified. A Lean-side pass that resolves names and synthesizes instance claims in the compiled environment is a natural follow-up; this check is the cheap tier that runs on every push.
Also quotes the colon in the LorentzGroup map description so the existing file parses as YAML. That is the one error the check finds on current master.
Testing
exits 0 on this branch with
Reverting the LorentzGroup quote reproduces the YAML parse failure (exit 1), and misspelling a declared name in a map fails with MISSING NAME (exit 1). Both were checked locally.