From ae7337eb3a1294474c4f676de0ade126cf5eef47 Mon Sep 17 00:00:00 2001 From: Teddy Andrieux Date: Fri, 13 Nov 2026 10:18:39 +0100 Subject: [PATCH] ci: add claude review workflow --- .claude/REVIEW.md | 17 +++++++++++++++++ .github/workflows/review.yml | 28 ++++++++++++++++++++++++++++ CLAUDE.md | 10 ++++++++++ 3 files changed, 55 insertions(+) create mode 100644 .claude/REVIEW.md create mode 100644 .github/workflows/review.yml create mode 100644 CLAUDE.md diff --git a/.claude/REVIEW.md b/.claude/REVIEW.md new file mode 100644 index 0000000..8e6e8c5 --- /dev/null +++ b/.claude/REVIEW.md @@ -0,0 +1,17 @@ +# Code Review Criteria + +When reviewing pull requests in this repository, check the following areas: + +| Area | What to check | +| ---- | ------------- | +| Public API compatibility | Changes to exported identifiers, function signatures, the `Option` type or the `Error` struct fields. A breaking change needs a major version bump and a `/vN` module path. | +| Output formats | Changes to the `Error()` string, the `%v` / `%+v` JSON shape, JSON field names or the `slog` group keys. Consumers parse and match these, so treat them as API. `README.md` and `DESIGN.md` show the exact strings and must stay in sync. | +| Standard library semantics | `Is`, `As` and `Unwrap` keep working with the standard `errors` package. `Is` keeps its identifier-prefix matching. `CausedBy` chains stay reachable through `errors.Unwrap`. | +| Immutability of sentinels | Sentinel errors from `New` are shared package-level values. `Wrap` and every option must clone `Details`, `Identifier` and `Properties` and never mutate the template error. Watch for slice aliasing through `append`. | +| Concurrency | Sentinels are wrapped from many goroutines at once. No option may write to shared maps or slices. Tests run with `-race`. | +| Nil safety | Nil receivers, `Wrap(nil)`, `CausedBy(nil)`, empty property keys and nil maps must not panic. An error library must never crash the caller's error path. | +| Stack capture | `runtime.Caller` depth is hard-coded. A new entry point or an extra call layer shifts the captured frame. Tests should assert the reported function name. | +| Dependencies | The library has no runtime dependency. A new non-test import outside the standard library needs a strong reason. `go.mod` and `go.sum` stay consistent. | +| Tests | New behavior is covered by Ginkgo/Gomega specs in `errors_test.go`, in the existing `Describe` / `It` style. | +| CI and workflows | GitHub Actions are pinned to a commit SHA with a version comment, matching the existing workflows. | +| Security | No secrets or real hostnames in tests or examples. Flag changes that start logging `Properties` or `Details` in new places, since callers may put sensitive values there. | diff --git a/.github/workflows/review.yml b/.github/workflows/review.yml new file mode 100644 index 0000000..325284e --- /dev/null +++ b/.github/workflows/review.yml @@ -0,0 +1,28 @@ +name: Code Review + +on: + pull_request: + types: [opened, synchronize, labeled, unlabeled] + pull_request_target: + types: [opened, synchronize] + +jobs: + review: + # May also trigger on bump branches when a human updates them (acceptable double-review). + if: github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' && github.actor != 'scality-renovate[bot]' + uses: scality/workflows/.github/workflows/claude-code-review.yml@91619d883650e6238f517757f7b978757c2cb086 # v2.12.1 + secrets: + # The review prompt is a slash command shipped by the scality-skills + # plugin, which the shared workflow clones from the agent-hub marketplace + # with this app key. Without it the plugin is skipped and the review + # silently does nothing. + ACTIONS_APP_PRIVATE_KEY: ${{ secrets.ACTIONS_APP_PRIVATE_KEY }} + + review-dependency-bump: + # pr.user.login catches bump PRs updated by a human, where github.actor is no longer the bot. + if: github.event_name == 'pull_request_target' && (github.actor == 'dependabot[bot]' || github.event.pull_request.user.login == 'dependabot[bot]' || github.actor == 'scality-renovate[bot]' || github.event.pull_request.user.login == 'scality-renovate[bot]') + uses: scality/workflows/.github/workflows/claude-code-dependency-review.yml@91619d883650e6238f517757f7b978757c2cb086 # v2.12.1 + with: + ACTIONS_APP_ID: ${{ vars.ACTIONS_APP_ID }} + secrets: + ACTIONS_APP_PRIVATE_KEY: ${{ secrets.ACTIONS_APP_PRIVATE_KEY }} diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..b1acde6 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,10 @@ +# go-errors + +This is a **Go library for structured error handling** (`github.com/scality/go-errors`). It contains: + +- A single package `errors` in `errors.go`: `New`, `Wrap` with functional options, stack capture, identifier chaining +- Standard library compatibility: `errors.Is`, `errors.As`, `errors.Unwrap`, `fmt` verbs (`%v` / `%+v` as JSON) and `slog.LogValuer` +- Ginkgo/Gomega tests in `errors_test.go`, run with `go test -race ./...` +- Linting with golangci-lint, via the devcontainer in `.devcontainer/` +- Design notes in `DESIGN.md`, usage and exact output formats in `README.md` +- No runtime dependencies: `go.mod` only pulls test dependencies