Skip to content
Open
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
17 changes: 17 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,23 @@ make vet # Vet the Go code
make golangci-lint # Verify the Go code
```

### Targeted lint/format

For quick feedback on specific files or packages instead of running project-wide `make` targets:

```bash
# Go
make golangci-lint LINT_PKG=./pkg/controller/... # Lint a single Go package
go vet ./pkg/controller/... # Vet a single Go package (package-level)
gofmt -w path/to/file.go # Format a single Go file

# Python
pre-commit run --files path/to/file.py # Run all hooks on a single file

# Rust (crate-level: triggers on the file but formats/checks the entire crate)
pre-commit run --files path/to/file.rs # Run all hooks on a single file
```
Comment on lines +141 to +146
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we just run pre-commit run --all-files ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pre-commit run --all-files is already mentioned in Pre-commit and this will run for all files. This PR adds commands to execute against single file/package

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But i replace it with a single command

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChughShilpa We also use pre-commit for cargo check, shall we use it too?
https://github.com/kubeflow/trainer/blob/master/.pre-commit-config.yaml#L28-L35

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, updated the cargo commands to use pre-commit


**Code generation** (always run after modifying the APIs):

```bash
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ HELM_DOCS ?= $(LOCALBIN)/helm-docs
YQ ?= $(LOCALBIN)/yq
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
GOLANGCI_LINT_KAL ?= $(LOCALBIN)/golangci-lint-kube-api-linter
LINT_PKG ?= ./...
KUBE_LINTER ?= $(LOCALBIN)/kube-linter

##@ General
Expand Down Expand Up @@ -173,7 +174,7 @@ vet: ## Run go vet against the code.

.PHONY: golangci-lint
golangci-lint: golangci-lint-install golangci-lint-kal ## Run golangci-lint to verify Go files.
$(GOLANGCI_LINT) run --timeout 5m ./...
$(GOLANGCI_LINT) run --timeout 5m $(LINT_PKG)
$(GOLANGCI_LINT_KAL) run -v --config $(PROJECT_DIR)/.golangci-kal.yml

.PHONY: verify-boilerplate
Expand Down
Loading