implemented a CI check to validate code generation#225
implemented a CI check to validate code generation#225katara-Jayprakash wants to merge 10 commits intovolcano-sh:masterfrom
Conversation
Summary of ChangesHello @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 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
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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)
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)
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
fiThis should be applied to all three file existence checks.
CI.md (109)
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)
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)
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)
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"
70d2803 to
b2c58ca
Compare
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= |
There was a problem hiding this comment.
this is synced from volcano core repo
There was a problem hiding this comment.
ok keep that in mind, but thought it would be great to update this or should we update this into volcano core too?
.github/workflows/codegen-check.yaml
Outdated
| - uses: actions/setup-go@v5 | ||
| with: | ||
| go-version-file: 'go.mod' | ||
| - run: ./hack/verify-codegen.sh |
There was a problem hiding this comment.
we have a gen check workflow in volcano-sh/volcano
I donot mind addong one in apis repo
Signed-off-by: katara-Jayprakash <[email protected]>
Signed-off-by: katara-Jayprakash <[email protected]>
Signed-off-by: katara-Jayprakash <[email protected]>
Signed-off-by: katara-Jayprakash <[email protected]>
cda899a to
c737989
Compare
Signed-off-by: katara-Jayprakash <[email protected]>
|
/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 |
There was a problem hiding this comment.
we donot need this verify here
There was a problem hiding this comment.
/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 |
There was a problem hiding this comment.
I am not sure what you are doing here?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
You just install this tool without calling it
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
donot change the go mod, it is synced from volcano-sh/volcano repo
There was a problem hiding this comment.
@hzxuzhonghu fixed sir! ready for final review!
Signed-off-by: katara-Jayprakash <[email protected]>
| run: go install sigs.k8s.io/crdify@latest | ||
|
|
||
| - name: Fetch base branch for comparison | ||
| run: git fetch origin ${{ github.base_ref }} --depth=1 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
the CI runner only has PR code. It needs master to compare against so i am fetching it and comparing it with master
There was a problem hiding this comment.
I would recommend removing this workflow, all the code are generated, ans synced from volcano repo. It is too late to check compatability here.
There was a problem hiding this comment.
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: |
Makefile
Outdated
| crd-gen: | ||
| @echo "Validating API structure with crdify..." | ||
| go install sigs.k8s.io/crdify@latest | ||
| ~/go/bin/crdify --help || echo "crdify installed" |
Signed-off-by: katara-Jayprakash <[email protected]>
Signed-off-by: katara-Jayprakash <[email protected]>
Signed-off-by: katara-Jayprakash <[email protected]>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: hzxuzhonghu The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
@JesseStutler i think we can merge this sir! thanx |
fix #198