Helm Charts / Detect changed charts (pull_request) Successful in 22s
Helm Charts / Library charts tool (pull_request) Skipped
Helm Charts / Application charts chart (pull_request) Skipped
Helm Charts / Application charts crowdsec (pull_request) Skipped
Helm Charts / Application charts grafana (pull_request) Skipped
Helm Charts / Application charts pgbouncer (pull_request) Skipped
Helm Charts / Application charts pgcat (pull_request) Skipped
Helm Charts / Application charts prometheus (pull_request) Skipped
Helm Charts / Application charts redis (pull_request) Skipped
Helm Charts / Application charts hashicorp-vault (pull_request) Successful in 15s
Helm Charts / Application charts minio (pull_request) Successful in 18s
Trouvé en refusant de lire le vert de cette PR : elle réécrit le chart `minio` en entier, et la CI a rendu `success` avec « Detect changed charts » ✓ et les deux jobs de construction en `Skipped`. Aucun job `Application charts minio` n'existait. La cause : Gitea ne sait pas monter une matrice DYNAMIQUE, donc la matrice est codée en dur — `chart: [tool]` et `chart: [pgcat]`. Le job `filter-chart` calcule POURTANT la bonne réponse ; personne ne la consomme. Le `if:` vérifie seulement si le chart codé en dur figure dans la liste détectée. Résultat mesuré : 10 charts dans le dépôt, 2 constructibles. `minio`, `redis`, `crowdsec`, `hashicorp-vault`, `grafana`, `prometheus`, `pgbouncer` et `chart` ne passaient sous aucun `helm template`, et toute PR qui les touchait affichait vert. Le remède ne demande PAS de matrice dynamique : le `if:` filtre déjà sur la sortie du détecteur, donc un chart non modifié reste `Skipped`. Il ne manquait que l'ÉNUMÉRATION — les neuf applicatifs sont désormais listés. ⚠ Le mode d'échec de ce fichier est maintenant écrit dedans : ajouter un chart au dépôt sans l'ajouter à la liste le rend invisible à la CI, en silence.
218 lines
8.8 KiB
YAML
218 lines
8.8 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:
|
|
# ⚠⚠ ÉNUMÉRATION EXHAUSTIVE, ET ELLE DOIT LE RESTER.
|
|
#
|
|
# Gitea ne sait pas monter une matrice DYNAMIQUE : on ne peut pas
|
|
# écrire `fromJson(needs.filter-chart.outputs.library_charts)` ici.
|
|
# La conséquence est passée inaperçue longtemps — le détecteur
|
|
# calculait la bonne réponse, et PERSONNE NE LA CONSOMMAIT : le `if:`
|
|
# ci-dessous vérifie seulement si le chart CODÉ EN DUR figure dans la
|
|
# liste détectée. Seuls `tool` et `pgcat` pouvaient donc être
|
|
# construits ; les HUIT AUTRES charts de ce dépôt ne l'étaient jamais,
|
|
# et leurs PR affichaient vert. Mesuré le 2026-09-02 sur la PR #32,
|
|
# qui réécrivait le chart `minio` en entier : `Detect changed charts`
|
|
# ✓, les deux jobs de construction `Skipped`, statut global `success`.
|
|
#
|
|
# Le remède n'a pas besoin de matrice dynamique : le `if:` filtre DÉJÀ
|
|
# sur la sortie du détecteur, donc un chart non modifié reste `Skipped`.
|
|
# Il ne manquait que l'ÉNUMÉRATION.
|
|
#
|
|
# ⚠ Ajouter un chart au dépôt SANS l'ajouter ici le rend invisible à la
|
|
# CI, en silence. C'est le mode d'échec de ce fichier.
|
|
chart: [tool]
|
|
# 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:
|
|
# ⚠ Les NEUF charts applicatifs du dépôt — voir l'avertissement du job
|
|
# `library-charts` ci-dessus. Un chart absent de cette liste n'est
|
|
# JAMAIS construit, et sa PR est verte quand même.
|
|
# chart: ${{ fromJson(needs.filter-chart.outputs.application_charts) }}
|
|
chart: [chart, crowdsec, grafana, hashicorp-vault, minio, pgbouncer, pgcat, prometheus, redis]
|
|
type: [application] |