-
Notifications
You must be signed in to change notification settings - Fork 1
Pc 474 #237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Pc 474 #237
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| name: pre-commit | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| merge_group: | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| pre-commit: | ||
| name: pre-commit | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.12" | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version-file: "go.mod" | ||
| cache: true | ||
|
|
||
| - name: Add Go bin to PATH | ||
| run: echo "${{ github.workspace }}/.tools/bin" >> $GITHUB_PATH | ||
|
|
||
| - name: Install pre-commit | ||
| run: python -m pip install --upgrade pip pre-commit | ||
|
|
||
| - name: Install Go tools | ||
| run: | | ||
| mkdir -p .tools/bin | ||
| GOBIN="${{ github.workspace }}/.tools/bin" go install golang.org/x/tools/cmd/goimports@v0.30.0 | ||
| GOBIN="${{ github.workspace }}/.tools/bin" go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.2 | ||
|
|
||
| - name: Run pre-commit | ||
| run: pre-commit run --all-files --show-diff-on-failure | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,8 @@ config/**/charts | |
| *~ | ||
|
|
||
| .claude | ||
| .venv | ||
| .tools | ||
|
|
||
| /zxporter-netmon | ||
| *.o | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| default_stages: | ||
| - pre-commit | ||
|
|
||
| repos: | ||
| - repo: local | ||
| hooks: | ||
| - id: gofmt | ||
| name: gofmt | ||
| entry: gofmt -w | ||
| language: system | ||
| types: [go] | ||
| - id: goimports | ||
| name: goimports | ||
| entry: ./.tools/bin/goimports -w | ||
| language: system | ||
| types: [go] | ||
| - id: golangci-lint | ||
| name: golangci-lint | ||
| entry: ./.tools/bin/golangci-lint run --timeout=5m | ||
| language: system | ||
| pass_filenames: false | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v4.6.0 | ||
| hooks: | ||
| - id: trailing-whitespace | ||
| - id: end-of-file-fixer | ||
| - id: check-json | ||
| - id: check-yaml | ||
| args: ["--allow-multiple-documents"] | ||
| exclude: ^helm-chart/.*/templates/ | ||
| - id: check-added-large-files | ||
| args: ["--maxkb=1024"] | ||
|
Comment on lines
+22
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CI warning: formatting hooks are modifying files—run pre-commit locally and commit the results. The job warning indicates 🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,7 +60,7 @@ DAKR_URL ?= https://dakr.devzero.io | |
| # PROMETHEUS URL for metrics collection | ||
| PROMETHEUS_URL ?= http://prometheus-dz-prometheus-server.$(DEVZERO_MONITORING_NAMESPACE).svc.cluster.local:80 | ||
| # TARGET_NAMESPACES for limiting collection to specific namespaces (comma-separated) | ||
| TARGET_NAMESPACES ?= | ||
| TARGET_NAMESPACES ?= | ||
| # COLLECTION_FILE is used to control the collectionpolicies. | ||
| COLLECTION_FILE ?= env_configmap.yaml | ||
| # ENV_CONFIGMAP_FILE is used to control the zxporter-manager deployment. | ||
|
|
@@ -162,6 +162,32 @@ lint: golangci-lint ## Run golangci-lint linter | |
| lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes | ||
| $(GOLANGCI_LINT) run --fix | ||
|
|
||
| PRE_COMMIT ?= .venv/bin/pre-commit | ||
|
|
||
| .venv/bin/pre-commit: | ||
| python3 -m venv .venv | ||
| .venv/bin/pip install --upgrade pip pre-commit | ||
|
|
||
| .PHONY: pre-commit-install | ||
| pre-commit-install: .venv/bin/pre-commit ## Install pre-commit hooks (optional). | ||
| $(PRE_COMMIT) install --install-hooks | ||
|
|
||
| .PHONY: pre-commit | ||
| pre-commit: pre-commit-tools .venv/bin/pre-commit ## Run pre-commit on all files. | ||
| PATH="$(PWD)/.tools/bin:$$PATH" $(PRE_COMMIT) run --all-files | ||
|
|
||
| .PHONY: pre-commit-tools | ||
| pre-commit-tools: ## Install Go tools needed by pre-commit. | ||
| @mkdir -p .tools/bin | ||
| GOBIN="$(PWD)/.tools/bin" go install golang.org/x/tools/cmd/goimports@v0.30.0 | ||
| GOBIN="$(PWD)/.tools/bin" go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.2 | ||
|
Comment on lines
+179
to
+183
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: goimports is distributed inside the golang.org/x/tools module and doesn’t have its own independent release tag — its version follows the golang.org/x/tools module release. To install the latest published version (resolves to the module’s latest tag or pseudo-version): go install golang.org/x/tools/cmd/goimports@latest (Documentation: pkg.go.dev). [1][2] References:
🌐 Web query:
💡 Result: Latest notable release: gopls (part of golang.org/x/tools) v0.21.0 — released Dec 17, 2025. [1][2] References:
🌐 Web query:
💡 Result: v0.30.0 is not the latest — the golang.org/x/tools module has newer releases (e.g. v0.31.0 and later) and its downstream projects (like gopls) have continued releasing after v0.30.0. (pkg.go.dev) Citations: Update goimports to a more recent version. The golangci-lint version correctly matches 🤖 Prompt for AI Agents |
||
|
|
||
| .PHONY: pre-commit-install-tool | ||
| pre-commit-install-tool: .venv/bin/pre-commit ## Install pre-commit into a local virtualenv. | ||
|
|
||
| .PHONY: pre-commit-setup | ||
| pre-commit-setup: pre-commit-install-tool pre-commit-tools ## Install pre-commit and tools (hooks are optional). | ||
|
|
||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| GITVERSION ?= $(shell git describe --tags 2>/dev/null || echo "v0.0.0-$(shell git rev-parse --short HEAD)") | ||
|
|
||
| ifeq ($(shell echo $(GITVERSION) | grep -E "^v[0-9]+\.[0-9]+\.[0-9]+"),) | ||
|
|
@@ -354,7 +380,7 @@ build-installer: manifests generate kustomize yq ## Generate a consolidated YAML | |
| # @cat $(METRICS_SERVER) >> $(DIST_INSTALL_BUNDLE) | ||
| # @echo "# ----- END METRICS SERVER -----" >> $(DIST_INSTALL_BUNDLE) | ||
| @echo "---" >> $(DIST_INSTALL_BUNDLE) | ||
|
|
||
| @echo "[INFO] Append zxporter-manager to the installer bundle" | ||
| @cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} | ||
|
|
||
|
|
@@ -396,11 +422,11 @@ HELM_CHART_PACKAGE_DIR := helm-chart/packages | |
| helm-chart-build: helm ## Build and package the Helm chart | ||
| @echo "[INFO] Building Helm chart..." | ||
| @mkdir -p $(HELM_CHART_PACKAGE_DIR) | ||
|
|
||
| # Update chart version and appVersion | ||
| @$(YQ) eval '.version = "$(VERSION)"' -i $(HELM_CHART_DIR)/Chart.yaml | ||
| @$(YQ) eval '.appVersion = "$(VERSION)"' -i $(HELM_CHART_DIR)/Chart.yaml | ||
|
|
||
| # Package the chart | ||
| @$(HELM) package $(HELM_CHART_DIR) --destination $(HELM_CHART_PACKAGE_DIR) | ||
| @echo "[INFO] Helm chart packaged successfully" | ||
|
|
@@ -681,7 +707,7 @@ install-buf: ## Install buf if not already installed | |
| echo "$(BUF_BINARY_NAME) is already installed."; \ | ||
| fi | ||
|
|
||
| # (for local dev) Get metadata to generate a Dakr client. | ||
| # (for local dev) Get metadata to generate a Dakr client. | ||
| .PHONY: generate-proto | ||
| generate-proto: install-buf ## Fetch latest Dakr protobuf | ||
| @PROTO_DIR="$(PWD)/proto"; \ | ||
|
|
@@ -693,7 +719,7 @@ generate-proto: install-buf ## Fetch latest Dakr protobuf | |
| cp "$(DAKR_MPA_PROTO)" "$$PROTO_DIR/api/v1"; \ | ||
| find "$$PROTO_DIR" -type f -name "*.yaml" -exec perl -pi -e 's|github.com/devzero-inc/services/dakr/gen|github.com/devzero-inc/zxporter/gen|g' {} +; \ | ||
| buf build "$(DAKR_DIR)" --path "$(DAKR_METRICS_COLLECTOR_PROTO)" --path "$(DAKR_CLUSTER_PROTO)" -o "$$PROTO_DIR"/dakr_proto_descriptor.bin; \ | ||
| buf generate --include-imports "$$PROTO_DIR"/dakr_proto_descriptor.bin; | ||
| buf generate --include-imports "$$PROTO_DIR"/dakr_proto_descriptor.bin; | ||
| buf generate --verbose --include-imports --timeout=5m . | ||
|
|
||
| # Lima Verification | ||
|
|
@@ -714,7 +740,7 @@ verify-local: setup-lima | |
| @chmod +x verification/verify_local.sh | ||
| @./verification/verify_local.sh $(LIMA_INSTANCE) | ||
|
|
||
| # for local, this will be something like: | ||
| # for local, this will be something like: | ||
| # make verify-e2e CLUSTER_CONTEXT=kind-zxporter-e2e NAMESPACE=devzero-zxporter | ||
| .PHONY: verify-e2e | ||
| verify-e2e: ## Run E2E verification on a Kind or Cloud cluster | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove leftover TODO comment.
The HTML comment
<!-- todo? remove scope later when all old lint errors are fixed -->appears to be a development note that shouldn't be in the final user-facing documentation.🧹 Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents