From 543a2bb2c50d4e1ada92c7813f3c107bd1d0224d Mon Sep 17 00:00:00 2001 From: Marco Ebert Date: Mon, 29 Jan 2024 23:03:53 +0100 Subject: [PATCH] CI: Rework docs generation. --- .github/workflows/ci.yaml | 19 +++++++++++-------- .gitignore | 1 - MANUAL_RELEASE.md | 10 ++++------ magefiles/steps/helm.go | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7d70e7deb..4282b91aa 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -216,16 +216,19 @@ jobs: - name: Set up Helm Chart Testing uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 # v2.6.1 - - name: Run helm-docs + - name: Set up Helm Docs + uses: gabe565/setup-helm-docs-action@79a4cfe8dc7ae51c1113e3f3a1ae45e601d0c963 # v1.0.3 + + - name: Generate docs run: | - GOBIN=$PWD GO111MODULE=on go install github.com/norwoodj/helm-docs/cmd/helm-docs@v1.11.0 - ./helm-docs --chart-search-root=${GITHUB_WORKSPACE}/charts - DIFF=$(git diff ${GITHUB_WORKSPACE}/charts/ingress-nginx/README.md) - if [ ! -z "$DIFF" ]; then - echo "Please use helm-docs in your clone, of your fork, of the project, and commit a updated README.md for the chart. https://github.com/kubernetes/ingress-nginx/blob/main/RELEASE.md#d-edit-the-valuesyaml-and-run-helm-docs" + helm-docs --chart-search-root charts + + if ! git diff --exit-code charts/ingress-nginx/README.md + then + echo "Please use helm-docs in your fork of the project and commit an updated README.md for the chart." + echo "https://github.com/kubernetes/ingress-nginx/blob/main/MANUAL_RELEASE.md#d-edit-the-valuesyaml-and-run-helm-docs" + exit 1 fi - git diff --exit-code - rm -f ./helm-docs - name: Lint chart run: | diff --git a/.gitignore b/.gitignore index 73108f627..5eac1a800 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -helm-docs # OSX ._* .DS_Store diff --git a/MANUAL_RELEASE.md b/MANUAL_RELEASE.md index b1c1fd068..a6cd3e5da 100644 --- a/MANUAL_RELEASE.md +++ b/MANUAL_RELEASE.md @@ -231,14 +231,12 @@ Promoting the images basically means that images, that were pushed to staging co - tag - digest - - [helm-docs](https://github.com/norwoodj/helm-docs) is a tool that generates the README.md for a helm-chart automatically. In the CI pipeline workflow of github actions (/.github/workflows/ci.yaml), you can see how helm-docs is used. But the CI pipeline is not designed to make commits back into the project. So we need to run helm-docs manually, and check in the resulting autogenerated README.md at the path /charts/ingress-nginx/README.md + - [helm-docs](https://github.com/norwoodj/helm-docs) is a tool that generates the README.md for a Helm chart automatically. In the CI pipeline workflow of GitHub actions (.github/workflows/ci.yaml), you can see how helm-docs is used. The CI pipeline is not designed to make commits back into the project, so we need to run helm-docs manually and commit the resulting generated README.md. You can obtain a recent version of the helm-docs binary here: https://github.com/norwoodj/helm-docs/releases. ``` - GOBIN=$PWD GO111MODULE=on go install github.com/norwoodj/helm-docs/cmd/helm-docs@v1.11.0 - ./helm-docs --chart-search-root=${GITHUB_WORKSPACE}/charts - git diff --exit-code - rm -f ./helm-docs + helm-docs --chart-search-root charts + git diff charts/ingress-nginx/README.md ``` - Watchout for mistakes like leaving the helm-docs executable in your clone workspace or not checking the new README.md manually etc. + Take care of not leaving the helm-docs executable in your clone workspace or not committing the new README.md. ### e. Edit the static manifests diff --git a/magefiles/steps/helm.go b/magefiles/steps/helm.go index 245f5e1c0..3019ab225 100644 --- a/magefiles/steps/helm.go +++ b/magefiles/steps/helm.go @@ -170,7 +170,7 @@ func runHelmDocs() error { if err != nil { return err } - err = sh.RunV("helm-docs", "--chart-search-root=${PWD}/charts") + err = sh.RunV("helm-docs", "--chart-search-root", "${PWD}/charts") if err != nil { return err } @@ -181,7 +181,7 @@ func installHelmDocs() error { utils.Info("HELM Install HelmDocs") g0 := sh.RunCmd("go") - err := g0("install", "github.com/norwoodj/helm-docs/cmd/helm-docs@v1.11.0") + err := g0("install", "github.com/norwoodj/helm-docs/cmd/helm-docs@v1.11.3") if err != nil { return err }