Gen3 Monthly Release 2026.02 midrcprod/staging.midrc.org 1771345370 #3626
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Lint and Test Charts | |
| on: pull_request | |
| jobs: | |
| lint-test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v2 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Helm | |
| uses: azure/setup-helm@v3 | |
| with: | |
| version: v3.10.0 | |
| - uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.9' | |
| check-latest: true | |
| # - name: Set up chart-testing | |
| # uses: helm/chart-testing-action@v2.7.0 | |
| # - name: Run chart-testing (list-changed) | |
| # id: list-changed | |
| # run: | | |
| # changed=$(ct list-changed --config ct.yaml) | |
| # if [[ -n "$changed" ]]; then | |
| # echo "changed=true >> $GITHUB_OUTPUT" | |
| # fi | |
| # - name: Run chart-testing (lint) | |
| # run: ct lint --config ct.yaml | |
| - name: Validate Helm Templates for All Charts | |
| run: | | |
| # Find all chart directories containing a Chart.yaml file | |
| find . -name 'Chart.yaml' | while read chart_yaml; do | |
| chart_dir=$(dirname "$chart_yaml") # Get the directory path of the chart | |
| values_dir="$chart_dir/values" # Assume a 'values' subdirectory for custom values files | |
| echo "Processing chart directory: $chart_dir" | |
| # Check if the values directory exists and contains any yaml files | |
| if [ -d "$values_dir" ] && [ -n "$(ls $values_dir/*.yaml 2>/dev/null)" ]; then | |
| values_args="" # Initialize the string to hold the --values arguments | |
| for values_file in $values_dir/*.yaml; do | |
| echo "Including values file $values_file" | |
| values_args+=" --values $values_file" | |
| done | |
| echo "Rendering chart $chart_dir with all values files" | |
| helm template "$chart_dir" $values_args | |
| else | |
| echo "No values directory found or it is empty, rendering chart with default values" | |
| helm template "$chart_dir" | |
| fi | |
| done | |
| - name: Lint All Charts with Custom Values Files | |
| run: | | |
| # Find all directories containing a 'Chart.yaml', which indicates a helm chart directory | |
| find . -type f -name 'Chart.yaml' | sed 's|/Chart.yaml||' | while read chart_dir; do | |
| echo "Linting charts in $chart_dir" | |
| # Check if the values directory exists | |
| if [[ -d "$chart_dir/values" ]]; then | |
| # If values directory exists, loop over each yaml file in the values directory | |
| for values_file in $chart_dir/values/*.yaml; do | |
| echo "Linting $chart_dir with values file $values_file" | |
| helm lint "$chart_dir" --values "$values_file" | |
| done | |
| else | |
| echo "No values directory found in $chart_dir, linting with default values" | |
| helm lint "$chart_dir" | |
| fi | |
| done | |
| - name: Validate All aggMDS Configurations | |
| run: | | |
| # loop through each Helm chart directory | |
| find . -name 'Chart.yaml' | while read chart_yaml; do | |
| chart_dir=$(dirname "$chart_yaml") # Get the directory path of the chart | |
| values_dir="$chart_dir/values" # Assume a 'values' subdirectory for custom values files | |
| echo "Processing chart directory: $chart_dir" | |
| # Check if the values directory exists and contains any yaml files | |
| if [ -d "$values_dir" ] && [ -n "$(ls $values_dir/values.yaml 2>/dev/null)" ]; then | |
| values_args="" # Initialize the string to hold the --values arguments | |
| for values_file in $values_dir/*.yaml; do | |
| mds_config=$(yq '.metadata.aggMdsConfig' "$values_file") | |
| if [[ -n "$mds_config" && "$mds_config" != "null" ]]; then | |
| if printf '%s' "$mds_config" | jq empty > /dev/null 2>&1; then | |
| echo "$values_file: JSON is valid" | |
| else | |
| echo "$values_file: JSON is invalid" | |
| exit 1 | |
| fi | |
| fi | |
| done | |
| fi | |
| done | |
| - name: Validate app.yaml References to Values Files | |
| run: | | |
| # Loop through each Helm chart directory | |
| find . -type f -name 'Chart.yaml' | sed 's|/Chart.yaml||' | while read chart_dir; do | |
| echo "Checking $chart_dir/templates/app.yaml for references to values files in $chart_dir/values/" | |
| # Check if the app.yaml file exists | |
| if [[ -f "$chart_dir/templates/app.yaml" ]]; then | |
| # Loop over each values file in the values directory | |
| missing_references="" | |
| for values_file in $chart_dir/values/*.yaml; do | |
| values_filename=$(basename "$values_file") | |
| # Check if values_filename is referenced in app.yaml | |
| if ! grep -q "$values_filename" "$chart_dir/templates/app.yaml"; then | |
| missing_references="$missing_references $values_filename" | |
| fi | |
| done | |
| # Print results | |
| if [[ -n "$missing_references" ]]; then | |
| echo "Missing references in $chart_dir/templates/app.yaml for:$missing_references" | |
| exit 1 | |
| else | |
| echo "All values files are correctly referenced in $chart_dir/templates/app.yaml" | |
| fi | |
| else | |
| echo "No app.yaml found in $chart_dir/templates/; skipping..." | |
| fi | |
| done | |
| - name: Set up Kubeconform | |
| id: setup-kubeconform | |
| uses: bmuschko/setup-kubeconform@v1 | |
| with: | |
| kubeconform-version: '0.6.1' | |
| - name: Print Kubeconform installation path | |
| env: | |
| KUBECONFORM_INSTALLATION_PATH: ${{ steps.setup-kubeconform.outputs.installation-path }} | |
| run: | | |
| echo "Kubeconform installed..." | |
| echo "Installation path: ${KUBECONFORM_INSTALLATION_PATH}" | |
| shell: bash | |
| - name: Kubeconform Validate app.yaml | |
| run: | | |
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| # Resolve a sane base ref (works on PRs and pushes) | |
| resolve_base() { | |
| if [[ -n "${GITHUB_BASE_REF:-}" ]]; then echo "origin/${GITHUB_BASE_REF}"; return; fi | |
| for b in origin/main origin/master main master; do | |
| git rev-parse --verify --quiet "$b" >/dev/null && { echo "$b"; return; } | |
| done | |
| git rev-parse --verify --quiet origin/HEAD >/dev/null \ | |
| && git symbolic-ref --quiet --short refs/remotes/origin/HEAD \ | |
| | awk -F/ '{print "origin/"$2}' && return | |
| git rev-list --max-parents=0 HEAD | head -n1 | |
| } | |
| BASE_REF="$(resolve_base)" | |
| MERGE_BASE="$(git merge-base HEAD "$BASE_REF" 2>/dev/null || echo "$BASE_REF")" | |
| # Find changed YAML files that look like Argo Applications | |
| mapfile -t APP_FILES < <( | |
| git diff --name-only --diff-filter=ACMRT "$MERGE_BASE"...HEAD \ | |
| | grep -E '\.ya?ml$' \ | |
| | xargs -I{} sh -c 'grep -qE "^[[:space:]]*kind:[[:space:]]*Application[[:space:]]*$" "{}" && echo "{}"' \ | |
| || true | |
| ) | |
| [[ ${#APP_FILES[@]} -eq 0 ]] && { echo "No changed Argo Application YAMLs."; exit 0; } | |
| for f in "${APP_FILES[@]}"; do | |
| echo "=== Validating Application: $f ===" | |
| # YAML syntax | |
| yq -e '.' "$f" >/dev/null | |
| # Schema validation (no -schemas-from-file) | |
| kubeconform --summary -ignore-missing-schemas \ | |
| -schema-location default \ | |
| -schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' \ | |
| "$f" | |
| echo | |
| done |