|
| 1 | +# Renders every component chart with the values the meta chart forwards to it, |
| 2 | +# against main and the latest patch of the last five minor releases, every six |
| 3 | +# hours. A component range floats within its major, so a component release |
| 4 | +# changes what an already published agent-platform release installs without an |
| 5 | +# agent-platform commit; the PR and tag pipelines never see that. |
| 6 | +# |
| 7 | +# Each ref is judged by its own values and its own test code: main runs |
| 8 | +# `make verify-components-charts verify-examples`, a release tag runs |
| 9 | +# `make verify-release-floors verify-examples` (the strict run, no fallback for |
| 10 | +# an unreleased component). The report job keeps one issue per failing ref. |
| 11 | +# docs/ci.md says how to respond. |
| 12 | +name: component-render-schedule |
| 13 | + |
| 14 | +on: |
| 15 | + schedule: |
| 16 | + - cron: '23 */6 * * *' |
| 17 | + workflow_dispatch: |
| 18 | + inputs: |
| 19 | + refs: |
| 20 | + description: Refs to render, space-separated (default main and the latest patch of the last five minors) |
| 21 | + required: false |
| 22 | + pull_request: |
| 23 | + paths: |
| 24 | + - '.github/workflows/component-render-schedule.yaml' |
| 25 | + |
| 26 | +permissions: {} |
| 27 | + |
| 28 | +concurrency: |
| 29 | + group: component-render-schedule-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }} |
| 30 | + cancel-in-progress: ${{ github.event_name == 'pull_request' }} |
| 31 | + |
| 32 | +env: |
| 33 | + MINORS: 5 |
| 34 | + |
| 35 | +jobs: |
| 36 | + refs: |
| 37 | + name: Pick the refs to render |
| 38 | + runs-on: ubuntu-26.04 |
| 39 | + permissions: |
| 40 | + contents: read |
| 41 | + outputs: |
| 42 | + refs: ${{ steps.pick.outputs.refs }} |
| 43 | + steps: |
| 44 | + - name: main and the latest patch of the last minors |
| 45 | + id: pick |
| 46 | + env: |
| 47 | + REFS: ${{ inputs.refs }} |
| 48 | + REPO: ${{ github.repository }} |
| 49 | + run: | |
| 50 | + set -euo pipefail |
| 51 | + if [ -n "${REFS:-}" ]; then |
| 52 | + read -r -a picked <<<"$REFS" |
| 53 | + else |
| 54 | + tags="$(git ls-remote --tags --refs "https://github.com/$REPO" 'v*' \ |
| 55 | + | sed 's#.*refs/tags/##' | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V)" |
| 56 | + mapfile -t releases < <(awk -F. '{ last[$1"."$2] = $0 } END { for (m in last) print last[m] }' <<<"$tags" | sort -V | tail -n "$MINORS") |
| 57 | + picked=(main "${releases[@]}") |
| 58 | + fi |
| 59 | + json="$(jq -cn '$ARGS.positional' --args "${picked[@]}")" |
| 60 | + echo "refs=$json" >> "$GITHUB_OUTPUT" |
| 61 | + echo "rendering: ${picked[*]}" |
| 62 | +
|
| 63 | + render: |
| 64 | + name: Render ${{ matrix.ref }} |
| 65 | + needs: refs |
| 66 | + runs-on: ubuntu-26.04 |
| 67 | + timeout-minutes: 30 |
| 68 | + permissions: |
| 69 | + contents: read |
| 70 | + strategy: |
| 71 | + fail-fast: false |
| 72 | + matrix: |
| 73 | + ref: ${{ fromJSON(needs.refs.outputs.refs) }} |
| 74 | + env: |
| 75 | + # The checks print `ok:` lines to stdout and their FAIL to stderr: unbuffered, |
| 76 | + # the log keeps them in order. |
| 77 | + PYTHONUNBUFFERED: "1" |
| 78 | + steps: |
| 79 | + - name: Check out ${{ matrix.ref }} |
| 80 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 81 | + with: |
| 82 | + ref: ${{ matrix.ref }} |
| 83 | + persist-credentials: false |
| 84 | + - name: Install helm |
| 85 | + uses: giantswarm/install-binary-action@5bef88f65012037dd836117c8d344b21bb559854 # v4.1.0 |
| 86 | + with: |
| 87 | + binary: helm |
| 88 | + # The pin of .circleci/custom.yml's test-ingress-modes. |
| 89 | + version: "3.17.3" |
| 90 | + download_url: "https://get.helm.sh/helm-v${version}-linux-amd64.tar.gz" |
| 91 | + tarball_binary_path: "linux-amd64/helm" |
| 92 | + smoke_test: "${binary} version --short" |
| 93 | + - name: Install PyYAML |
| 94 | + run: | |
| 95 | + for attempt in 1 2 3; do |
| 96 | + python3 -c 'import yaml' 2>/dev/null && break |
| 97 | + (sudo timeout 180 apt-get update -qq && sudo timeout 180 apt-get install -y -qq python3-yaml) && break |
| 98 | + echo "apt attempt $attempt failed or stalled; retrying" >&2; sleep 15 |
| 99 | + done |
| 100 | + python3 -c 'import yaml' |
| 101 | + - name: Render every component with the forwarded values |
| 102 | + id: render |
| 103 | + env: |
| 104 | + REF: ${{ matrix.ref }} |
| 105 | + run: | |
| 106 | + set -o pipefail |
| 107 | + if [ "$REF" = main ]; then |
| 108 | + targets=(verify-components-charts verify-examples) |
| 109 | + else |
| 110 | + targets=(verify-release-floors verify-examples) |
| 111 | + fi |
| 112 | + # -k: every target reports, not only the first that fails. |
| 113 | + make -k "${targets[@]}" 2>&1 | tee "$RUNNER_TEMP/render.log" |
| 114 | + - name: Classify the result |
| 115 | + if: always() |
| 116 | + env: |
| 117 | + REF: ${{ matrix.ref }} |
| 118 | + OUTCOME: ${{ steps.render.outcome }} |
| 119 | + run: | |
| 120 | + set -euo pipefail |
| 121 | + log="$RUNNER_TEMP/render.log" |
| 122 | + touch "$log" |
| 123 | + mkdir -p result |
| 124 | + # refused: a component chart refuses the forwarded values (what breaks |
| 125 | + # installations); unreleased: main's Chart.yaml annotation is stale; |
| 126 | + # failed: anything else (setup, the registry, the check itself). |
| 127 | + if [ "$OUTCOME" = success ]; then |
| 128 | + kind=success |
| 129 | + elif grep -q -E 'rejects the values (the meta chart forwards to it|the example gives it)' "$log"; then |
| 130 | + kind=refused |
| 131 | + elif grep -q 'run `make sync-unreleased`' "$log"; then |
| 132 | + kind=unreleased |
| 133 | + else |
| 134 | + kind=failed |
| 135 | + fi |
| 136 | + # The FAIL blocks, without the lines that change from run to run. |
| 137 | + { grep -E -A6 '^FAIL' "$log" || tail -n 40 "$log"; } | head -n 80 > result/excerpt.txt |
| 138 | + echo "$kind" > result/kind |
| 139 | + echo "$REF" > result/ref |
| 140 | + if [ "$kind" != success ]; then |
| 141 | + { echo "### $REF: $kind"; echo '```'; cat result/excerpt.txt; echo '```'; } >> "$GITHUB_STEP_SUMMARY" |
| 142 | + fi |
| 143 | + - name: Keep the result for the report |
| 144 | + if: always() |
| 145 | + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 |
| 146 | + with: |
| 147 | + name: result-${{ strategy.job-index }} |
| 148 | + path: result/ |
| 149 | + retention-days: 7 |
| 150 | + |
| 151 | + report: |
| 152 | + name: Open, update or close the issues |
| 153 | + needs: [refs, render] |
| 154 | + if: always() && github.event_name != 'pull_request' && needs.refs.result == 'success' |
| 155 | + runs-on: ubuntu-26.04 |
| 156 | + permissions: |
| 157 | + issues: write |
| 158 | + steps: |
| 159 | + # An App token, unlike GITHUB_TOKEN, lets the issue's events start the |
| 160 | + # board workflows and the team mention notify. The workflow token is the |
| 161 | + # fallback when the App is not available or may not write issues. |
| 162 | + - name: Generate giantswarm-release token |
| 163 | + id: app-token |
| 164 | + continue-on-error: true |
| 165 | + uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 |
| 166 | + with: |
| 167 | + client-id: ${{ secrets.RELEASE_BOT_CLIENT_ID }} |
| 168 | + private-key: ${{ secrets.RELEASE_BOT_PRIVATE_KEY }} |
| 169 | + permission-issues: write |
| 170 | + - name: Collect the results |
| 171 | + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 |
| 172 | + with: |
| 173 | + pattern: result-* |
| 174 | + path: results |
| 175 | + - name: Report every ref |
| 176 | + env: |
| 177 | + GH_TOKEN: ${{ steps.app-token.outputs.token || github.token }} |
| 178 | + GH_REPO: ${{ github.repository }} |
| 179 | + REFS: ${{ needs.refs.outputs.refs }} |
| 180 | + SCHEDULED: ${{ github.event_name == 'schedule' }} |
| 181 | + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
| 182 | + run: | |
| 183 | + set -euo pipefail |
| 184 | + title_of() { |
| 185 | + if [ "$1" = main ]; then echo "agent-platform main branch chart doesn't render" |
| 186 | + else echo "agent-platform release $1 chart doesn't render"; fi |
| 187 | + } |
| 188 | + open="$(gh issue list --state open --label team/bumblebee --limit 500 --json number,title)" |
| 189 | + number_of() { |
| 190 | + TITLE="$1" jq -r 'map(select(.title == env.TITLE))[0].number // empty' <<<"$open" |
| 191 | + } |
| 192 | +
|
| 193 | + mapfile -t refs < <(jq -r '.[]' <<<"$REFS") |
| 194 | + for ref in "${refs[@]}"; do |
| 195 | + dir="$( (grep -l -x -F -- "$ref" results/*/ref 2>/dev/null || true) | head -n 1 | xargs -r dirname)" |
| 196 | + if [ -n "$dir" ]; then |
| 197 | + kind="$(cat "$dir/kind")"; excerpt="$(cat "$dir/excerpt.txt")" |
| 198 | + else |
| 199 | + kind=failed; excerpt="The render job reported no result: it failed before the render ran." |
| 200 | + fi |
| 201 | + title="$(title_of "$ref")" |
| 202 | + number="$(number_of "$title")" |
| 203 | + if [ "$kind" = success ]; then |
| 204 | + [ -z "$number" ] || gh issue close "$number" --comment "Every component renders again on \`$ref\`: $RUN_URL" |
| 205 | + continue |
| 206 | + fi |
| 207 | + if [ "$ref" = main ]; then where="the next release"; else where="installations that reconcile \`$ref\`"; fi |
| 208 | + case "$kind" in |
| 209 | + refused) what="A component chart refuses the values agent-platform \`$ref\` forwards to it: $where now fail to install or upgrade that component." ;; |
| 210 | + unreleased) what="\`main\`'s \`agent-platform.giantswarm.io/unreleased\` annotation no longer matches the registry: run \`make sync-unreleased\` on \`main\`. Installations are not affected." ;; |
| 211 | + *) what="The render check for \`$ref\` could not finish (setup, the registry or the check itself). This does not say that installations fail; look at the run." ;; |
| 212 | + esac |
| 213 | + signature="$(printf '%s\n%s' "$kind" "$excerpt" | sha256sum | cut -c1-16)" |
| 214 | + report="$(printf '%s\n\nRun: %s\n\n```\n%s\n```\n\nHow to respond: [docs/ci.md](https://github.com/%s/blob/main/docs/ci.md#scheduled-component-render).\n\n<!-- render-signature: %s -->' \ |
| 215 | + "$what" "$RUN_URL" "$excerpt" "$GH_REPO" "$signature")" |
| 216 | + if [ -z "$number" ]; then |
| 217 | + gh issue create --title "$title" --label team/bumblebee --body "$(printf '@giantswarm/team-bumblebee %s' "$report")" |
| 218 | + continue |
| 219 | + fi |
| 220 | + # A new comment only when the failure changed: the same refusal |
| 221 | + # every six hours says nothing new. |
| 222 | + last="$(gh issue view "$number" --json body,comments \ |
| 223 | + --jq '[.body, (.comments[].body)] | map(select(contains("render-signature"))) | last // ""')" |
| 224 | + if [[ "$last" != *"render-signature: $signature"* ]]; then |
| 225 | + gh issue comment "$number" --body "$report" |
| 226 | + fi |
| 227 | + done |
| 228 | +
|
| 229 | + # A ref the schedule no longer renders (a newer patch or minor took its |
| 230 | + # place, or it was rendered once by hand) never turns green: close its |
| 231 | + # issue so the open ones are the refs that are still checked. |
| 232 | + if [ "$SCHEDULED" = true ]; then |
| 233 | + TITLES="$(for ref in "${refs[@]}"; do title_of "$ref"; done | jq -R . | jq -sc .)" \ |
| 234 | + jq -r '(env.TITLES | fromjson) as $t |
| 235 | + | .[] | select(.title | test("^agent-platform (release v[0-9.]+|main branch) chart doesn.t render$")) |
| 236 | + | select(.title as $x | $t | index($x) | not) | .number' <<<"$open" \ |
| 237 | + | while read -r stale; do |
| 238 | + gh issue close "$stale" --comment "The schedule no longer renders this ref (a newer patch or minor took its place): $RUN_URL. Reopen it if installations still run it." |
| 239 | + done |
| 240 | + fi |
0 commit comments