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

[Feature] Sync for manifests and helm chart #564

Merged
merged 14 commits into from
Sep 15, 2022
26 changes: 26 additions & 0 deletions .github/workflows/consistency-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,29 @@ jobs:
with:
script: |
core.setFailed('Please run \"make manifests\" to synchronize CRD!')
# Check consistency between CRD YAML files in ray-operator/config/crd/bases
# and in helm-chart/kuberay-operator/crds
helm-chart-verify-crd:
needs: ray-operator-verify-crd
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Update CRD YAML files
run: |
rm -r helm-chart/kuberay-operator/crds/
cp -r ray-operator/config/crd/bases/ helm-chart/kuberay-operator/crds/
- name: Verify Changed files
id: verify-changed-files
uses: tj-actions/[email protected]
with:
files: |
./helm-chart/kuberay-operator/crds/*.yaml
- name: Check changed files
if: steps.verify-changed-files.outputs.files_changed == 'true'
uses: actions/github-script@v3
with:
script: |
core.setFailed('Please run \"make sync\" to synchronize CRDs!')
24 changes: 23 additions & 1 deletion ray-operator/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,26 @@ IMG=kuberay/operator:nightly make deploy
We have [chart lint tests](https://github.com/ray-project/kuberay/blob/master/.github/workflows/helm-lint.yaml) with Helm v3.4.1 and Helm v3.9.4 on GitHub Actions. We also provide a script to execute the lint tests on your laptop. If you cannot reproduce the errors on GitHub Actions, the possible reason is the different version of Helm. Issue [#537](https://github.com/ray-project/kuberay/issues/537) is an example that some errors only happen in old helm versions.

* Step1: Install `ct` (chart-testing) and related dependencies. See https://github.com/helm/chart-testing for more details.
* Step2: `./helm-chart/script/chart-test.sh`
* Step2: `./helm-chart/script/chart-test.sh`

### Consistency check

We have several [consistency checks](https://github.com/ray-project/kuberay/blob/master/.github/workflows/consistency-check.yaml) on GitHub Actions. There are several files which need synchronization.

1. `ray-operator/apis/ray/v1alpha1/*_types.go` should be synchronized with the CRD YAML files (`ray-operator/config/crd/bases/`)
2. `ray-operator/apis/ray/v1alpha1/*_types.go` should be synchronized with generated API (`ray-operator/pkg/client`)
3. CRD YAML files in `ray-operator/config/crd/bases/` and `helm-chart/kuberay-operator/crds/` should be the same.

```bash
# Consistency 1:
make manifests

# Consistency 2:
./hack/update-codegen.sh

# Consistency 3:
make helm

# Synchronize 1, 2, 3 in one command
make sync
```
5 changes: 4 additions & 1 deletion ray-operator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

helm: manifests kustomize ## Sync the CRDs into the Helm chart
$(KUSTOMIZE) build config/crd > ../helm-chart/kuberay-operator/crds/crd.yaml
rm -r ../helm-chart/kuberay-operator/crds/
cp -r config/crd/bases/ ../helm-chart/kuberay-operator/crds/

fmt: ## Run go fmt against code.
go fmt ./...
Expand All @@ -64,6 +65,8 @@ test: manifests generate fmt vet ## Run tests.
test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.7.2/hack/setup-envtest.sh
source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); go test ./... -coverprofile cover.out

sync: helm
./hack/update-codegen.sh
##@ Build

build: generate fmt vet ## Build manager binary.
Expand Down