|
| 1 | +name: Helm Chart Validation |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - "k8s/helm/**" |
| 8 | + - "scripts/helm-chart-kind-smoke.sh" |
| 9 | + - ".github/workflows/helm-chart-validation.yml" |
| 10 | + pull_request: |
| 11 | + paths: |
| 12 | + - "k8s/helm/**" |
| 13 | + - "scripts/helm-chart-kind-smoke.sh" |
| 14 | + - ".github/workflows/helm-chart-validation.yml" |
| 15 | + workflow_dispatch: |
| 16 | + |
| 17 | +permissions: |
| 18 | + contents: read |
| 19 | + |
| 20 | +env: |
| 21 | + CHART_PATH: k8s/helm/durable-workflow |
| 22 | + HELM_VERSION: v3.16.2 |
| 23 | + KUBECONFORM_VERSION: v0.6.7 |
| 24 | + KUBE_VERSIONS: "1.27.0 1.28.0 1.29.0 1.30.0" |
| 25 | + HELM_CT_CLUSTER_NAME: dw-helm-ct-${{ github.run_id }}-${{ github.run_attempt }} |
| 26 | + |
| 27 | +jobs: |
| 28 | + lint-and-template: |
| 29 | + name: Lint, render, and validate manifests |
| 30 | + runs-on: ubuntu-latest |
| 31 | + timeout-minutes: 10 |
| 32 | + steps: |
| 33 | + - name: Checkout server |
| 34 | + uses: actions/checkout@v6 |
| 35 | + |
| 36 | + - name: Set up Helm |
| 37 | + uses: azure/setup-helm@v4.2.0 |
| 38 | + with: |
| 39 | + version: ${{ env.HELM_VERSION }} |
| 40 | + |
| 41 | + - name: Helm lint |
| 42 | + run: | |
| 43 | + helm lint "${CHART_PATH}" |
| 44 | + for f in "${CHART_PATH}"/ci/*-values.yaml; do |
| 45 | + echo "::group::helm lint with $(basename "$f")" |
| 46 | + helm lint "${CHART_PATH}" -f "$f" |
| 47 | + echo "::endgroup::" |
| 48 | + done |
| 49 | +
|
| 50 | + - name: Render every CI fixture |
| 51 | + run: | |
| 52 | + mkdir -p rendered |
| 53 | + for f in "${CHART_PATH}"/ci/*-values.yaml; do |
| 54 | + name="$(basename "$f" .yaml)" |
| 55 | + echo "::group::helm template ${name}" |
| 56 | + helm template "rel-${name}" "${CHART_PATH}" \ |
| 57 | + --namespace durable-workflow \ |
| 58 | + -f "$f" \ |
| 59 | + > "rendered/${name}.yaml" |
| 60 | + echo "::endgroup::" |
| 61 | + done |
| 62 | +
|
| 63 | + - name: Validate rendered manifests against Kubernetes schemas |
| 64 | + run: | |
| 65 | + docker run --rm \ |
| 66 | + -v "${PWD}/rendered:/manifests:ro" \ |
| 67 | + ghcr.io/yannh/kubeconform:${KUBECONFORM_VERSION} \ |
| 68 | + -strict \ |
| 69 | + -summary \ |
| 70 | + -schema-location default \ |
| 71 | + -schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' \ |
| 72 | + -kubernetes-version 1.29.0 \ |
| 73 | + /manifests |
| 74 | +
|
| 75 | + - name: Validate against the supported Kubernetes version matrix |
| 76 | + run: | |
| 77 | + for kv in ${KUBE_VERSIONS}; do |
| 78 | + echo "::group::kubeconform against ${kv}" |
| 79 | + docker run --rm \ |
| 80 | + -v "${PWD}/rendered:/manifests:ro" \ |
| 81 | + ghcr.io/yannh/kubeconform:${KUBECONFORM_VERSION} \ |
| 82 | + -strict \ |
| 83 | + -summary \ |
| 84 | + -kubernetes-version "${kv}" \ |
| 85 | + /manifests |
| 86 | + echo "::endgroup::" |
| 87 | + done |
| 88 | +
|
| 89 | + - name: Upload rendered manifests |
| 90 | + if: always() |
| 91 | + continue-on-error: true |
| 92 | + uses: actions/upload-artifact@v3.2.2 |
| 93 | + with: |
| 94 | + name: helm-rendered-manifests |
| 95 | + path: rendered/ |
| 96 | + if-no-files-found: error |
| 97 | + |
| 98 | + ct-lint-install: |
| 99 | + name: chart-testing lint + install (kind) |
| 100 | + runs-on: ubuntu-latest |
| 101 | + timeout-minutes: 30 |
| 102 | + steps: |
| 103 | + - name: Checkout server |
| 104 | + uses: actions/checkout@v6 |
| 105 | + with: |
| 106 | + fetch-depth: 0 |
| 107 | + |
| 108 | + - name: Set up Python |
| 109 | + uses: actions/setup-python@v5 |
| 110 | + with: |
| 111 | + python-version: "3.12" |
| 112 | + |
| 113 | + - name: Set up Helm |
| 114 | + uses: azure/setup-helm@v4.2.0 |
| 115 | + with: |
| 116 | + version: ${{ env.HELM_VERSION }} |
| 117 | + |
| 118 | + - name: Set up chart-testing |
| 119 | + uses: helm/chart-testing-action@v2.6.1 |
| 120 | + |
| 121 | + - name: Configure kind networking for containerized runners |
| 122 | + if: env.JOB_CONTAINER_NAME != '' |
| 123 | + run: | |
| 124 | + workflow_network="$(docker inspect -f '{{range $k, $v := .NetworkSettings.Networks}}{{printf "%s" $k}}{{end}}' "${JOB_CONTAINER_NAME}")" |
| 125 | + if [ -z "${workflow_network}" ]; then |
| 126 | + echo "unable to determine workflow network for ${JOB_CONTAINER_NAME}" >&2 |
| 127 | + exit 1 |
| 128 | + fi |
| 129 | + echo "KIND_EXPERIMENTAL_DOCKER_NETWORK=${workflow_network}" >> "${GITHUB_ENV}" |
| 130 | +
|
| 131 | + - name: Set up kind |
| 132 | + uses: helm/kind-action@v1.10.0 |
| 133 | + with: |
| 134 | + version: v0.23.0 |
| 135 | + node_image: kindest/node:v1.29.4 |
| 136 | + cluster_name: ${{ env.HELM_CT_CLUSTER_NAME }} |
| 137 | + wait: 120s |
| 138 | + |
| 139 | + - name: Export internal kind kubeconfig for containerized runners |
| 140 | + if: env.JOB_CONTAINER_NAME != '' |
| 141 | + run: kind export kubeconfig --name "${HELM_CT_CLUSTER_NAME}" --internal |
| 142 | + |
| 143 | + - name: ct lint |
| 144 | + run: | |
| 145 | + ct lint \ |
| 146 | + --target-branch "${{ github.event.repository.default_branch }}" \ |
| 147 | + --chart-dirs k8s/helm \ |
| 148 | + --charts "${CHART_PATH}" \ |
| 149 | + --validate-maintainers=false |
| 150 | +
|
| 151 | + - name: Run kind smoke script |
| 152 | + env: |
| 153 | + K8S_HELM_SMOKE_KIND_NODE_IMAGE: kindest/node:v1.29.4 |
| 154 | + K8S_HELM_SMOKE_CLUSTER: ${{ env.HELM_CT_CLUSTER_NAME }} |
| 155 | + K8S_HELM_SMOKE_REUSE_CLUSTER: "1" |
| 156 | + K8S_HELM_SMOKE_IMAGE: durableworkflow/server:helm-smoke-${{ github.run_id }}-${{ github.run_attempt }} |
| 157 | + K8S_HELM_SMOKE_ARTIFACT_DIR: ${{ runner.temp }}/helm-smoke |
| 158 | + run: scripts/helm-chart-kind-smoke.sh |
| 159 | + |
| 160 | + - name: Print smoke diagnostics |
| 161 | + if: failure() |
| 162 | + run: | |
| 163 | + artifact_dir="${{ runner.temp }}/helm-smoke" |
| 164 | + if [ ! -d "${artifact_dir}" ]; then |
| 165 | + echo "no smoke artifacts collected" |
| 166 | + exit 0 |
| 167 | + fi |
| 168 | +
|
| 169 | + for file in \ |
| 170 | + helm-status.txt \ |
| 171 | + events.txt \ |
| 172 | + describe.txt \ |
| 173 | + resources.txt \ |
| 174 | + migration-job.log \ |
| 175 | + server.log \ |
| 176 | + worker.log \ |
| 177 | + mysql.log \ |
| 178 | + redis.log \ |
| 179 | + port-forward.log; do |
| 180 | + path="${artifact_dir}/${file}" |
| 181 | + if [ ! -f "${path}" ]; then |
| 182 | + continue |
| 183 | + fi |
| 184 | + echo "::group::${file}" |
| 185 | + tail -n 200 "${path}" || cat "${path}" || true |
| 186 | + echo "::endgroup::" |
| 187 | + done |
| 188 | +
|
| 189 | + - name: Upload smoke artifacts |
| 190 | + if: failure() |
| 191 | + continue-on-error: true |
| 192 | + uses: actions/upload-artifact@v3.2.2 |
| 193 | + with: |
| 194 | + name: helm-chart-kind-smoke |
| 195 | + path: ${{ runner.temp }}/helm-smoke |
| 196 | + if-no-files-found: ignore |
0 commit comments