Skip to content

feat: outline-1.2.0 #74

feat: outline-1.2.0

feat: outline-1.2.0 #74

Workflow file for this run

name: Charts Validation
on:
pull_request:
paths:
- 'charts/**'
jobs:
lint:
name: Charts Validation
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Fetch history
run: git fetch --prune --unshallow
- name: Run Helm lint
uses: helm/chart-testing-action@v2.6.1
with:
command: lint
config: .github/verify-config.yaml
- name: Set up Node.js (required for readme-generator)
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Install readme-generator-for-helm
run: npm install -g @bitnami/readme-generator-for-helm
- name: Check Chart Version and Run README Generator
shell: bash
run: |
errors=false
# Loop through modified chart directories
for dir in $(git diff --name-only origin/main | grep -o 'charts/[^/]*/' | sort -u); do
chart_file="${dir}Chart.yaml"
if [ -f "$chart_file" ]; then
# Check if the chart file exists in the main branch
if git show origin/main:"$chart_file" > /dev/null 2>&1; then
# Fetch current and main branch versions
current_version=$(yq eval '.version' "$chart_file")
main_version=$(git show origin/main:"$chart_file" | yq eval '.version' -)
# Check if the version was incremented correctly
if [ "$current_version" = "$main_version" ]; then
echo "::error::❌ Version in $chart_file needs to be updated. The current version in main is $main_version."
echo "Please increment the version in $chart_file by updating the 'version' field to the next semantic version (e.g., 1.0.1 -> 1.0.2)."
errors=true
else
# Extract major, minor, patch for validation
IFS='.' read -r major minor patch <<< "$main_version"
next_patch_version="$major.$minor.$((patch + 1))"
next_minor_version="$major.$((minor + 1)).0"
# Validate the updated version
if [ "$current_version" = "$next_patch_version" ]; then
echo "✅ Version in $chart_file is correctly incremented to $current_version (next patch version)."
elif [ "$current_version" = "$next_minor_version" ]; then
echo "✅ Version in $chart_file is correctly incremented to $current_version (next minor version)."
else
echo "::error::❌ Version in $chart_file is not a valid next version. The current version in main is $main_version."
echo "Expected the next version to be either $next_patch_version (patch increment) or $next_minor_version (minor increment)."
echo "Please update the version in $chart_file to one of these expected values."
errors=true
fi
fi
else
# Log that this is a new chart and no version comparison is needed
echo "✅ $chart_file is a new chart. No version comparison needed."
fi
echo -e "\n" # Add an empty line after version check for readability
fi
# Check and generate README
if [ -f "${dir}values.yaml" ]; then
echo "🔄 Generating README for $dir"
if ! readme-generator -v "${dir}values.yaml" -r "${dir}README.md"; then
echo "::error::❌ README.md for $dir is outdated or an error occurred while generating it."
echo ""
echo "Please update README.md by installing readme-generator-for-helm and running:"
echo "npm install -g @bitnami/readme-generator-for-helm"
echo "readme-generator -v ${dir}values.yaml -r ${dir}README.md"
errors=true
else
echo "✅ README generation for $dir is in order."
fi
echo ""
fi
done
# Fail the job if any errors were detected
if [ "$errors" = true ]; then
echo "❌ Some checks failed. Please address the issues above."
exit 1
else
echo "✅ All validation checks passed."
fi