Skip to content

Add lint and image step for testing in Prow#7

Merged
yingzhanredhat merged 1 commit intoopenshift-hyperfleet:mainfrom
yingzhanredhat:ying-e2e
Jan 5, 2026
Merged

Add lint and image step for testing in Prow#7
yingzhanredhat merged 1 commit intoopenshift-hyperfleet:mainfrom
yingzhanredhat:ying-e2e

Conversation

@yingzhanredhat
Copy link
Contributor

@yingzhanredhat yingzhanredhat commented Jan 5, 2026

https://issues.redhat.com/browse/HYPERFLEET-139

  • Makefile with Container Image Support
  • Linting with golangci-lint test
  • Update Owners
# make lint                                                  
Running golangci-lint...
0 issues.
#podman build -t e2e .

podman build -t e2e .

STEP 1/3: FROM golang:1.25-alpine
STEP 2/3: WORKDIR /workspace
--> Using cache 36bf99dbf726eac907b53bd101f45a0dfe4b53fccc63dfcd9221c176cebb0dec
--> 36bf99dbf726
STEP 3/3: COPY . .
COMMIT e2e
--> 5b5dcf3b59e5
Successfully tagged localhost/e2e:latest
5b5dcf3b59e5a3ed1676620c50a1689709e357e24e8136e0056ba13c5880f474

Summary by CodeRabbit

  • Chores

    • Added Docker support and context exclusions for cleaner container builds and CI test environments.
    • Introduced a lint target to the build workflow.
    • Established project module configuration and updated project ownership/approvals.
  • Tests

    • Added test scaffolding/placeholder to support future end-to-end tests.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 5, 2026

Walkthrough

Adds initial e2e test scaffolding for a Go project: new .dockerignore excluding build/IDE/OS/CI artifacts, a Dockerfile (golang:1.25-alpine) placeholder for e2e CI, go.mod declaring module path and Go version, a Makefile with a lint target using golangci-lint, a placeholder test at test/sample_test.go, and an OWNERS update adding tzhou5 as approver and reviewer.

Sequence Diagram(s)

