Quatre runs d'une branche déjà mergée ont bloqué, ce matin, l'apply qu'on attendait. Deux causes, indépendantes : 1. Les workflows tofu (minio, vault, crowdsec, plausible) s'authentifient à Vault par un flux OIDC dont un HUMAIN doit ouvrir le lien. Déclenchés tout seuls, ils ne peuvent qu'occuper un runner jusqu'au timeout. Ils font en plus `apply` en `auto_approve` CONTRE LA PROD : partir sur le push d'une branche, c'est appliquer du code que personne n'a relu. → `workflow_dispatch` seul, ce qui écrit enfin ce qu'ils faisaient déjà. (crowdsec et plausible passaient de toute façon par une ancre YAML, donc leurs triggers étaient INERTES — issues 113 → 117 de kadans.) 2. `push` sur toutes les branches + `pull_request` = DEUX runs par commit dès qu'une branche a une PR. Vérifié : runs 258/259 et 260/261 portent le même SHA. helmcharts, qui travaille seul et mérite de rester automatique, prend la forme éprouvée de la CI de kadans : push sur `main`, PR pour la branche. Chaque clé de trigger porte un corps explicite : un `pull_request:` nu n'est pas une forme éprouvée ici, et son mode d'échec est le silencieux. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01CoafGWmRVESaWX819USUUA
196 lines
7.4 KiB
YAML
196 lines
7.4 KiB
YAML
---
|
|
# template source: https://github.com/bretfisher/docker-build-workflow/blob/main/templates/call-docker-build.yaml
|
|
name: Helm Charts
|
|
|
|
# Celui-ci travaille SEUL (pas d'auth Vault, pas d'apply) : on le garde
|
|
# automatique. Mais `push` sur TOUTES les branches + `pull_request` faisait
|
|
# partir DEUX runs pour le même commit dès qu'une branche avait une PR.
|
|
#
|
|
# Même forme que la CI de kadans : la branche est couverte par `pull_request`,
|
|
# `main` par le `push` d'après-merge. Un run par événement, aucun angle mort.
|
|
#
|
|
# (Le filtre de chemins d'origine, resté en commentaire des années sous un
|
|
# « gitea don't handle well the paths filter », n'était probablement pas en
|
|
# cause : il passait par une ancre YAML, et le parseur d'événements de Gitea ne
|
|
# les résout pas — issues 113 → 117 de kadans. Le job `filter-chart` fait déjà
|
|
# ce tri au niveau job, donc on n'y retouche pas.)
|
|
#
|
|
# ⚠ Chaque clé porte un CORPS explicite : un `pull_request:` nu (valeur nulle)
|
|
# n'est pas une forme éprouvée sur ce Gitea, et son mode d'échec est le
|
|
# silencieux — aucun run, aucune erreur. On copie la forme qui tourne (kadans
|
|
# ci.yml), listes dupliquées à la main, sans ancre.
|
|
on:
|
|
workflow_dispatch: {}
|
|
push:
|
|
branches: [main]
|
|
paths-ignore:
|
|
- '**.md'
|
|
pull_request:
|
|
paths-ignore:
|
|
- '**.md'
|
|
|
|
# cancel any previously-started, yet still active runs of this workflow on the same branch
|
|
concurrency:
|
|
group: ${{ github.ref }}-${{ github.workflow }}
|
|
cancel-in-progress: true
|
|
|
|
.helm_install_dependencies_sh: &helm_install_dependencies_sh |-
|
|
helm_install_dependencies() {
|
|
chart_file="$1/Chart.yaml"
|
|
[[ ! -f "$chart_file" ]] && echo "Chart.yaml not found in $1" && return 1
|
|
|
|
yq eval '.dependencies[]' "$chart_file" -o=json | jq -c '.' | while IFS= read -r dep; do
|
|
name=$(jq -r '.name' <<< "$dep")
|
|
version=$(jq -r '.version' <<< "$dep")
|
|
repo=$(jq -r '.repository' <<< "$dep")
|
|
url=$(curl -s "${repo}/index.yaml" | yq eval ".entries.${name}[] | select(.version == \"${version}\") | .urls[0]" -)
|
|
|
|
echo "Dependency: $name, Version: $version, URL: $url"
|
|
mkdir -p "$1/charts" && curl -sL "$url" -o "$1/charts/${name}-${version}.tgz"
|
|
done
|
|
}
|
|
helm_install_dependencies $chart
|
|
|
|
|
|
jobs:
|
|
filter-chart:
|
|
name: Detect changed charts
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
library_charts: ${{steps.filter-charts.outputs.library_charts}}
|
|
application_charts: ${{steps.filter-charts.outputs.application_charts}}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Get changed files
|
|
id: changed-files
|
|
uses: tj-actions/changed-files@v45
|
|
|
|
- name: Filter modified charts
|
|
id: filter-charts
|
|
run: |
|
|
echo "Changed files:"
|
|
echo "${{ steps.changed-files.outputs.all_changed_files }}"
|
|
|
|
# Find unique directories that contain Chart.yaml among the changed files
|
|
modified_dirs=$(echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n' | xargs -n1 dirname | sort -u || true)
|
|
|
|
# Initialize an array to store directories that contain Chart.yaml
|
|
helm_chart_dirs=()
|
|
|
|
# Function to find the closest directory containing Chart.yaml
|
|
find_chart_root() {
|
|
dir="$1"
|
|
while [[ "$dir" != "/" && "$dir" != "." ]]; do
|
|
if [[ -f "$dir/Chart.yaml" ]]; then
|
|
echo "$dir"
|
|
return
|
|
fi
|
|
dir=$(dirname "$dir")
|
|
done
|
|
}
|
|
|
|
# Iterate over each modified directory and find the root chart directory
|
|
for dir in $modified_dirs; do
|
|
chart_dir=$(find_chart_root "$dir")
|
|
if [[ -n "$chart_dir" && ! " ${helm_chart_dirs[*]} " =~ " ${chart_dir} " ]]; then
|
|
helm_chart_dirs+=("$chart_dir")
|
|
fi
|
|
done
|
|
|
|
# Initialize arrays for library and application charts
|
|
library_dirs=()
|
|
application_dirs=()
|
|
|
|
# Iterate over each modified directory and check the 'type' field in Chart.yaml
|
|
for dir in ${helm_chart_dirs[@]}; do
|
|
chart_type=$(yq eval '.type' "$dir/Chart.yaml" || echo "undefined")
|
|
|
|
# Add directories to corresponding arrays based on the 'type'
|
|
if [[ "$chart_type" == "library" ]]; then
|
|
library_dirs+=("$dir")
|
|
elif [[ "$chart_type" == "application" ]]; then
|
|
application_dirs+=("$dir")
|
|
fi
|
|
done
|
|
|
|
# Convert the arrays to JSON format
|
|
library_json=$(printf '%s\n' "${library_dirs[@]}" | jq -R . | jq -cs 'map(select(. != ""))')
|
|
application_json=$(printf '%s\n' "${application_dirs[@]}" | jq -R . | jq -cs 'map(select(. != ""))')
|
|
|
|
# Output the JSON arrays
|
|
echo "Modified Helm library charts directories: $library_json"
|
|
echo "library_charts=$library_json" >> $GITHUB_OUTPUT
|
|
|
|
echo "Modified Helm application charts directories: $application_json"
|
|
echo "application_charts=$application_json" >> $GITHUB_OUTPUT
|
|
|
|
library-charts: &charts-matrix-job
|
|
name: Library charts ${{ matrix.chart }}
|
|
runs-on: ubuntu-latest
|
|
needs: filter-chart
|
|
strategy:
|
|
matrix:
|
|
chart: [tool] # turns out gitea doesn't support dynamic matrix
|
|
# chart: ${{ fromJson(needs.filter-chart.outputs.library_charts) }}
|
|
type: [library]
|
|
if: >-
|
|
${{
|
|
always() && !contains(needs.*.result, 'failure') && needs.filter-chart.result == 'success'
|
|
&& (
|
|
contains(fromJson(needs.filter-chart.outputs.library_charts), matrix.chart)
|
|
|| contains(fromJson(needs.filter-chart.outputs.application_charts), matrix.chart)
|
|
)
|
|
&& (
|
|
contains(fromJSON('["","pull_request"]'), github.event_name)
|
|
|| github.ref == 'refs/heads/main'
|
|
) }}
|
|
env:
|
|
chart: ${{ matrix.chart }}
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- run: *helm_install_dependencies_sh
|
|
|
|
- name: Install Helm for test
|
|
if: >-
|
|
${{
|
|
matrix.type != 'library'
|
|
&& (
|
|
contains(fromJSON('["","pull_request"]'), github.event_name)
|
|
|| github.ref != 'refs/heads/main'
|
|
)
|
|
}}
|
|
uses: azure/setup-helm@v4
|
|
- name: Helm template
|
|
if: >-
|
|
${{
|
|
matrix.type != 'library'
|
|
&& (
|
|
contains(fromJSON('["","pull_request"]'), github.event_name)
|
|
|| github.ref != 'refs/heads/main'
|
|
)
|
|
}}
|
|
run: helm template $chart --debug
|
|
|
|
- name: publish ${{ matrix.chart }} helm chart
|
|
if: ${{ contains(fromJSON('["","push"]'), github.event_name) && github.ref == 'refs/heads/main' }}
|
|
run: |
|
|
set -x
|
|
chart=${chart:-tool}
|
|
chart_version=`yq eval .version ${chart}/Chart.yaml`
|
|
chart_package=${chart}-${chart_version}.tgz
|
|
# helm package ${chart}
|
|
tar -X ${chart}/.helmignore -czf ${chart_package} ${chart}
|
|
curl --user ${{ github.actor }}:${{ secrets.PACKAGES_TOKEN }} -X POST --upload-file ./${chart_package} https://gitea.arcodange.lab/api/packages/${{ github.repository_owner }}/helm/api/charts
|
|
|
|
application-charts:
|
|
<<: *charts-matrix-job
|
|
name: Application charts ${{ matrix.chart }}
|
|
needs: [filter-chart,library-charts]
|
|
strategy:
|
|
matrix:
|
|
# chart: ${{ fromJson(needs.filter-chart.outputs.application_charts) }}
|
|
chart: [pgcat]
|
|
type: [application] |