From 45e1cdbd015650cbfcf1d86a0e2b2e0808aba85b Mon Sep 17 00:00:00 2001 From: Lucas Severo Alves Date: Tue, 14 Jun 2022 15:59:10 +0200 Subject: [PATCH] WIP: improving helm setup --- .github/ci/ct.yaml | 5 +++++ .github/workflows/helm.yaml | 44 +++++++++++++++++++++++++++++++++++++ .gitignore | 3 ++- Makefile | 15 ++++++++----- docs/contributor-guide.md | 16 ++++++++++++++ 5 files changed, 77 insertions(+), 6 deletions(-) create mode 100644 .github/ci/ct.yaml create mode 100644 .github/workflows/helm.yaml diff --git a/.github/ci/ct.yaml b/.github/ci/ct.yaml new file mode 100644 index 000000000..72cc0603c --- /dev/null +++ b/.github/ci/ct.yaml @@ -0,0 +1,5 @@ +chart-dirs: + - ./charts +helm-extra-args: "--timeout=5m" +check-version-increment: false +target-branch: master diff --git a/.github/workflows/helm.yaml b/.github/workflows/helm.yaml new file mode 100644 index 000000000..5e9d07a38 --- /dev/null +++ b/.github/workflows/helm.yaml @@ -0,0 +1,44 @@ +name: Helm + +on: + push: + branches: + - master + - release-* + paths: + - 'charts/**' + pull_request: + paths: + - 'charts/**' + +jobs: + lint-and-test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Helm + uses: azure/setup-helm@v2.1 + with: + version: v3.4.2 + + - uses: actions/setup-python@v3.1.2 + with: + python-version: 3.7 + + - name: Set up chart-testing + uses: helm/chart-testing-action@v2.2.1 + + - name: Run chart-testing (list-changed) + id: list-changed + run: | + changed=$(ct list-changed --config=.github/ci/ct.yaml) + if [[ -n "$changed" ]]; then + echo "::set-output name=changed::true" + fi + + - name: Run chart-testing (lint) + run: ct lint --config=.github/ci/ct.yaml diff --git a/.gitignore b/.gitignore index 78fcbb93f..fbc9a312c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ vendordiff.patch .idea/ *.code-workspace .vscode/ -kind \ No newline at end of file +kind +bin/ \ No newline at end of file diff --git a/Makefile b/Makefile index a76bc7935..13cec077c 100644 --- a/Makefile +++ b/Makefile @@ -135,13 +135,18 @@ ifndef HAS_GOLANGCI endif ./_output/bin/golangci-lint run -lint-chart: ensure-helm-install - helm lint ./charts/descheduler - -test-helm: ensure-helm-install - ./test/run-helm-tests.sh +# helm ensure-helm-install: ifndef HAS_HELM curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 && chmod 700 ./get_helm.sh && ./get_helm.sh endif + +lint-chart: ensure-helm-install + helm lint ./charts/descheduler + +build-helm: + helm package ./charts/descheduler --dependency-update --destination ./bin/chart + +test-helm: ensure-helm-install + ./test/run-helm-tests.sh diff --git a/docs/contributor-guide.md b/docs/contributor-guide.md index c5ddda9f9..b716d4ced 100644 --- a/docs/contributor-guide.md +++ b/docs/contributor-guide.md @@ -52,5 +52,21 @@ The helm tests runs as part of descheduler CI. But, to run it manually from the make test-helm ``` +## Build Helm Package locally + +If you made some changes in the chart, and just want to check if templating is ok, or if the chart is buildable, you can run this command to have a package built from the `./charts` directory. + +``` +make build-helm +``` + +## Lint Helm Chart locally + +To check linting of your changes in the helm chart locally you can run: + +``` +make lint-helm +``` + ### Miscellaneous See the [hack directory](https://github.com/kubernetes-sigs/descheduler/tree/master/hack) for additional tools and scripts used for developing the descheduler.