Skip to content
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

Add consistency check for deepcopy generated files #1127

Merged
merged 5 commits into from
Jun 2, 2023

Conversation

varungup90
Copy link
Contributor

@varungup90 varungup90 commented May 30, 2023

Why are these changes needed?

Checks consistency for deepcopy generated files

Related issue number

Closes #1111

Checks

  • I've made sure the tests are passing.
  • Testing Strategy
    • Unit tests
    • Manual tests
    • This PR is not tested :(

@kevin85421
Copy link
Member

cc @Yicheng-Lu-llll would you mind reviewing this PR?

@Yicheng-Lu-llll
Copy link
Contributor

Yicheng-Lu-llll commented Jun 1, 2023

LGTM!

Also manually test it:

git clone https://github.com/varungup90/kuberay.git
cd kuberay
git checkout add-generated-files-check
cd ray-operator/


# do nothing to zz_generated.deepcopy.go
./hack/verify-generated-files.sh

#root@ip-172-31-8-217:/home/ubuntu/workspace/review/kuberay/ray-operator# ./hack/verify-generated-files.sh
#/home/ubuntu/workspace/review/kuberay/ray-operator/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" #paths="./..."
#diffing ./hack/../apis against freshly generated deepcopy files
#./hack/../apis up to date.


# manually change something to zz_generated.deepcopy.go
./hack/verify-generated-files.sh

#root@ip-172-31-8-217:/home/ubuntu/workspace/review/kuberay/ray-operator# ./hack/verify-generated-files.sh
#/home/ubuntu/workspace/review/kuberay/ray-operator/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" #paths="./..."
#diffing ./hack/../apis against freshly generated deepcopy files
#diff -Naupr ./hack/../apis/ray/v1alpha1/zz_generated.deepcopy.go #./hack/../_tmp/apis/ray/v1alpha1/zz_generated.deepcopy.go
#--- ./hack/../apis/ray/v1alpha1/zz_generated.deepcopy.go        2023-06-01 15:04:41.326004561 +0000
#+++ ./hack/../_tmp/apis/ray/v1alpha1/zz_generated.deepcopy.go   2023-06-01 15:04:37.166101782 +0000
#@@ -6,7 +6,7 @@
# package v1alpha1
 
# import (
#-       "k8s.io/api/core/v1"
#+       v1 "k8s.io/api/core/v1"
#        runtime "k8s.io/apimachinery/pkg/runtime"
# )
 
#./hack/../apis is out of date. Please run make generate

@@ -30,6 +30,10 @@ jobs:
- name: Verify Codegen
working-directory: ./ray-operator
run: ./hack/verify-codegen.sh

- name: Verify Generated Files
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a nit-picky comment, we can have a better name here.

-Verify Generated Files: showing it is used to verify the aforementioned runtime.Object interface generated by kubebuilder.

-Verify Codegen: showing it is used to verify things like clientset, lister, informer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I got the idea from Kubernetes repo (https://github.com/kubernetes/kubernetes/blob/v1.22.1/hack/verify-generated-files.sh). Please suggest better alternatives.

@kevin85421
Copy link
Member

There seems to be a conflict between "Verify Generated Files" and "Go-build-and-test / Lint (pull_request)". The linter expects v1 "k8s.io/api/core/v1" in zz_generated.deepcopy.go, but the "Verify Generated Files" step expects "k8s.io/api/core/v1". Perhaps we need to fix the linter to align with the expected format.

@varungup90
Copy link
Contributor Author

There seems to be a conflict between "Verify Generated Files" and "Go-build-and-test / Lint (pull_request)". The linter expects v1 "k8s.io/api/core/v1" in zz_generated.deepcopy.go, but the "Verify Generated Files" step expects "k8s.io/api/core/v1". Perhaps we need to fix the linter to align with the expected format.

Updated test-job.yaml file where goimports ignores zz_generated.deepcopy.go file. Verified it locally using github action act -W .github/workflows/test-job.yaml.

Copy link
Member

@kevin85421 kevin85421 left a comment

Choose a reason for hiding this comment

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

LGTM.

To summarize this PR,

@kevin85421 kevin85421 merged commit 70ef243 into ray-project:master Jun 2, 2023
19 checks passed
lowang-bh pushed a commit to lowang-bh/kuberay that referenced this pull request Sep 24, 2023
Add consistency check for deepcopy generated files
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.

[Bug][CI] Add tests to ensure that the zz_generated.deepcopy.go is up-to-date.
3 participants