(Section omitted — changes are configuration and scaffolding without multi-component runtime control flow.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Update OWNERS file #6 — Changes to OWNERS (reformats approvers/reviewers); directly related to concurrent OWNERS edits.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: adding a lint target to the Makefile and a Dockerfile for CI testing in Prow, which are the primary deliverables of this PR.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 35af801 and fb0b666.

📒 Files selected for processing (6)
  • .dockerignore
  • Dockerfile
  • Makefile
  • OWNERS
  • go.mod
  • test/sample_test.go
✅ Files skipped from review due to trivial changes (1)
  • .dockerignore
🚧 Files skipped from review as they are similar to previous changes (1)
  • go.mod
🧰 Additional context used
🪛 checkmake (0.2.2)
Makefile

[warning] 2-2: Target body for "lint" exceeds allowed length of 5 (8).

(maxbodylength)


[warning] 1-1: Missing required phony target "all"

(minphony)


[warning] 1-1: Missing required phony target "clean"

(minphony)


[warning] 1-1: Missing required phony target "test"

(minphony)

🔇 Additional comments (5)
OWNERS (1)

17-17: LGTM!

The addition of tzhou5 as both approver and reviewer aligns with the governance structure and is properly formatted.

Also applies to: 35-35

test/sample_test.go (1)

1-3: LGTM!

The placeholder test file now includes the [TODO] tag and has correct spacing in the comment. Previous review feedback has been successfully addressed.

Dockerfile (2)

1-2: LGTM!

The [TODO] tag and context comment clearly document that this is placeholder scaffolding for the e2e test framework. The previous feedback about adding a TODO marker has been addressed.


3-3: The golang:1.25-alpine base image is available and valid as of January 2026.

Makefile (1)

1-10: LGTM!

The lint target implementation is well-structured with:

  • Proper tool availability check before execution
  • Clear error messaging with installation instructions
  • Cache clean before running (good practice)

The static analysis warnings about missing standard phony targets (all, clean, test) and body length are noted, but these are optional refinements that can be addressed as the Makefile grows.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (6)
cmd/e2e/main.go (1)

1-19: LGTM! Clear scaffold for future E2E test implementation.

The placeholder implementation provides a solid foundation with clear TODO comments describing the intended test workflow.

Do you want me to help generate an initial implementation for the E2E test suite based on the TODO comments, or open an issue to track this work?

Makefile (5)

8-13: Unused GOBIN variable.

The GOBIN variable is defined but never referenced elsewhere in this Makefile. Consider removing it if not needed, or use it in the lint target to install golangci-lint to a known location.


59-68: Unconditional cache clear slows down lint runs.

golangci-lint cache clean is run on every invocation, which defeats the purpose of caching and significantly slows down repeated lint runs. Consider removing this unless there's a specific reason for it.

🔎 Proposed fix
 .PHONY: lint
 lint: ## Run golangci-lint linter.
 	@echo "Running golangci-lint..."
 	@if command -v golangci-lint > /dev/null; then \
-		golangci-lint cache clean && golangci-lint run; \
+		golangci-lint run; \
 	else \
 		echo "Error: golangci-lint not found. Please install it:"; \
 		echo "  go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest"; \
 		exit 1; \
 	fi

81-86: LOCALBIN is defined but unused.

The LOCALBIN variable and its directory creation rule are defined but not referenced by any target. This could be intentional scaffolding for future tool installation. Consider using it in the lint target to install golangci-lint locally, or remove if not needed.


115-130: docker-buildx missing check-container-runtime prerequisite.

Unlike docker-build and docker-push, the docker-buildx target doesn't depend on check-container-runtime. While it has its own runtime check via the ifeq conditions, adding the prerequisite would provide consistent, user-friendly error messages.

🔎 Proposed fix
 .PHONY: docker-buildx
-docker-buildx: ## Build and push multi-platform image (requires Docker with buildx).
+docker-buildx: check-container-runtime ## Build and push multi-platform image (requires Docker with buildx).
 ifeq ($(CONTAINER_RUNTIME),docker)

141-149: Consider adding standard clean and test targets.

The Makefile is missing commonly expected targets:

  • clean: to remove build artifacts (e.g., bin/ directory)
  • test: to run Go tests (e.g., go test ./...)

These are standard Makefile conventions that users typically expect.

🔎 Proposed additions
.PHONY: clean
clean: ## Remove build artifacts.
	rm -rf bin/

.PHONY: test
test: ## Run tests.
	go test ./...
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4ad40cf and b95e8f1.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (6)
  • .dockerignore
  • Dockerfile
  • Makefile
  • OWNERS
  • cmd/e2e/main.go
  • go.mod
🧰 Additional context used
🪛 checkmake (0.2.2)
Makefile

[warning] 60-60: Target body for "lint" exceeds allowed length of 5 (8).

(maxbodylength)


[warning] 146-146: Missing required phony target "clean"

(minphony)


[warning] 146-146: Missing required phony target "test"

(minphony)

🔇 Additional comments (10)
OWNERS (1)

17-17: LGTM!

The addition of tzhou5 as both an approver and reviewer is properly formatted and follows the existing structure.

Also applies to: 35-35

.dockerignore (1)

1-32: LGTM! Comprehensive exclusion patterns.

The .dockerignore file provides excellent coverage of binaries, IDE artifacts, version control metadata, CI/CD files, and OS-specific files, helping to keep the Docker build context lean and secure.

Dockerfile (2)

1-29: Multi-stage build pattern looks solid overall.

The separation of build and runtime stages is well-implemented, with CGO disabled for static linking and minimal runtime dependencies. Once the version and pinning issues are addressed, this will be a clean, efficient container image.


2-2: No action needed. Go 1.25 is a valid and released version (released August 12, 2025), and both the Dockerfile and go.mod correctly declare the same Go version (1.25). The files are consistent.

Likely an incorrect or invalid review comment.

go.mod (2)

1-3: No issue found — go.sum file is present.

The go.sum file exists in the repository, and the Dockerfile correctly references it with COPY go.sum ./ at line 8. The Docker build will proceed without issues.

Likely an incorrect or invalid review comment.


3-3: Go 1.25 is a valid and released version.

Go 1.25 was released on August 12, 2025, and is the latest stable release as of January 2026. The go.mod specification is correct and requires no changes.

Likely an incorrect or invalid review comment.

Makefile (4)

1-6: LGTM!

Image variables are well-structured with sensible defaults and proper use of conditional assignment (?=) to allow overrides.


36-38: LGTM!

Good practice to set pipefail for robust error handling in shell recipes.


40-47: LGTM!

Self-documenting help target is a nice usability feature.


73-79: LGTM!

Build and run targets correctly depend on fmt and vet for code quality checks. Note that fmt as a prerequisite will auto-modify files, which is a common but opinionated choice.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
Makefile (1)

15-34: Undefined variables when CONTAINER_TOOL is overridden.

This issue was previously identified: when CONTAINER_TOOL is provided externally, DOCKER_AVAILABLE and PODMAN_AVAILABLE remain unset, causing the check-container-runtime target to display empty values.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b95e8f1 and 1d05309.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (6)
  • .dockerignore
  • Dockerfile
  • Makefile
  • OWNERS
  • cmd/e2e/main.go
  • go.mod
🚧 Files skipped from review as they are similar to previous changes (3)
  • cmd/e2e/main.go
  • Dockerfile
  • go.mod
🧰 Additional context used
🪛 checkmake (0.2.2)
Makefile

[warning] 60-60: Target body for "lint" exceeds allowed length of 5 (8).

(maxbodylength)


[warning] 146-146: Missing required phony target "clean"

(minphony)


[warning] 146-146: Missing required phony target "test"

(minphony)

🔇 Additional comments (12)
OWNERS (1)

17-17: LGTM! Governance update looks good.

The addition of tzhou5 to both approvers and reviewers lists is appropriately placed and aligns with the PR objectives.

Also applies to: 34-35

.dockerignore (1)

1-32: LGTM! Comprehensive Docker ignore patterns.

The exclusion patterns are well-organized and appropriate for a Go e2e test project, covering binaries, IDE files, test artifacts, and CI/CD metadata.

Makefile (10)

1-6: LGTM! Clean image configuration.

The image variables use appropriate defaults with override support and follow standard conventions.


8-13: LGTM! Standard GOBIN detection.

The GOBIN detection follows the standard Go tooling pattern.


36-38: LGTM! Robust shell configuration.

The bash configuration with pipefail and error flags ensures recipes fail fast on errors.


40-47: LGTM! Standard Makefile patterns.

The all target and self-documenting help target follow Makefile best practices.


51-68: LGTM! Well-structured development targets.

The fmt, vet, and lint targets are appropriately implemented with helpful user feedback when tooling is missing.


73-79: LGTM! Build targets with appropriate dependencies.

The build and run targets correctly depend on fmt and vet, ensuring code quality checks run before execution.


84-86: LGTM! Standard local binary location.

The LOCALBIN setup follows standard conventions for local tool installation.


90-103: LGTM! Container runtime validation.

The check-container-runtime target provides helpful feedback and appropriate error handling when no runtime is available.


105-113: LGTM! Clean container build and push targets.

The docker-build and docker-push targets correctly gate on check-container-runtime and use the detected runtime.


132-149: LGTM! Convenient image workflow aliases.

The image aliases (image-build, image-push, image-all, image-run, image-clean) provide a clean interface for container workflows.

@tzhou5
Copy link

tzhou5 commented Jan 5, 2026

should we need to add .golangci.yml and .gitignore file in this repo?

@yingzhanredhat
Copy link
Contributor Author

should we need to add .golangci.yml and .gitignore file in this repo?

As there is no detailed test file now, no skip requirement. We can edit it in the futher if it requiures.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Fix all issues with AI Agents 🤖
In @Dockerfile:
- Around line 1-7: The Dockerfile currently sets ENTRYPOINT to "./e2e-test" but
never builds that binary and is single-stage contrary to the PR description;
update to a two-stage build where a builder stage (e.g., FROM
golang:1.25-alpine) sets the module context, runs the appropriate go build
command to produce the e2e-test binary (set CGO_ENABLED=0 and GOOS=linux as
needed) and then a slim final stage (e.g., FROM alpine:latest) copies the
compiled e2e-test into the final image, sets WORKDIR and ENTRYPOINT
["./e2e-test"], and only copies required artifacts into the runtime image to
match the PR intent.

In @test/sample_test.go:
- Line 3: The comment in sample_test.go has missing whitespace after a period
("pass.We"); update the comment text so there is a space after the period, e.g.
change "pass.We" to "pass. We" in the file's top-line comment to fix spacing.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c4b5383 and 041d0c7.

📒 Files selected for processing (6)
  • .dockerignore
  • Dockerfile
  • Makefile
  • OWNERS
  • go.mod
  • test/sample_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • OWNERS
  • .dockerignore
🧰 Additional context used
🪛 checkmake (0.2.2)
Makefile

[warning] 2-2: Target body for "lint" exceeds allowed length of 5 (8).

(maxbodylength)


[warning] 1-1: Missing required phony target "all"

(minphony)


[warning] 1-1: Missing required phony target "clean"

(minphony)


[warning] 1-1: Missing required phony target "test"

(minphony)

🔇 Additional comments (2)
Makefile (1)

1-10: LGTM!

The lint target correctly checks for golangci-lint availability and provides helpful installation instructions when missing. The implementation is solid.

go.mod (1)

3-3: Go 1.25 is released and stable. Go 1.25 was officially released on August 12, 2025, with the latest patch being 1.25.5 (December 2, 2025). No verification needed—this version is available and production-ready.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
Makefile (1)

8-8: Consider pinning golangci-lint version.

The installation instruction uses @latest, which can lead to inconsistent linting results across different environments and time periods. Consider pinning to a specific version for reproducibility.

🔎 Example with pinned version
-		echo " go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest"; \
+		echo " go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61.0"; \
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b3f6209 and 35af801.

📒 Files selected for processing (6)
  • .dockerignore
  • Dockerfile
  • Makefile
  • OWNERS
  • go.mod
  • test/sample_test.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • .dockerignore
  • go.mod
  • test/sample_test.go
🧰 Additional context used
🪛 checkmake (0.2.2)
Makefile

[warning] 2-2: Target body for "lint" exceeds allowed length of 5 (8).

(maxbodylength)


[warning] 1-1: Missing required phony target "all"

(minphony)


[warning] 1-1: Missing required phony target "clean"

(minphony)


[warning] 1-1: Missing required phony target "test"

(minphony)

🔇 Additional comments (2)
OWNERS (1)

17-17: LGTM!

The addition of tzhou5 to both approvers and reviewers lists is straightforward and properly formatted.

Also applies to: 34-35

Makefile (1)

1-10: Lint target implementation looks good.

The lint target properly checks for golangci-lint availability and provides helpful installation instructions. The implementation is clean and functional.

@86254860
Copy link
Contributor

86254860 commented Jan 5, 2026

/lgtm

Copy link
Contributor

@86254860 86254860 left a comment

Choose a reason for hiding this comment

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

/lgtm

@yingzhanredhat yingzhanredhat merged commit 8d900ee into openshift-hyperfleet:main Jan 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments