|
| 1 | +name: Helm Chart |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, staging, dev] |
| 6 | + paths: |
| 7 | + - 'helm/sim/**' |
| 8 | + - '.github/workflows/helm.yml' |
| 9 | + pull_request: |
| 10 | + branches: [main, staging, dev] |
| 11 | + paths: |
| 12 | + - 'helm/sim/**' |
| 13 | + - '.github/workflows/helm.yml' |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: helm-${{ github.ref }} |
| 17 | + cancel-in-progress: true |
| 18 | + |
| 19 | +permissions: |
| 20 | + contents: read |
| 21 | + |
| 22 | +jobs: |
| 23 | + chart: |
| 24 | + name: Lint, test, and validate chart |
| 25 | + runs-on: ${{ (vars.CI_PROVIDER == '' || vars.CI_PROVIDER == 'blacksmith') && 'blacksmith-2vcpu-ubuntu-2404' || 'ubuntu-latest' }} |
| 26 | + timeout-minutes: 15 |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 |
| 29 | + |
| 30 | + - name: Set up Helm |
| 31 | + uses: azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4 # v4 |
| 32 | + with: |
| 33 | + version: v3.16.4 |
| 34 | + |
| 35 | + - name: Helm lint |
| 36 | + run: helm lint helm/sim --values helm/sim/ci/default-values.yaml |
| 37 | + |
| 38 | + - name: Helm unit tests |
| 39 | + run: | |
| 40 | + # Official helm-unittest image, pinned by immutable digest (tag 3.17.3-0.8.2). |
| 41 | + # Run as the runner's UID so the container can write into the bind |
| 42 | + # mount (it creates tests/__snapshot__), with a writable HOME for helm. |
| 43 | + docker run --rm --user "$(id -u):$(id -g)" -e HOME=/tmp \ |
| 44 | + -v "$PWD/helm/sim:/apps" \ |
| 45 | + helmunittest/helm-unittest@sha256:b653db7d5665bc6cec677b15c5eaa1c0377c0de8ac4eb1df58b924478baa21e1 . |
| 46 | +
|
| 47 | + - name: Install kubeconform |
| 48 | + run: | |
| 49 | + curl -sSL -o /tmp/kubeconform.tar.gz \ |
| 50 | + https://github.com/yannh/kubeconform/releases/download/v0.6.7/kubeconform-linux-amd64.tar.gz |
| 51 | + echo "95f14e87aa28c09d5941f11bd024c1d02fdc0303ccaa23f61cef67bc92619d73 /tmp/kubeconform.tar.gz" | sha256sum -c - |
| 52 | + tar -xzf /tmp/kubeconform.tar.gz -C /tmp kubeconform |
| 53 | +
|
| 54 | + - name: Render and validate manifests (default configuration) |
| 55 | + run: | |
| 56 | + helm template sim helm/sim --namespace sim \ |
| 57 | + --values helm/sim/ci/default-values.yaml \ |
| 58 | + | /tmp/kubeconform -strict -summary \ |
| 59 | + -kubernetes-version 1.29.0 \ |
| 60 | + -schema-location default \ |
| 61 | + -schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' |
| 62 | +
|
| 63 | + - name: Render and validate manifests (all components enabled) |
| 64 | + run: | |
| 65 | + helm template sim helm/sim --namespace sim \ |
| 66 | + --values helm/sim/ci/full-values.yaml \ |
| 67 | + | /tmp/kubeconform -strict -summary \ |
| 68 | + -kubernetes-version 1.29.0 \ |
| 69 | + -schema-location default \ |
| 70 | + -schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' |
| 71 | +
|
| 72 | + - name: Render every example values file |
| 73 | + run: | |
| 74 | + set -euo pipefail |
| 75 | + for f in helm/sim/examples/values-*.yaml; do |
| 76 | + echo "--- $f" |
| 77 | + # Examples intentionally omit secrets (their headers document the |
| 78 | + # required --set flags), so supply the CI dummies alongside each. |
| 79 | + helm template sim helm/sim --namespace sim \ |
| 80 | + --values "$f" \ |
| 81 | + --values helm/sim/ci/default-values.yaml \ |
| 82 | + --set copilot.postgresql.auth.password=ci-dummy-password \ |
| 83 | + --set copilot.server.env.AGENT_API_DB_ENCRYPTION_KEY=cicicicicicicicicicicicicicicicicicicicicicicicicicicicicicicici \ |
| 84 | + --set copilot.server.env.INTERNAL_API_SECRET=cicicicicicicicicicicicicicicicicicicicicicicicicicicicicicicici \ |
| 85 | + --set copilot.server.env.LICENSE_KEY=ci-dummy-license \ |
| 86 | + --set copilot.server.env.SIM_BASE_URL=https://ci.example.com \ |
| 87 | + --set copilot.server.env.SIM_AGENT_API_KEY=ci-dummy-agent-key \ |
| 88 | + --set copilot.server.env.REDIS_URL=redis://ci-redis:6379 \ |
| 89 | + --set copilot.server.env.OPENAI_API_KEY_1=ci-dummy-openai-key \ |
| 90 | + --set externalDatabase.password=ci-dummy-password > /dev/null |
| 91 | + done |
| 92 | +
|
| 93 | + version-bump: |
| 94 | + name: Chart version bumped |
| 95 | + if: github.event_name == 'pull_request' |
| 96 | + runs-on: ${{ (vars.CI_PROVIDER == '' || vars.CI_PROVIDER == 'blacksmith') && 'blacksmith-2vcpu-ubuntu-2404' || 'ubuntu-latest' }} |
| 97 | + timeout-minutes: 5 |
| 98 | + steps: |
| 99 | + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 |
| 100 | + with: |
| 101 | + fetch-depth: 0 |
| 102 | + - name: Require a Chart.yaml version bump when chart content changes |
| 103 | + run: | |
| 104 | + set -euo pipefail |
| 105 | + base="origin/${{ github.base_ref }}" |
| 106 | + git fetch origin "${{ github.base_ref }}" |
| 107 | + merge_base=$(git merge-base "$base" HEAD) |
| 108 | + changed=$(git diff --name-only "$merge_base" HEAD) |
| 109 | + if echo "$changed" | grep -q '^helm/sim/'; then |
| 110 | + base_version=$(git show "$merge_base:helm/sim/Chart.yaml" | awk '/^version:/ {print $2}') |
| 111 | + head_version=$(awk '/^version:/ {print $2}' helm/sim/Chart.yaml) |
| 112 | + echo "base=$base_version head=$head_version" |
| 113 | + if [ "$base_version" = "$head_version" ]; then |
| 114 | + echo "::error::helm/sim/** changed but Chart.yaml version did not (still $head_version). Bump it per SemVer." |
| 115 | + exit 1 |
| 116 | + fi |
| 117 | + else |
| 118 | + echo "No chart changes; skipping." |
| 119 | + fi |
| 120 | +
|
| 121 | + install: |
| 122 | + name: Install on kind and run helm test |
| 123 | + needs: chart |
| 124 | + runs-on: ${{ (vars.CI_PROVIDER == '' || vars.CI_PROVIDER == 'blacksmith') && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-latest' }} |
| 125 | + timeout-minutes: 25 |
| 126 | + steps: |
| 127 | + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 |
| 128 | + |
| 129 | + - name: Set up Helm |
| 130 | + uses: azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4 # v4 |
| 131 | + with: |
| 132 | + version: v3.16.4 |
| 133 | + |
| 134 | + - name: Create kind cluster |
| 135 | + uses: helm/kind-action@ef37e7f390d99f746eb8b610417061a60e82a6cc # v1 |
| 136 | + with: |
| 137 | + version: v0.24.0 |
| 138 | + |
| 139 | + - name: Install chart |
| 140 | + run: | |
| 141 | + helm install sim helm/sim \ |
| 142 | + --namespace sim --create-namespace \ |
| 143 | + --values helm/sim/ci/default-values.yaml \ |
| 144 | + --values helm/sim/ci/kind-values.yaml \ |
| 145 | + --wait --timeout 15m |
| 146 | +
|
| 147 | + - name: Diagnostics on failure |
| 148 | + if: failure() |
| 149 | + run: | |
| 150 | + kubectl -n sim get pods -o wide || true |
| 151 | + kubectl -n sim get events --sort-by=.lastTimestamp | tail -40 || true |
| 152 | + kubectl -n sim describe pods | tail -100 || true |
| 153 | + kubectl -n sim logs deploy/sim-app -c migrations --tail=50 || true |
| 154 | + kubectl -n sim logs deploy/sim-app --tail=80 || true |
| 155 | +
|
| 156 | + - name: Run helm test |
| 157 | + run: helm test sim --namespace sim --timeout 5m |
0 commit comments