diff --git a/.github/workflows/helm-lint-test.yaml b/.github/workflows/helm-lint-test.yaml index c3ee822..c0f9709 100644 --- a/.github/workflows/helm-lint-test.yaml +++ b/.github/workflows/helm-lint-test.yaml @@ -1,4 +1,4 @@ -name: Lint and test Helm chart +name: Lint and test chart on: pull_request: @@ -27,7 +27,7 @@ jobs: uses: helm/chart-testing-action@v2.2.0 - name: Run chart-testing (lint) - run: ct lint --config deployment/ct.yaml + run: ct lint --config deployment/ct.yaml --check-version-increment=false - name: Create kind cluster uses: helm/kind-action@v1.2.0 diff --git a/.github/workflows/version-test.yaml b/.github/workflows/version-test.yaml new file mode 100644 index 0000000..3b7ff00 --- /dev/null +++ b/.github/workflows/version-test.yaml @@ -0,0 +1,69 @@ +name: Validate versions + +on: + pull_request: + branches: + - 'release-*' + - gh-pages + +jobs: + validate-versions: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Get target branch + id: branch + run: | + echo "target=${{ github.base_ref }}" >> $GITHUB_OUTPUT + + - name: Validate release branch versions + if: startsWith(steps.branch.outputs.target, 'release-') + run: | + BRANCH="${{ steps.branch.outputs.target }}" + SEMVER="${BRANCH#release-}" + + # Validate semver format + if ! [[ "$SEMVER" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "❌ Branch name must follow 'release-X.Y.Z' semver format" + exit 1 + fi + + CHART_VERSION=$(yq eval '.version' deployment/console-plugin-nvidia-gpu/Chart.yaml) + APP_VERSION=$(yq eval '.appVersion' deployment/console-plugin-nvidia-gpu/Chart.yaml) + + if [[ "$CHART_VERSION" != "$SEMVER" ]]; then + echo "❌ Chart version must be '$SEMVER', found '$CHART_VERSION'" + exit 1 + fi + + if [[ "$APP_VERSION" != "v${SEMVER}" && "$APP_VERSION" != "release-${SEMVER}" ]]; then + echo "❌ appVersion must be 'v${SEMVER}' or 'release-${SEMVER}', found '$APP_VERSION'" + exit 1 + fi + + echo "✓ Versions match branch" + + - name: Validate gh-pages index.yaml + if: steps.branch.outputs.target == 'gh-pages' + run: | + # Check for duplicate versions + DUPLICATES=$(yq eval '.entries.console-plugin-nvidia-gpu[].version' index.yaml | sort | uniq -d) + if [[ -n "$DUPLICATES" ]]; then + echo "❌ Duplicate versions: $DUPLICATES" + exit 1 + fi + + # Check if any appVersion doesn't match v{version} or release-{version} + INVALID=$(yq eval '.entries.console-plugin-nvidia-gpu[] | select(.appVersion != "v" + .version and .appVersion != "release-" + .version) | .version' index.yaml) + if [[ -n "$INVALID" ]]; then + echo "❌ Invalid appVersion for versions: $INVALID" + echo " appVersion must be 'v{version}' or 'release-{version}'" + exit 1 + fi + + COUNT=$(yq eval '.entries.console-plugin-nvidia-gpu | length' index.yaml) + echo "✓ All $COUNT versions valid"