Skip to content

Commit 635f03e

Browse files
committed
docs: Clarify verify vs generate workflow in AGENTS.md
Add documentation explaining that make verify targets compare against HEAD, so they will fail if there are uncommitted changes. This is a common source of confusion when making changes that require code regeneration. Key clarifications: - Verify targets compare working tree against HEAD (last commit) - Must commit changes before running make verify - Updated workflow sections to show correct order of operations - Added troubleshooting section for verify failures after generate Signed-off-by: Lennart Jern <[email protected]>
1 parent 452372b commit 635f03e

File tree

1 file changed

+29
-11
lines changed

1 file changed

+29
-11
lines changed

AGENTS.md

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,23 @@ All code PRs MUST be labeled with one of:
3434

3535
### Code Quality & Verification
3636

37+
> **⚠️ IMPORTANT**: The `make verify` targets compare the working tree against `HEAD` (the last commit). This means:
38+
> - `make verify` will **always fail** if you have uncommitted changes, even if those changes are correct
39+
> - You should **commit your changes first**, then run `make verify` to confirm everything is in order
40+
> - The typical workflow is: make changes → `make generate``make modules``make test`**commit**`make verify`
41+
3742
```bash
3843
# Run all verification checks (should pass before submitting PR)
44+
# NOTE: This compares against HEAD, so commit your changes first!
3945
make verify
4046

4147
# Verify boilerplate headers
4248
make verify-boilerplate
4349

44-
# Verify go modules are up to date
50+
# Verify go modules are up to date (runs `go mod tidy` and diffs against HEAD)
4551
make verify-modules
4652

47-
# Verify generated code is up to date
53+
# Verify generated code is up to date (runs `make generate` and diffs against HEAD)
4854
make verify-gen
4955

5056
# Verify container images for vulnerabilities
@@ -221,15 +227,17 @@ Before submitting a PR, ensure:
221227
3. Update modules if needed: `make modules`
222228
4. Run tests: `make test`
223229
5. Lint the code: `make lint`
224-
6. Verify everything: `make verify`
225-
7. Commit changes with descriptive message
230+
6. **Commit changes** with descriptive message
231+
7. Verify everything: `make verify` (this compares against HEAD, so must be done after commit)
226232

227233
### Updating Dependencies
228234

229-
1. Update `go.mod` or `hack/tools/go.mod` as needed
230-
2. Run: `make modules`
231-
3. Run: `make verify-modules`
232-
4. Test that everything still works: `make test`
235+
1. Update `go.mod` or `hack/tools/go.mod` as needed (e.g., `go get sigs.k8s.io/[email protected]`)
236+
2. Run: `make modules` to tidy dependencies
237+
3. Run: `make generate` to regenerate code (dependency updates often change generated code)
238+
4. Run: `make test` to ensure everything still works
239+
5. **Commit all changes** (go.mod, go.sum, and any regenerated files)
240+
6. Run: `make verify` to confirm everything is in order
233241

234242
## Common Issues
235243

@@ -250,9 +258,19 @@ The project uses golangci-lint. If you get lint errors:
250258

251259
If `make verify` fails with generated file drift:
252260
1. Run `make generate` to regenerate all files
253-
2. Review the changes to ensure they're expected
254-
3. Commit the generated files
255-
4. Never manually edit generated files
261+
2. Run `make modules` to ensure go.mod/go.sum are tidy
262+
3. Review the changes to ensure they're expected
263+
4. **Commit the generated files** - verify targets compare against HEAD!
264+
5. Run `make verify` again - it should pass now
265+
6. Never manually edit generated files
266+
267+
### Verify Fails Even After Running Generate/Modules
268+
269+
If `make verify-gen` or `make verify-modules` fails even after running `make generate` or `make modules`:
270+
- Remember that these targets compare against `HEAD` (the last commit)
271+
- If you have uncommitted changes, they will show as "drift" even if correct
272+
- **Solution**: Commit your changes first, then run `make verify`
273+
- This is by design - it ensures the committed code is complete and self-consistent
256274

257275
## Documentation
258276

0 commit comments

Comments
 (0)