Skip to content

Commit

Permalink
ci: introduce workflow for helm documentation validation (#454)
Browse files Browse the repository at this point in the history
Signed-off-by: odubajDT <ondrej.dubaj@dynatrace.com>
Signed-off-by: odubajDT <93584209+odubajDT@users.noreply.github.com>
Co-authored-by: Giovanni Liva <giovanni.liva@dynatrace.com>
  • Loading branch information
odubajDT and thisthat authored Apr 24, 2023
1 parent fff12a8 commit d389a19
Show file tree
Hide file tree
Showing 6 changed files with 193 additions and 48 deletions.
30 changes: 30 additions & 0 deletions .github/scripts/generate-helm-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# Readme generator for OpenFeature Operator Helm Chart
#
# This script will install the readme generator if it's not installed already
# and then it will generate the README.md file from the local Helm values
#
# Dependencies:
# Node >=16

# renovate: datasource=github-releases depName=bitnami-labs/readme-generator-for-helm
GENERATOR_VERSION="2.5.0"

echo "Checking if readme generator is installed already..."
if [[ $(npm list -g | grep -c "readme-generator-for-helm@${GENERATOR_VERSION}") -eq 0 ]]; then
echo "Readme Generator v${GENERATOR_VERSION} not installed, installing now..."
git clone https://github.com/bitnami-labs/readme-generator-for-helm.git
cd ./readme-generator-for-helm || exit
git checkout ${GENERATOR_VERSION}
npm ci
cd ..
npm install -g ./readme-generator-for-helm
else
echo "Readme Generator is already installed, continuing..."
fi

echo "Generating readme now..."
readme-generator --config $(pwd)/chart/open-feature-operator/helm-docs-config.json --values=./chart/open-feature-operator/values.yaml --readme=./chart/open-feature-operator/README.md

# Please be aware, the readme file needs to exist and needs to have a Parameters section, as only this section will be re-generated
51 changes: 51 additions & 0 deletions .github/workflows/validate-helm-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Validate Helm Docs
on:
pull_request:
branches:
- 'main'
paths:
- 'chart/**'
defaults:
run:
shell: bash
jobs:
check-helm-docs:
name: Check helm documentation values
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Set up Node
uses: actions/setup-node@v3.6.0
with:
node-version: 16

- name: Generate helm charts
env:
RELEASE_REGISTRY: ghcr.io/openfeature
run: make helm-package

- name: Install readme generator
run: |
git clone https://github.com/bitnami-labs/readme-generator-for-helm.git
cd ./readme-generator-for-helm
npm ci
npm install --location=global ./
cd ..
- name: Check Helm doc up to date
run: |
cd ./chart/open-feature-operator/
cp ./README.md ./README-old.md
readme-generator --config $(pwd)/helm-docs-config.json --values=./values.yaml --readme=./README.md
if ! cmp --quiet ./README-old.md ./README.md; then
echo "The Helm values have changes that are not reflected in the readme. Please use ./.github/scripts/generate-helm-docs.sh to re-generate the docs."
echo ""
echo "=========== Diff ==========="
diff -u ./README-old.md ./README.md
exit 1
else
echo ""
echo "Helm values documentation is correct!"
fi
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ The OpenFeature Operator allows you to expose feature flags to your applications

<h2 align="center"><a href="https://killercoda.com/open-feature/scenario/openfeature-operator-demo" target="_blank">Try the OpenFeature Operator in the Killercoda Playground (in browser)</a></h2>

## Changelog

See [CHANGELOG.md](https://github.com/open-feature/open-feature-operator/blob/main/CHANGELOG.md)

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to the OpenFeature project.
Expand Down
Loading

0 comments on commit d389a19

Please sign in to comment.