|
| 1 | +# SPDX-License-Identifier: MIT OR Apache-2.0 |
| 2 | +# |
| 3 | +# Deploy-artifact lint gate (#363). The repo ships production deployment artifacts |
| 4 | +# (the Helm chart, the raw k8s manifests, the docker-compose files, the two |
| 5 | +# Dockerfiles) that no other workflow validates: image.yml only runs on `v*` tags, |
| 6 | +# and rust.yml lints Rust, not YAML. This gate lints them on every PR that TOUCHES |
| 7 | +# them (the `paths:` filter), so a malformed chart / manifest / Dockerfile is caught |
| 8 | +# before it ships rather than when an operator first applies it. |
| 9 | +# |
| 10 | +# It renders the chart (default AND with the console enabled) and validates the |
| 11 | +# output against the Kubernetes schemas, validates the raw manifests the same way, |
| 12 | +# and hadolints both Dockerfiles. Third-party actions are tag-pinned to match the |
| 13 | +# CI-workflow convention (rust.yml / docs.yml use `@v4`-style tags; the release/ |
| 14 | +# image workflows use SHA pins). |
| 15 | +name: deploy-lint |
| 16 | + |
| 17 | +on: |
| 18 | + push: |
| 19 | + branches: [main] |
| 20 | + pull_request: |
| 21 | + paths: |
| 22 | + - "deploy/**" |
| 23 | + - "Dockerfile" |
| 24 | + - "Dockerfile.console" |
| 25 | + - ".github/workflows/deploy-lint.yml" |
| 26 | + |
| 27 | +permissions: |
| 28 | + contents: read |
| 29 | + |
| 30 | +env: |
| 31 | + # Validate against a recent stable Kubernetes API surface. |
| 32 | + KUBE_VERSION: "1.30.0" |
| 33 | + KUBECONFORM_VERSION: "0.6.7" |
| 34 | + HELM_VERSION: "v3.15.4" |
| 35 | + |
| 36 | +jobs: |
| 37 | + helm: |
| 38 | + name: helm lint + kubeconform (rendered chart) |
| 39 | + runs-on: ubuntu-latest |
| 40 | + timeout-minutes: 10 |
| 41 | + steps: |
| 42 | + - uses: actions/checkout@v4 |
| 43 | + - uses: azure/setup-helm@v4 |
| 44 | + with: |
| 45 | + version: ${{ env.HELM_VERSION }} |
| 46 | + - name: helm lint (defaults + console enabled) |
| 47 | + run: | |
| 48 | + set -euo pipefail |
| 49 | + helm lint deploy/helm/ironcache |
| 50 | + helm lint deploy/helm/ironcache \ |
| 51 | + --set console.enabled=true --set console.replicas=2 |
| 52 | + - name: Install kubeconform |
| 53 | + run: | |
| 54 | + set -euo pipefail |
| 55 | + curl -fsSL \ |
| 56 | + "https://github.com/yannh/kubeconform/releases/download/v${KUBECONFORM_VERSION}/kubeconform-linux-amd64.tar.gz" \ |
| 57 | + | tar -xz kubeconform |
| 58 | + sudo install -m 0755 kubeconform /usr/local/bin/kubeconform |
| 59 | + kubeconform -v |
| 60 | + - name: helm template | kubeconform (both value sets) |
| 61 | + run: | |
| 62 | + set -euo pipefail |
| 63 | + # -ignore-missing-schemas skips CRDs (ServiceMonitor) that have no core |
| 64 | + # schema; -strict rejects unknown fields in the core resources. |
| 65 | + for extra in "" "--set console.enabled=true --set console.replicas=2"; do |
| 66 | + echo "::group::helm template ${extra:-(defaults)}" |
| 67 | + rendered="$(helm template ic deploy/helm/ironcache $extra)" |
| 68 | + printf '%s\n' "$rendered" \ |
| 69 | + | kubeconform -strict -summary -verbose \ |
| 70 | + -ignore-missing-schemas \ |
| 71 | + -kubernetes-version "${KUBE_VERSION}" |
| 72 | + if [ -n "$extra" ]; then |
| 73 | + # Guard against a broken `console.enabled` gate silently rendering |
| 74 | + # nothing (kubeconform is happy with zero console objects, so assert |
| 75 | + # the console Deployment/Service actually appeared). |
| 76 | + printf '%s\n' "$rendered" | grep -q "ic-ironcache-console" \ |
| 77 | + || { echo "ERROR: console.enabled=true rendered no console resources"; exit 1; } |
| 78 | + fi |
| 79 | + echo "::endgroup::" |
| 80 | + done |
| 81 | +
|
| 82 | + k8s: |
| 83 | + name: kubeconform (raw manifests) |
| 84 | + runs-on: ubuntu-latest |
| 85 | + timeout-minutes: 10 |
| 86 | + steps: |
| 87 | + - uses: actions/checkout@v4 |
| 88 | + - name: Install kubeconform |
| 89 | + run: | |
| 90 | + set -euo pipefail |
| 91 | + curl -fsSL \ |
| 92 | + "https://github.com/yannh/kubeconform/releases/download/v${KUBECONFORM_VERSION}/kubeconform-linux-amd64.tar.gz" \ |
| 93 | + | tar -xz kubeconform |
| 94 | + sudo install -m 0755 kubeconform /usr/local/bin/kubeconform |
| 95 | + - name: kubeconform deploy/k8s |
| 96 | + run: | |
| 97 | + set -euo pipefail |
| 98 | + kubeconform -strict -summary -verbose \ |
| 99 | + -ignore-missing-schemas \ |
| 100 | + -kubernetes-version "${KUBE_VERSION}" \ |
| 101 | + deploy/k8s/*.yaml |
| 102 | +
|
| 103 | + docker: |
| 104 | + name: hadolint (Dockerfiles) |
| 105 | + runs-on: ubuntu-latest |
| 106 | + timeout-minutes: 10 |
| 107 | + steps: |
| 108 | + - uses: actions/checkout@v4 |
| 109 | + - name: hadolint Dockerfile |
| 110 | + uses: hadolint/hadolint-action@v3.1.0 |
| 111 | + with: |
| 112 | + dockerfile: Dockerfile |
| 113 | + - name: hadolint Dockerfile.console |
| 114 | + uses: hadolint/hadolint-action@v3.1.0 |
| 115 | + with: |
| 116 | + dockerfile: Dockerfile.console |
| 117 | + |
| 118 | + compose: |
| 119 | + name: docker compose config (validate) |
| 120 | + runs-on: ubuntu-latest |
| 121 | + timeout-minutes: 10 |
| 122 | + steps: |
| 123 | + - uses: actions/checkout@v4 |
| 124 | + - name: Validate every compose file parses + resolves |
| 125 | + env: |
| 126 | + # The cluster compose uses a fail-fast required var (${IRONCACHE_CLUSTER_SECRET:?}); |
| 127 | + # deploy-lint only checks the file STRUCTURE, not real secrets, so a |
| 128 | + # placeholder lets `config` interpolate. Add more here if a compose file |
| 129 | + # introduces another required var. |
| 130 | + IRONCACHE_CLUSTER_SECRET: deploy-lint-placeholder |
| 131 | + run: | |
| 132 | + set -euo pipefail |
| 133 | + for f in deploy/compose/docker-compose*.yml; do |
| 134 | + echo "::group::docker compose -f $f config" |
| 135 | + # `config` fully parses + interpolates + schema-checks the file; -q |
| 136 | + # suppresses the rendered output, leaving only errors. |
| 137 | + docker compose -f "$f" config -q |
| 138 | + echo "::endgroup::" |
| 139 | + done |
0 commit comments