Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,5 @@ jobs:
run: |
make init-dev
make man
make checks
make checks RURU=:
acme-widgets status --json
41 changes: 41 additions & 0 deletions .github/workflows/ruru-post.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Template B: comments on the pull request from the report Template A uploaded.
# It runs in the base repository's context with a write token, so it NEVER checks out pull request code: it
# downloads the report and hands it to `ruru post`, which checks the schema, checks that the pull request's head is
# the commit this trusted event names, and escapes every string.
name: ruru post

on:
workflow_run:
workflows: [ruru]
types: [completed]

permissions:
pull-requests: write
actions: read

jobs:
post:
if: github.event.workflow_run.event == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: "Download the report (data only)"
uses: actions/download-artifact@v4
with:
name: ruru-report
path: ruru
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}

- name: "Read the pull request number from the artifact"
id: pr
run: |
n=$(python3 -c 'import json; n = json.load(open("ruru/ruru-pr.json")).get("number")
print(n if isinstance(n, int) and n > 0 else "")')
echo "number=$n" >> "$GITHUB_OUTPUT"

- name: "ruru post"
uses: jpsanders/ruru-review@main
with:
run: post
report: ruru/ruru-report.json
pr: ${{ steps.pr.outputs.number }}
42 changes: 42 additions & 0 deletions .github/workflows/ruru.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# ruru reviews each pull request: a tamper audit of the tests, fail first for new tests, and mutants on the changed
# lines (https://github.com/jpsanders/ruru-review). This job runs the pull request's code with a read only token, so
# it is safe for forks; ruru-post.yml comments from its report.
name: ruru

on:
pull_request:

permissions:
contents: read

jobs:
ruru:
runs-on: ubuntu-latest
steps:
- name: "Checkout code with history"
uses: actions/checkout@v7
with:
fetch-depth: 0
persist-credentials: false

- name: "Set up Python"
uses: actions/setup-python@v7
with:
python-version: "3.15"

- name: "Install the package and its test tools"
run: python -m pip install -e ".[dev]"

- name: "ruru"
uses: jpsanders/ruru-review@main
with:
mode: gate
report: ruru/ruru-report.json

- name: "Upload the report for the posting workflow"
if: always()
uses: actions/upload-artifact@v4
with:
name: ruru-report
path: ruru/
if-no-files-found: ignore
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Instructions for AI coding agents working in this repository. People will find t
make init-dev # install the package and the development tools into the active environment
make format # apply black and isort
make checks # every check CI runs, in CI's order; run it before you say a change is done
make ruru # ruru reviews your branch against main: tamper audit, fail first, mutants (in checks)
make man # rebuild the man page and the packaged manual after editing docs/MANUAL.md
make build # wheel and sdist into build/dist
```
Expand Down
15 changes: 14 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,17 @@ clean:

# Run all checking tools
.PHONY: checks
checks: isort-check black-check ec docstyle lint mypy bandit man-check pytest
checks: isort-check black-check ec docstyle lint mypy bandit man-check pytest ruru

# ruru reviews the change on this branch against main: a tamper audit of the tests, fail first for new tests, and
# mutants on the changed lines (https://github.com/jpsanders/ruru-review). On main with nothing changed it passes at
# once. `make checks RURU=:` skips it; RURU_BASE and RURU_MODE override the defaults.
RURU ?= uvx --python 3.14 --from git+https://github.com/jpsanders/ruru-review@main ruru
RURU_BASE ?= origin/main
RURU_MODE ?= gate

.PHONY: ruru
ruru:
@echo
@echo --- ruru: tamper audit, fail first and mutants on the change ---
$(RURU) check --base $(RURU_BASE) --mode $(RURU_MODE)
Loading