From 01de5a6730031a7f4cb75bbb5f10a367fa0f42b8 Mon Sep 17 00:00:00 2001 From: Yi Chen Date: Thu, 17 Apr 2025 07:07:05 +0800 Subject: [PATCH 1/2] [CI][HELM] Use chart-testing to install Helm charts Signed-off-by: Yi Chen --- .github/workflows/helm-lint.yaml | 88 ----------- .github/workflows/helm.yaml | 138 ++++++++++++++++++ helm-chart/kuberay-apiserver/.helmignore | 20 ++- .../kuberay-apiserver/ci/ci-values.yaml | 10 ++ helm-chart/kuberay-operator/.helmignore | 21 ++- helm-chart/kuberay-operator/ci/ci-values.yaml | 4 + helm-chart/ray-cluster/.helmignore | 21 ++- helm-chart/ray-cluster/ci/ci-values.yaml | 3 + 8 files changed, 211 insertions(+), 94 deletions(-) delete mode 100644 .github/workflows/helm-lint.yaml create mode 100644 .github/workflows/helm.yaml create mode 100644 helm-chart/kuberay-apiserver/ci/ci-values.yaml create mode 100644 helm-chart/kuberay-operator/ci/ci-values.yaml create mode 100644 helm-chart/ray-cluster/ci/ci-values.yaml diff --git a/.github/workflows/helm-lint.yaml b/.github/workflows/helm-lint.yaml deleted file mode 100644 index 67293bb9343..00000000000 --- a/.github/workflows/helm-lint.yaml +++ /dev/null @@ -1,88 +0,0 @@ -name: Lint and Test Charts - -on: - push: - branches: - - master - - release-* - pull_request: - branches: - - master - - release-* - -jobs: - lint-test-helm-3-4: - runs-on: ubuntu-22.04 - steps: - - name: Checkout Code - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Set up Helm - uses: azure/setup-helm@v3.3 - with: - version: v3.4.1 - - - uses: actions/setup-python@v4 - with: - python-version: 3.7 - - - name: Install Helm unittest plugin - run: helm plugin install https://github.com/helm-unittest/helm-unittest.git --version 0.8.1 - - - name: Run Helm unittest (kuberay-apiserver) - run: helm unittest helm-chart/kuberay-apiserver --file "tests/**/*_test.yaml" --strict --debug - - - name: Run Helm unittest (kuberay-operator) - run: helm unittest helm-chart/kuberay-operator --file "tests/**/*_test.yaml" --strict --debug - - - name: Run Helm unittest (ray-cluster) - run: helm unittest helm-chart/ray-cluster --file "tests/**/*_test.yaml" --strict --debug - - - name: Set up chart-testing - uses: helm/chart-testing-action@v2.3.0 - - - name: Run chart-testing (lint) - # Run 'helm lint', version checking, YAML schema validation on 'Chart.yaml', - # YAML linting on 'Chart.yaml' and 'values.yaml', and maintainer. - # [Doc]: https://github.com/helm/chart-testing/blob/main/doc/ct_lint.md - run: ct lint --all --chart-dirs helm-chart/ --validate-maintainers=false - - lint-test-helm-3-9: - runs-on: ubuntu-22.04 - steps: - - name: Checkout Code - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Set up Helm - uses: azure/setup-helm@v3.3 - with: - version: v3.9.4 - - - uses: actions/setup-python@v4 - with: - python-version: 3.7 - - - name: Install Helm unittest plugin - run: helm plugin install https://github.com/helm-unittest/helm-unittest.git --version 0.8.1 - - - name: Run Helm unittest (kuberay-apiserver) - run: helm unittest helm-chart/kuberay-apiserver --file "tests/**/*_test.yaml" --strict --debug - - - name: Run Helm unittest (kuberay-operator) - run: helm unittest helm-chart/kuberay-operator --file "tests/**/*_test.yaml" --strict --debug - - - name: Run Helm unittest (ray-cluster) - run: helm unittest helm-chart/ray-cluster --file "tests/**/*_test.yaml" --strict --debug - - - name: Set up chart-testing - uses: helm/chart-testing-action@v2.3.0 - - - name: Run chart-testing (lint) - # Run 'helm lint', version checking, YAML schema validation on 'Chart.yaml', - # YAML linting on 'Chart.yaml' and 'values.yaml', and maintainer. - # [Doc]: https://github.com/helm/chart-testing/blob/main/doc/ct_lint.md - run: ct lint --all --chart-dirs helm-chart/ --validate-maintainers=false diff --git a/.github/workflows/helm.yaml b/.github/workflows/helm.yaml new file mode 100644 index 00000000000..6593892f7a5 --- /dev/null +++ b/.github/workflows/helm.yaml @@ -0,0 +1,138 @@ +name: Helm + +on: + push: + branches: + - master + - release-* + pull_request: + branches: + - master + - release-* + +env: + CHART_DIR: helm-chart + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.actor }} + cancel-in-progress: true + +jobs: + lint-test: + name: Lint and Test + + runs-on: ubuntu-24.04 + + strategy: + matrix: + chart: + - kuberay-operator + - kuberay-apiserver + - ray-cluster + + steps: + - name: Determine branch name + id: get_branch + run: | + BRANCH="" + if [ "${{ github.event_name }}" == "push" ]; then + BRANCH=${{ github.ref_name }} + elif [ "${{ github.event_name }}" == "pull_request" ]; then + BRANCH=${{ github.base_ref }} + fi + echo "BRANCH=$BRANCH" >> "$GITHUB_OUTPUT" + + - name: Checkout Code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Helm + uses: azure/setup-helm@v4.3.0 + with: + version: v3.17.3 + + - uses: actions/setup-python@v5.3.0 + with: + python-version: 3.13 + + - name: Set up chart-testing + uses: helm/chart-testing-action@v2.7.0 + + - name: Run chart-testing (list-changed) + id: list-changed + env: + BRANCH: ${{ steps.get_branch.outputs.BRANCH }} + run: | + changed=$(ct list-changed --target-branch $BRANCH) + if [[ -n "$changed" ]]; then + echo "changed=true" >> "$GITHUB_OUTPUT" + fi + + - name: Install Helm unittest plugin + # if: steps.list-changed.outputs.changed == 'true' + run: helm plugin install https://github.com/helm-unittest/helm-unittest.git --version 0.8.1 + + - name: Run Helm unittest + # if: steps.list-changed.outputs.changed == 'true' + run: helm unittest ${{ env.CHART_DIR }}/${{ matrix.chart }} --file "tests/**/*_test.yaml" --strict --debug + + - name: Run chart-testing (lint) + # if: steps.list-changed.outputs.changed == 'true' + env: + BRANCH: ${{ steps.get_branch.outputs.BRANCH }} + run: | + # Run 'helm lint', version checking, YAML schema validation on 'Chart.yaml', + # YAML linting on 'Chart.yaml' and 'values.yaml', and maintainer. + # [Doc]: https://github.com/helm/chart-testing/blob/main/doc/ct_lint.md + ct lint --charts ${{ env.CHART_DIR }}/${{ matrix.chart }} --validate-maintainers=false + + - name: Create kind cluster + # if: steps.list-changed.outputs.changed == 'true' + uses: helm/kind-action@v1.12.0 + with: + cluster_name: kind + + - name: Build Docker image (kuberay-operator) + if: matrix.chart == 'kuberay-operator' + run: | + cd ray-operator && make docker-image -e IMG=kuberay/operator:local + + - name: Build Docker image (kuberay-apiserver) + if: matrix.chart == 'kuberay-apiserver' + run: | + cd apiserver && make docker-image -e IMG=kuberay/apiserver:local + + - name: Build Docker image (security-proxy) + if: matrix.chart == 'kuberay-apiserver' + run: | + cd experimental && make docker-image -e IMG=kuberay/security-proxy:local + + - name: Load image to kind cluster (kuberay-operator) + if: matrix.chart == 'kuberay-operator' + run: | + kind load docker-image kuberay/operator:local + + - name: Load image to kind cluster (kuberay-apiserver) + if: matrix.chart == 'kuberay-apiserver' + run: | + kind load docker-image kuberay/apiserver:local + + - name: Load image to kind cluster (security-proxy) + if: matrix.chart == 'kuberay-apiserver' + run: | + kind load docker-image kuberay/security-proxy:local + + - name: Install Custom Resource Definitions to kind cluster + if: matrix.chart == 'ray-cluster' + working-directory: helm-chart/kuberay-operator + run: kubectl create -f crds + + - name: Run chart-testing + # if: steps.list-changed.outputs.changed == 'true' + env: + BRANCH: ${{ steps.get_branch.outputs.BRANCH }} + run: | + # Run 'helm install', 'helm test', and optionally 'helm upgrade' on specified charts. + # [Doc]: https://github.com/helm/chart-testing/blob/main/doc/ct_install.md + ct install --charts ${{ env.CHART_DIR}}/${{ matrix.chart }} diff --git a/helm-chart/kuberay-apiserver/.helmignore b/helm-chart/kuberay-apiserver/.helmignore index 0e8a0eb36f4..b757724f3e8 100644 --- a/helm-chart/kuberay-apiserver/.helmignore +++ b/helm-chart/kuberay-apiserver/.helmignore @@ -1,7 +1,10 @@ # Patterns to ignore when building packages. # This supports shell glob matching, relative path matching, and # negation (prefixed with !). Only one pattern per line. -.DS_Store + +ci/ +.helmignore + # Common VCS dirs .git/ .gitignore @@ -10,14 +13,27 @@ .hg/ .hgignore .svn/ + # Common backup files *.swp *.bak *.tmp *.orig *~ + # Various IDEs +*.tmproj .project .idea/ -*.tmproj .vscode/ + +# helm-unittest +tests +.debug +__snapshot__ + +# helm-docs +README.md.gotmpl + +# MacOS +.DS_Store diff --git a/helm-chart/kuberay-apiserver/ci/ci-values.yaml b/helm-chart/kuberay-apiserver/ci/ci-values.yaml new file mode 100644 index 00000000000..36b7308e2f0 --- /dev/null +++ b/helm-chart/kuberay-apiserver/ci/ci-values.yaml @@ -0,0 +1,10 @@ +image: + repository: kuberay/apiserver + tag: local + pullPolicy: Never + +security: + proxy: + repository: kuberay/security-proxy + tag: local + pullPolicy: Never diff --git a/helm-chart/kuberay-operator/.helmignore b/helm-chart/kuberay-operator/.helmignore index 50af0317254..b757724f3e8 100644 --- a/helm-chart/kuberay-operator/.helmignore +++ b/helm-chart/kuberay-operator/.helmignore @@ -1,7 +1,10 @@ # Patterns to ignore when building packages. # This supports shell glob matching, relative path matching, and # negation (prefixed with !). Only one pattern per line. -.DS_Store + +ci/ +.helmignore + # Common VCS dirs .git/ .gitignore @@ -10,13 +13,27 @@ .hg/ .hgignore .svn/ + # Common backup files *.swp *.bak *.tmp +*.orig *~ + # Various IDEs +*.tmproj .project .idea/ -*.tmproj .vscode/ + +# helm-unittest +tests +.debug +__snapshot__ + +# helm-docs +README.md.gotmpl + +# MacOS +.DS_Store diff --git a/helm-chart/kuberay-operator/ci/ci-values.yaml b/helm-chart/kuberay-operator/ci/ci-values.yaml new file mode 100644 index 00000000000..58874b27cb6 --- /dev/null +++ b/helm-chart/kuberay-operator/ci/ci-values.yaml @@ -0,0 +1,4 @@ +image: + repository: kuberay/operator + tag: local + pullPolicy: Never diff --git a/helm-chart/ray-cluster/.helmignore b/helm-chart/ray-cluster/.helmignore index 50af0317254..b757724f3e8 100644 --- a/helm-chart/ray-cluster/.helmignore +++ b/helm-chart/ray-cluster/.helmignore @@ -1,7 +1,10 @@ # Patterns to ignore when building packages. # This supports shell glob matching, relative path matching, and # negation (prefixed with !). Only one pattern per line. -.DS_Store + +ci/ +.helmignore + # Common VCS dirs .git/ .gitignore @@ -10,13 +13,27 @@ .hg/ .hgignore .svn/ + # Common backup files *.swp *.bak *.tmp +*.orig *~ + # Various IDEs +*.tmproj .project .idea/ -*.tmproj .vscode/ + +# helm-unittest +tests +.debug +__snapshot__ + +# helm-docs +README.md.gotmpl + +# MacOS +.DS_Store diff --git a/helm-chart/ray-cluster/ci/ci-values.yaml b/helm-chart/ray-cluster/ci/ci-values.yaml new file mode 100644 index 00000000000..6708c191211 --- /dev/null +++ b/helm-chart/ray-cluster/ci/ci-values.yaml @@ -0,0 +1,3 @@ +image: + repository: rayproject/ray + tag: 2.41.0 From d07c953f8fac430f1ef396c426ac7688c56f10c2 Mon Sep 17 00:00:00 2001 From: Yi Chen Date: Fri, 18 Apr 2025 09:46:18 +0800 Subject: [PATCH 2/2] Skip lint and test when charts do not change Signed-off-by: Yi Chen --- .github/workflows/helm.yaml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/helm.yaml b/.github/workflows/helm.yaml index 6593892f7a5..38a84a73eb2 100644 --- a/.github/workflows/helm.yaml +++ b/.github/workflows/helm.yaml @@ -64,21 +64,21 @@ jobs: env: BRANCH: ${{ steps.get_branch.outputs.BRANCH }} run: | - changed=$(ct list-changed --target-branch $BRANCH) + changed=$(ct list-changed --target-branch $BRANCH --chart-dirs ${{ env.CHART_DIR }} | grep ${{ matrix.chart }}) if [[ -n "$changed" ]]; then echo "changed=true" >> "$GITHUB_OUTPUT" fi - name: Install Helm unittest plugin - # if: steps.list-changed.outputs.changed == 'true' + if: steps.list-changed.outputs.changed == 'true' run: helm plugin install https://github.com/helm-unittest/helm-unittest.git --version 0.8.1 - name: Run Helm unittest - # if: steps.list-changed.outputs.changed == 'true' + if: steps.list-changed.outputs.changed == 'true' run: helm unittest ${{ env.CHART_DIR }}/${{ matrix.chart }} --file "tests/**/*_test.yaml" --strict --debug - name: Run chart-testing (lint) - # if: steps.list-changed.outputs.changed == 'true' + if: steps.list-changed.outputs.changed == 'true' env: BRANCH: ${{ steps.get_branch.outputs.BRANCH }} run: | @@ -88,48 +88,48 @@ jobs: ct lint --charts ${{ env.CHART_DIR }}/${{ matrix.chart }} --validate-maintainers=false - name: Create kind cluster - # if: steps.list-changed.outputs.changed == 'true' + if: steps.list-changed.outputs.changed == 'true' uses: helm/kind-action@v1.12.0 with: cluster_name: kind - name: Build Docker image (kuberay-operator) - if: matrix.chart == 'kuberay-operator' + if: steps.list-changed.outputs.changed == 'true' && matrix.chart == 'kuberay-operator' run: | cd ray-operator && make docker-image -e IMG=kuberay/operator:local - name: Build Docker image (kuberay-apiserver) - if: matrix.chart == 'kuberay-apiserver' + if: steps.list-changed.outputs.changed == 'true' && matrix.chart == 'kuberay-apiserver' run: | cd apiserver && make docker-image -e IMG=kuberay/apiserver:local - name: Build Docker image (security-proxy) - if: matrix.chart == 'kuberay-apiserver' + if: steps.list-changed.outputs.changed == 'true' && matrix.chart == 'kuberay-apiserver' run: | cd experimental && make docker-image -e IMG=kuberay/security-proxy:local - name: Load image to kind cluster (kuberay-operator) - if: matrix.chart == 'kuberay-operator' + if: steps.list-changed.outputs.changed == 'true' && matrix.chart == 'kuberay-operator' run: | kind load docker-image kuberay/operator:local - name: Load image to kind cluster (kuberay-apiserver) - if: matrix.chart == 'kuberay-apiserver' + if: steps.list-changed.outputs.changed == 'true' && matrix.chart == 'kuberay-apiserver' run: | kind load docker-image kuberay/apiserver:local - name: Load image to kind cluster (security-proxy) - if: matrix.chart == 'kuberay-apiserver' + if: steps.list-changed.outputs.changed == 'true' && matrix.chart == 'kuberay-apiserver' run: | kind load docker-image kuberay/security-proxy:local - name: Install Custom Resource Definitions to kind cluster - if: matrix.chart == 'ray-cluster' + if: steps.list-changed.outputs.changed == 'true' && matrix.chart == 'ray-cluster' working-directory: helm-chart/kuberay-operator run: kubectl create -f crds - name: Run chart-testing - # if: steps.list-changed.outputs.changed == 'true' + if: steps.list-changed.outputs.changed == 'true' env: BRANCH: ${{ steps.get_branch.outputs.BRANCH }} run: |