Skip to content

implemented a CI check to validate code generation#225

Open
katara-Jayprakash wants to merge 10 commits intovolcano-sh:masterfrom
katara-Jayprakash:feature/add-ci-workflows
Open

implemented a CI check to validate code generation#225
katara-Jayprakash wants to merge 10 commits intovolcano-sh:masterfrom
katara-Jayprakash:feature/add-ci-workflows

Conversation

@katara-Jayprakash
Copy link
Member

fix #198

@gemini-code-assist
Copy link

Summary of Changes

Hello @katara-Jayprakash, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the project's development workflow by integrating robust Continuous Integration (CI) checks. It automates the validation of generated client code and ensures API compatibility, preventing common issues before they merge. The changes also include detailed documentation and new Makefile targets, making it easier for developers to maintain code quality and troubleshoot CI failures locally.

Highlights

  • New CI Checks: Implemented new Continuous Integration (CI) checks to validate code generation and ensure API compatibility, enhancing code quality and consistency.
  • Comprehensive CI Documentation: Added a new CI.md file that provides detailed documentation on CI/CD workflows, local development commands, required tools, and troubleshooting steps for API-related issues.
  • Makefile Enhancements: Introduced several new Makefile targets to streamline code generation, API validation, building, testing, and cleaning processes for local development and CI.
  • Dependency Updates: Updated various Go module dependencies in go.mod and go.sum to their latest versions, including testing frameworks and Kubernetes code generation tools.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Ignored Files
  • Ignored by pattern: .github/workflows/** (2)
    • .github/workflows/api-compatibility.yaml
    • .github/workflows/codegen-check.yaml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a CI check to validate code generation, along with supporting Makefile targets, scripts, and documentation. The changes are well-structured and improve the development workflow by automating validation.

My review includes suggestions to improve the new scripts and Makefile for robustness and maintainability. Specifically, I've pointed out a redundant and inefficient command in the verification script, suggested turning soft warnings into hard errors for more reliable CI feedback, and recommended adding a standard help target to the Makefile. I've also noted some minor stylistic issues like missing newlines at the end of new files.

I am having trouble creating individual review comments. Click here to see my feedback.

hack/verify-api-compatibility.sh (10-13)

high

This go vet command is redundant because the api-lint target in the Makefile already performs this check. Additionally, running go vet on individual files with find ... -exec is less effective than go vet ./... on a package, as the latter can perform more comprehensive cross-file analysis.

To avoid duplication and use the more effective command, please remove this block from the script. The api-lint target should be the single source for running go vet.

hack/verify-api-compatibility.sh (21-32)

high

The checks for required files (doc.go, register.go, zz_generated.deepcopy.go) only print a warning. In a CI environment, warnings are often overlooked. Since these files are essential for a valid API definition, their absence should result in a hard failure.

Please change these checks to print an error message to stderr and exit with a non-zero status code to ensure the CI job fails correctly.

For example:

if [ ! -f "$api_dir/doc.go" ]; then
    echo "Error: Missing doc.go in $api_name/$version" >&2
    exit 1
fi

This should be applied to all three file existence checks.

CI.md (109)

medium

The file is missing a newline character at the end. It's a common convention to end files with a newline, and some tools might flag this as an issue.

- Ensure all imports are correct

Makefile (1)

medium

The .PHONY target help is declared but not defined. It's a common and good practice to provide a help target in a Makefile to list available commands and their purpose. This improves discoverability and usability for developers.

Here's an example of a simple help target you could add:

help:
	@echo "Usage: make [target]"
	@echo
	@echo "Targets:"
	@echo "  update-codegen  - Update generated code"
	@echo "  verify-codegen  - Verify generated code is up to date"
	@echo "  api-lint        - Run API linting"
	@echo "  api-compat      - Check API compatibility"
	@echo "  build           - Build all packages"
	@echo "  test            - Run tests"
	@echo "  clean           - Clean build artifacts"

Makefile (33)

medium

The file is missing a newline character at the end. It's a common convention to end files with a newline.

	rm -rf _tmp/ bin/

hack/verify-api-compatibility.sh (36)

medium

The file is missing a newline character at the end. It's a common convention to end files with a newline.

echo "API compatibility check completed"

go.sum Outdated
github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4=
github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
github.com/onsi/ginkgo/v2 v2.23.4 h1:ktYTpKJAVZnDT4VjxSbiBenUjmlL/5QkBEocaWXiQus=
github.com/onsi/ginkgo/v2 v2.23.4/go.mod h1:Bt66ApGPBFzHyR+JO10Zbt0Gsp4uWxu5mIOTusL46e8=
Copy link
Member

Choose a reason for hiding this comment

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

this is synced from volcano core repo

Copy link
Member Author

Choose a reason for hiding this comment

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

ok keep that in mind, but thought it would be great to update this or should we update this into volcano core too?

- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- run: ./hack/verify-codegen.sh
Copy link
Member

Choose a reason for hiding this comment

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

we have a gen check workflow in volcano-sh/volcano

I donot mind addong one in apis repo

@katara-Jayprakash
Copy link
Member Author

/cc @hzxuzhonghu i think we are ready for new review sir!

- name: Install crdify
run: go install sigs.k8s.io/crdify@latest

- name: Validate API structure
Copy link
Member

Choose a reason for hiding this comment

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

we donot need this verify here

Copy link
Member Author

@katara-Jayprakash katara-Jayprakash Jan 26, 2026

Choose a reason for hiding this comment

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

/cc @hzxuzhonghu fixed in next commit sir! thanx

Signed-off-by: katara-Jayprakash <[email protected]>
continue-on-error: true

- name: Install crdify
run: go install sigs.k8s.io/crdify@latest
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure what you are doing here?

Copy link
Member Author

Choose a reason for hiding this comment

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

this one, ya lemme clarify this is additional requirement ask by @JesseStutler in issue section,
Use tools like https://github.com/kubernetes-sigs/kube-api-linter and https://github.com/kubernetes-sigs/crdify to check API changes. API changes must be compatible, and certain fields must follow specified rules so i endedup adding them too, @hzxuzhonghu

Copy link
Member

Choose a reason for hiding this comment

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

You just install this tool without calling it

Copy link
Member Author

Choose a reason for hiding this comment

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

we got two things, remove the whole tool or add the tool , i choose to keep it and use it in codebase in next commit!

go.mod Outdated
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/gnostic-models v0.7.0 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/pprof v0.0.0-20250607225305-033d6d78b36a // indirect
Copy link
Member

Choose a reason for hiding this comment

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

donot change the go mod, it is synced from volcano-sh/volcano repo

Copy link
Member Author

Choose a reason for hiding this comment

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

@hzxuzhonghu fixed sir! ready for final review!

run: go install sigs.k8s.io/crdify@latest

- name: Fetch base branch for comparison
run: git fetch origin ${{ github.base_ref }} --depth=1
Copy link
Member

Choose a reason for hiding this comment

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

?? what does this do

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, so the thing i am trying to catch breaking API changes (removed fields, changed types,) before merge by installing crdify tool. If we prefer manual API review, I can remove crdify and keep only the basic checks like gofmt

Copy link
Member Author

Choose a reason for hiding this comment

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

the CI runner only has PR code. It needs master to compare against so i am fetching it and comparing it with master

Copy link
Member

Choose a reason for hiding this comment

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

I would recommend removing this workflow, all the code are generated, ans synced from volcano repo. It is too late to check compatability here.

Copy link
Member Author

Choose a reason for hiding this comment

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

ahh make sense, this workflow was suggest by jesse sir, so i'm doing it.

Makefile Outdated
verify-codegen:
./hack/verify-codegen.sh

api-lint:
Copy link
Member

Choose a reason for hiding this comment

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

remove

Copy link
Member Author

Choose a reason for hiding this comment

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

done,

Makefile Outdated
Comment on lines 11 to 14
crd-gen:
@echo "Validating API structure with crdify..."
go install sigs.k8s.io/crdify@latest
~/go/bin/crdify --help || echo "crdify installed"
Copy link
Member

Choose a reason for hiding this comment

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

remove

Copy link
Member Author

Choose a reason for hiding this comment

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

done sir

Signed-off-by: katara-Jayprakash <[email protected]>
Signed-off-by: katara-Jayprakash <[email protected]>
Signed-off-by: katara-Jayprakash <[email protected]>
Copy link
Member

@hzxuzhonghu hzxuzhonghu left a comment

Choose a reason for hiding this comment

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

/lgtm

@volcano-sh-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: hzxuzhonghu
Once this PR has been reviewed and has the lgtm label, please assign thor-wl for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@katara-Jayprakash
Copy link
Member Author

@JesseStutler i think we can merge this sir! thanx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a CI check to validate code generation

3 participants