Add workshop material lint workflow - #2
Open
cmvcordova wants to merge 2 commits into
Open
cmvcordova wants to merge 2 commits into
cmvcordova wants to merge 2 commits into
Conversation
Adds a reusable workflow that lints the files a pull request changes in a workshop repo, the linter it runs, and a caller template. Files that cannot be opened or run fail the check: notebooks that are not valid JSON, Python, R and shell scripts that do not parse, Rmd/qmd with a broken YAML header or an unclosed chunk. Code cells that do not parse, committed error outputs and relative image paths are warnings, since student notebooks contain intentional blanks. The caller is not distributed: the distributor is unchanged, so merging this changes nothing in other repos until a repo adds the caller. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- Run Rscript with --vanilla so .Rprofile and .Renviron from the repo
being checked are not loaded. A pull request could ship one that
quits before parsing, which made broken R files pass.
- Treat an R parser that exits non-zero, or stops before the end, as a
failed check instead of as clean files.
- Parse notebook cells and Python chunks as plain Python first and only
strip IPython syntax when that fails. The stripping rewrote text
inside ordinary strings and comments and produced false warnings,
for example on print("accuracy = %.2f" % 0.95).
Found by a Codex review of this branch.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moves the lint check trialled in QLS-MiCM/IntroToPython#10 into this repo, so it lives next to the checklist workflow instead of inside one workshop repo. It was prompted by QLS-MiCM/IntroToPython#9, where a missing comma made the notebook invalid JSON and nothing flagged it.
Merging this changes nothing in other repos
What is added
.github/workflows/reusable_lint_workshop.ymlscripts/lint_workshop.py.github/workflow-templates/lint_workshop_caller.ymlREADME.mdUnlike the checklist workflow, this one runs on
pull_request, with a read-only token and no secrets, which is why it is allowed to check out the PR. The linter always comes from this repo, so a PR cannot edit the checks it is held to.What it checks
It looks at the files a pull request changes.
Fails the check (the file cannot be opened or run at all):
.ipynbis not valid JSON.py,.Ror.shdoes not parse.Rmd/.qmdhas a broken YAML header or a code chunk that is never closed.mlxis not a valid archiveWarns only (annotations and a job summary):
Cell-level syntax is a warning on purpose: student notebooks contain intentional blanks.
How it was tested
.Rfile containing a sentence). None of the 26 merged PRs failed.line 21: not valid JSON, the notebook cannot be opened(run). The failing case was not re-run through the reusable workflow.Not covered
.R,.Rmdor.qmd; that step has not run yet, because IntroToPython has no R files..mfiles are not checked.Open questions for rollout
🤖 Generated with Claude Code