Repository navigation
fix: correct skill bugs and close the Docker lock race - #9
Merged
Merged
Conversation
## Short Summary (TL;DR) Fixes steps in all four skills that fail or give a wrong result, and makes the shared Docker lock safe when several sessions wait for an expired lock. ## The Issue A review of the skills found these problems: - `/ddev:ci-failure` checks the PR author with `gh pr view --json authorAssociation`, a field that gh doesn't have. - `failed-job.sh` reads an `/attempts/N` URL as job N. It stops at a job without a log, such as one whose runner was lost. It also fails on older gh, which doesn't know `--allow-escape-sequences`. - `/ddev:work` finds no conflicting PRs once the changes are uncommitted, because the file list is empty. - `/ddev:commit` cuts comments after the passing check run, which it says must be the last change. - `/ddev:review` fetches from `upstream` before it says to use `origin` without one. - Lock labels such as `pr-12` don't name the repository. Two sessions on PR 12 of different repositories both hold the lock. - The lock deletes an expired lock after it reads it. Two waiting sessions can both take it then. In a test with six sessions on an expired lock, two held it in 1 of 40 rounds. ## How This PR Solves The Issue The lock is now a directory of numbered files. The highest number holds `<holder> <since>`, and `-` means free. Every change writes the next number with `ln`, which fails when the file exists. So when sessions see the same free or expired lock, only one of them gets it. No session deletes the highest number, and a broken lock file stops the script with an error. The scripts also got simpler. `failed-job.sh` reads all jobs of a run in one request, and the Buildkite history in one GraphQL query instead of 17 requests. `mentions.sh` no longer reads marked-as-duplicate events, because DDEV closes duplicates with a reason, which the script already shows. Review drafts now go through `check-message.sh --body`, so the review and commit skills share one list of words to avoid. ## Manual Testing Instructions Load the skills from this branch: ```bash claude --plugin-dir ./plugins/ddev ``` Read a failed attempt of a run whose runner was lost: ```bash plugins/ddev/skills/ci-failure/failed-job.sh https://github.com/ddev/ddev/actions/runs/40808535160/attempts/1 # Expect the job "wsl2-nat-testpkg / WSL2 (nat, testpkg)", the annotation "The hosted runner lost communication with the server", "no log; gh printed why", and the job's history ``` Start six sessions on an expired lock: ```bash export REVIEW_LOCK=$HOME/tmp/lock-test mkdir -p "$REVIEW_LOCK" && echo "stale 0" > "$REVIEW_LOCK/1" for i in 1 2 3 4 5 6; do plugins/ddev/skills/review/review-lock.sh acquire "s$i" & done # Expect "expired: stale" and one "acquired:" line, and five "waiting for:" lines kill $(jobs -p); rm -r "$REVIEW_LOCK"; unset REVIEW_LOCK ``` ## Automated Testing Overview Claude Code ran `shellcheck` and `claude plugin validate .` on Linux. Claude Code also ran the changed scripts on Linux, under bash 5 and under bash 3.2 with BusyBox tools: - `failed-job.sh` on ddev/ddev runs, a job URL, an attempt URL and a Buildkite build, with gh 2.72 and 2.102 - `mentions.sh` and `pr-context.sh` on a ddev/ddev PR, with the same output as before - `check-message.sh` on three messages in both modes, with the same output as before - the lock: 350 rounds of six sessions on an expired lock with one holder each, 6 workers that each acquire and release 40 times with no overlap, a session that recreates a removed number, and four kinds of broken lock file Nobody tested on macOS or in Git Bash. ## Release/Deployment Notes The lock moved to `~/tmp/.ddev-docker-lock`. Until every session updates the plugin, sessions on an older version use `~/tmp/.ddev-review.lock` and don't wait for this version. 🤖 Developed with assistance from [Claude Code](https://claude.ai/code) Co-Authored-By: Claude Opus 5.5 <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.
Short Summary (TL;DR)
Fixes steps in all four skills that fail or give a wrong result, and makes the shared Docker lock safe when several sessions wait for an expired lock.
The Issue
A review of the skills found these problems:
/ddev:ci-failurechecks the PR author withgh pr view --json authorAssociation, a field that gh doesn't have.failed-job.shreads an/attempts/NURL as job N. It stops at a job without a log, such as one whose runner was lost. It also fails on older gh, which doesn't know--allow-escape-sequences./ddev:workfinds no conflicting PRs once the changes are uncommitted, because the file list is empty./ddev:commitcuts comments after the passing check run, which it says must be the last change./ddev:reviewfetches fromupstreambefore it says to useoriginwithout one.pr-12don't name the repository. Two sessions on PR 12 of different repositories both hold the lock.How This PR Solves The Issue
The lock is now a directory of numbered files. The highest number holds
<holder> <since>, and-means free. Every change writes the next number withln, which fails when the file exists. So when sessions see the same free or expired lock, only one of them gets it. No session deletes the highest number, and a broken lock file stops the script with an error.The scripts also got simpler.
failed-job.shreads all jobs of a run in one request, and the Buildkite history in one GraphQL query instead of 17 requests.mentions.shno longer reads marked-as-duplicate events, because DDEV closes duplicates with a reason, which the script already shows.Review drafts now go through
check-message.sh --body, so the review and commit skills share one list of words to avoid.Manual Testing Instructions
Load the skills from this branch:
Read a failed attempt of a run whose runner was lost:
plugins/ddev/skills/ci-failure/failed-job.sh https://github.com/ddev/ddev/actions/runs/40808535160/attempts/1 # Expect the job "wsl2-nat-testpkg / WSL2 (nat, testpkg)", the annotation "The hosted runner lost communication with the server", "no log; gh printed why", and the job's historyStart six sessions on an expired lock:
Automated Testing Overview
Claude Code ran
shellcheckandclaude plugin validate .on Linux. Claude Code also ran the changed scripts on Linux, under bash 5 and under bash 3.2 with BusyBox tools:failed-job.shon ddev/ddev runs, a job URL, an attempt URL and a Buildkite build, with gh 2.72 and 2.102mentions.shandpr-context.shon a ddev/ddev PR, with the same output as beforecheck-message.shon three messages in both modes, with the same output as beforeNobody tested on macOS or in Git Bash.
Release/Deployment Notes
The lock moved to
~/tmp/.ddev-docker-lock. Until every session updates the plugin, sessions on an older version use~/tmp/.ddev-review.lockand don't wait for this version.🤖 Developed with assistance from Claude Code