devzone 2.0.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/.devcontainer/agent-errors.sh +6 -6
  2. package/.devcontainer/agent-pod-manifest.sh +4 -4
  3. package/.devcontainer/agent-session.sh +2 -2
  4. package/.devcontainer/agent-state-json.sh +2 -2
  5. package/.devcontainer/agent-workspace.sh +1 -1
  6. package/.devcontainer/agent.sh +7 -7
  7. package/.devcontainer/ai/host-models.sh +2 -2
  8. package/.devcontainer/ai/plugins/devzone-guard-v2.js +3 -3
  9. package/.devcontainer/ai/plugins/devzone-guard.js +3 -3
  10. package/.devcontainer/argocd/argocd.sh +90 -89
  11. package/.devcontainer/argocd/catalog-argocd.sh +2 -2
  12. package/.devcontainer/argocd/services-hook.sh +3 -3
  13. package/.devcontainer/argocd/services.sh +1 -1
  14. package/.devcontainer/catalog/app.sh +114 -116
  15. package/.devcontainer/catalog/catalog-watcher.sh +62 -62
  16. package/.devcontainer/catalog/mysql/app.conf +1 -1
  17. package/.devcontainer/catalog/mysql/install.sh +40 -40
  18. package/.devcontainer/catalog/mysql/mysql.sh +141 -141
  19. package/.devcontainer/catalog/mysql/volume.sh +39 -39
  20. package/.devcontainer/catalog.sh +112 -112
  21. package/.devcontainer/chart-direct.sh +1 -1
  22. package/.devcontainer/cluster.sh +216 -218
  23. package/.devcontainer/clusters.sh +41 -41
  24. package/.devcontainer/command-aliases.sh +17 -8
  25. package/.devcontainer/devzone +93 -1496
  26. package/.devcontainer/devzone-ai-guard.sh +76 -0
  27. package/.devcontainer/devzone-ai.sh +201 -0
  28. package/.devcontainer/devzone-cluster.sh +210 -0
  29. package/.devcontainer/devzone-modules.sh +126 -0
  30. package/.devcontainer/devzone-platform.sh +189 -0
  31. package/.devcontainer/devzone-repair.sh +94 -0
  32. package/.devcontainer/devzone-services.sh +241 -0
  33. package/.devcontainer/devzone-skill.sh +97 -0
  34. package/.devcontainer/devzone-status.sh +140 -0
  35. package/.devcontainer/devzone-version.sh +78 -0
  36. package/.devcontainer/git-identity.sh +28 -0
  37. package/.devcontainer/gitlab/chart.sh +2 -2
  38. package/.devcontainer/gitlab/gitlab.sh +81 -82
  39. package/.devcontainer/gitlab/installation.sh +109 -109
  40. package/.devcontainer/gitlab/secrets.sh +47 -47
  41. package/.devcontainer/gitlab/seed.sh +77 -77
  42. package/.devcontainer/gitlab/test-gitlab.sh +242 -243
  43. package/.devcontainer/help.sh +1 -1
  44. package/.devcontainer/isolation.sh +30 -30
  45. package/.devcontainer/kind-wrapper.sh +17 -17
  46. package/.devcontainer/kube-account.sh +112 -113
  47. package/.devcontainer/kube-config.sh +45 -46
  48. package/.devcontainer/{invite-kube.sh → kube-prompt.sh} +6 -6
  49. package/.devcontainer/kube-reachable.sh +40 -40
  50. package/.devcontainer/memory.sh +1 -1
  51. package/.devcontainer/metrics-server.sh +2 -2
  52. package/.devcontainer/opencode.jsonc +2 -2
  53. package/.devcontainer/packages.sh +136 -135
  54. package/.devcontainer/password.sh +1 -1
  55. package/.devcontainer/ports-auto.sh +152 -153
  56. package/.devcontainer/ports-json.sh +16 -15
  57. package/.devcontainer/ports.sh +126 -122
  58. package/.devcontainer/post-create.sh +52 -52
  59. package/.devcontainer/postgres/postgres.sh +174 -174
  60. package/.devcontainer/rename-legacy-files.sh +103 -0
  61. package/.devcontainer/services-admin.sh +3 -3
  62. package/.devcontainer/skills/devzone/SKILL.md +40 -41
  63. package/.devcontainer/startup.sh +48 -49
  64. package/.devcontainer/state-gitops.sh +1 -1
  65. package/.devcontainer/state-json.sh +36 -62
  66. package/.devcontainer/state.sh +2 -2
  67. package/.devcontainer/workspace-init.sh +16 -2
  68. package/Makefile +1 -1
  69. package/README.md +191 -195
  70. package/charts/devzone-workspace/templates/statefulset.yaml +1 -1
  71. package/manage/devzone +7 -11
  72. package/manage/scripts/argocd-workspace.sh +1 -1
  73. package/manage/scripts/{check-charts.sh → ci/check-charts.sh} +1 -1
  74. package/manage/scripts/{check-english.sh → ci/check-english.sh} +1 -1
  75. package/manage/scripts/{check-go-layout.sh → ci/check-go-layout.sh} +1 -1
  76. package/manage/scripts/{check-names.sh → ci/check-names.sh} +7 -6
  77. package/manage/scripts/{check-utf8-vars.sh → ci/check-utf8-vars.sh} +1 -1
  78. package/manage/scripts/{versions.sh → ci/versions.sh} +8 -8
  79. package/manage/scripts/create-cluster.sh +1 -1
  80. package/manage/scripts/create-mode.sh +11 -18
  81. package/manage/scripts/devzone-create.sh +7 -35
  82. package/manage/scripts/devzone-manifest.sh +1 -1
  83. package/manage/scripts/devzone-update.sh +12 -8
  84. package/manage/scripts/launch.sh +7 -48
  85. package/manage/scripts/ports-apps.sh +1 -1
  86. package/manage/scripts/ports-workspace.sh +7 -7
  87. package/manage/scripts/poste.sh +6 -7
  88. package/manage/scripts/uninstall.sh +8 -8
  89. package/manage/scripts/workspace-egress.sh +2 -2
  90. package/manage/scripts/workspace-update.sh +5 -2
  91. package/manage/scripts/workspace-wait.sh +2 -2
  92. package/manage/workspace.sh +2 -12
  93. package/package.json +1 -1
  94. package/.devcontainer/docker-relay.sh +0 -149
  95. package/.devcontainer/docker-without-host.sh +0 -12
  96. package/.devcontainer/git-identite.sh +0 -28
  97. package/manage/scripts/docker-workstation.sh +0 -73
  98. package/manage/scripts/migrate-revert.sh +0 -60
  99. package/manage/scripts/migrate.sh +0 -243
  100. /package/manage/scripts/{ci-dns.sh → ci/ci-dns.sh} +0 -0
@@ -1,29 +1,29 @@
1
1
  #!/usr/bin/env bash
2
- # devzone test-gitlab : essai de bout en bout du module gitlab et de la
3
- # plateforme GitLab, dans le conteneur. Chaque étape est chronométrée ; le
4
- # résumé final dit ✔/✖/sauté et le code de sortie n'est 0 que sans ✖.
2
+ # devzone test-gitlab: end-to-end test of the gitlab module and of the GitLab
3
+ # platform, in the container. Each step is timed; the final summary gives
4
+ # ✔/✖/skipped and the exit code is 0 only without ✖.
5
5
  #
6
- # Pourquoi un script à part : la CI GitHub n'a pas les 8 Go de RAM du module
7
- # gitlab. Cet essai rejoue donc à la main, sur le poste, ce que la CI ne peut
8
- # pas faire, et publie éventuellement son résultat comme statut de commit.
6
+ # Why a separate script: the GitHub CI does not have the 8 GB of RAM of the gitlab
7
+ # module. This test therefore replays by hand, on the workstation, what the CI
8
+ # cannot do, and possibly publishes its result as a commit status.
9
9
  #
10
- # Options : --complet (désactive puis réinstalle), --statut (publie le statut
11
- # gitlab-integration sur HEAD par gh).
12
- # Les étapes sont appelées indirectement par lancer_etape : shellcheck ne peut
13
- # pas le voir et les croirait inatteignables (SC2317).
10
+ # Options: --complet (disables then reinstalls), --statut (publishes the
11
+ # gitlab-integration status on HEAD with gh).
12
+ # The steps are called indirectly by run_step: shellcheck cannot see it and
13
+ # would take them for unreachable (SC2317).
14
14
  # shellcheck disable=SC2317
15
15
  set -uo pipefail
16
16
 
17
17
  ICI="$(cd "$(dirname "$0")" && pwd)"
18
- # Même racine que gitlab.sh : DEVZONE_RACINE pour les tests
19
- RACINE="${DEVZONE_RACINE:-$(dirname "$(dirname "$ICI")")}"
18
+ # Same root as gitlab.sh: DEVZONE_ROOT for the tests
19
+ RACINE="${DEVZONE_ROOT:-$(dirname "$(dirname "$ICI")")}"
20
20
  GITLAB="$ICI/gitlab.sh"
21
21
  SECRETS="$RACINE/workspace/.gitlab"
22
- FICHIER_JETON="$SECRETS/root-token"
23
- ETAT="${DEVZONE_ETAT:-$RACINE/.devzone.modules}"
22
+ TOKEN_FILE="$SECRETS/root-token"
23
+ STATE_FILE="${DEVZONE_STATE:-$RACINE/.devzone.modules}"
24
24
  HOSTS="${DEVZONE_HOSTS:-/etc/hosts}"
25
- # Nom de l'instance : suffixe DEVZONE_INSTANCE calculé par cluster.sh, comme
26
- # gitlab.sh (namespace devzone-gitlab suffixé).
25
+ # Instance name: DEVZONE_INSTANCE suffix computed by cluster.sh, as in
26
+ # gitlab.sh (suffixed devzone-gitlab namespace).
27
27
  # shellcheck source=SCRIPTDIR/../cluster.sh
28
28
  # shellcheck disable=SC1091
29
29
  . "$ICI/../cluster.sh"
@@ -31,15 +31,15 @@ HOSTS="${DEVZONE_HOSTS:-/etc/hosts}"
31
31
  # shellcheck disable=SC1091
32
32
  . "$ICI/test-gitlab-restes.sh"
33
33
  URL="${GITLAB_TEST_URL:-http://gitlab.localhost:8929}"
34
- # Délai d'attente du pipeline : 600 s par défaut, court dans les tests
35
- DELAI_PIPELINE="${GITLAB_TEST_PIPELINE:-600}"
36
- # Intervalle d'interrogation du pipeline : 5 s par défaut, court dans les tests
37
- INTERVALLE="${GITLAB_TEST_INTERVALLE:-5}"
38
- # Réf. de la suite d'intégration repowarden (#533)
39
- REF_REPOWARDEN="${REPOWARDEN_TEST_REF:-develop}"
34
+ # Pipeline timeout: 600 s by default, short in the tests
35
+ PIPELINE_TIMEOUT="${GITLAB_TEST_PIPELINE:-600}"
36
+ # Pipeline polling interval: 5 s by default, short in the tests
37
+ INTERVAL="${GITLAB_TEST_INTERVALLE:-5}"
38
+ # Ref of the repowarden integration suite (#533)
39
+ REPOWARDEN_REF="${REPOWARDEN_TEST_REF:-develop}"
40
40
 
41
- # devzone lui-même : la commande du PATH (lien posé par post-create.sh), sinon
42
- # le script du dépôt. DEVZONE_TEST_DEVZONE permet une doublure de test.
41
+ # devzone itself: the command of the PATH (link set by post-create.sh), otherwise
42
+ # the script of the repository. DEVZONE_TEST_DEVZONE allows a test double.
43
43
  DEVZONE_BIN="${DEVZONE_TEST_DEVZONE:-}"
44
44
  if [ -z "$DEVZONE_BIN" ]; then
45
45
  if command -v devzone >/dev/null 2>&1; then
@@ -48,443 +48,442 @@ if [ -z "$DEVZONE_BIN" ]; then
48
48
  DEVZONE_BIN="$RACINE/.devcontainer/devzone"
49
49
  fi
50
50
  fi
51
- # Même chemin que devzone : glab vit dans ~/.local/bin, jamais dans le PATH
51
+ # Same path as devzone: glab lives in ~/.local/bin, never in the PATH
52
52
  GLAB="$HOME/.local/bin/glab"
53
53
 
54
- COMPLET=0
55
- STATUT=0
56
- JETON=""
57
- CLE_ID=""
58
- ECHEC=0
54
+ FULL=0
55
+ PUBLISH=0
56
+ TOKEN=""
57
+ KEY_ID=""
58
+ FAILED=0
59
59
  TOTAL=0
60
- RAISON=""
61
- PLATEFORME_CHANGEE=0
60
+ REASON=""
61
+ PLATFORM_CHANGED=0
62
62
  TMP_DIRS=()
63
- NOMS=()
64
- SYMBOLES=()
65
- DUREES=()
63
+ NAMES=()
64
+ SYMBOLS=()
65
+ DURATIONS=()
66
66
  SUFFIXES=()
67
67
 
68
- # Plateforme d'avant, lue dans le même fichier d'état que devzone : le trap
69
- # doit pouvoir la remettre même si l'étape 6 échoue en cours de route.
70
- PLATEFORME_AVANT="$(grep -E '^plateforme=' "$ETAT" 2>/dev/null | tail -1 | cut -d= -f2 || true)"
71
- [ "$PLATEFORME_AVANT" = gitlab ] || PLATEFORME_AVANT=github
72
- URL_AVANT="$(grep -E '^gitlab_url=' "$ETAT" 2>/dev/null | tail -1 | cut -d= -f2- || true)"
68
+ # Previous platform, read from the same state file as devzone: the trap
69
+ # must be able to restore it even if step 6 fails midway.
70
+ PLATFORM_BEFORE="$(grep -E '^platform=' "$STATE_FILE" 2>/dev/null | tail -1 | cut -d= -f2 || true)"
71
+ [ "$PLATFORM_BEFORE" = gitlab ] || PLATFORM_BEFORE=github
72
+ URL_BEFORE="$(grep -E '^gitlab_url=' "$STATE_FILE" 2>/dev/null | tail -1 | cut -d= -f2- || true)"
73
73
 
74
74
  usage() {
75
75
  cat <<'USAGE'
76
76
  devzone test-gitlab [--complet] [--statut]
77
77
 
78
- Essai de bout en bout du module gitlab et de la plateforme GitLab.
79
- --complet désactive gitlab, contrôle que rien ne reste, puis réinstalle
80
- --statut publie le résultat comme statut gitlab-integration sur HEAD (gh)
78
+ End-to-end test of the gitlab module and of the GitLab platform.
79
+ --complet disables gitlab, checks that nothing remains, then reinstalls
80
+ --statut publishes the result as the gitlab-integration status on HEAD (gh)
81
81
  USAGE
82
82
  }
83
83
 
84
- # Appel API GitLab : le jeton ne sort jamais dans un message ni dans un fichier
85
- # du clone. curl le reçoit en en-tête, comme le seed de gitlab.sh.
84
+ # GitLab API call: the token never appears in a message nor in a file of the
85
+ # clone. curl receives it in a header, as the seed of gitlab.sh does.
86
86
  api() {
87
- local methode="$1" chemin="$2"
87
+ local method="$1" path="$2"
88
88
  shift 2
89
- curl -sS --fail --request "$methode" --header "PRIVATE-TOKEN: ${JETON:-}" \
90
- "${URL}/api/v4${chemin}" "$@"
89
+ curl -sS --fail --request "$method" --header "PRIVATE-TOKEN: ${TOKEN:-}" \
90
+ "${URL}/api/v4${path}" "$@"
91
91
  }
92
92
 
93
- lire_jeton() {
94
- if [ ! -f "$FICHIER_JETON" ]; then
95
- RAISON="jeton root absent ($FICHIER_JETON) : lancer avec la commande devzone test-gitlab du PATH, ou régler DEVZONE_RACINE sur la racine du dépôt activé"
93
+ read_token() {
94
+ if [ ! -f "$TOKEN_FILE" ]; then
95
+ REASON="root token missing ($TOKEN_FILE): run with the devzone test-gitlab command of the PATH, or set DEVZONE_ROOT to the root of the enabled repository"
96
96
  return 1
97
97
  fi
98
- JETON="$(cat "$FICHIER_JETON")"
99
- if [ -z "$JETON" ]; then
100
- RAISON="jeton root vide ($FICHIER_JETON)"
98
+ TOKEN="$(cat "$TOKEN_FILE")"
99
+ if [ -z "$TOKEN" ]; then
100
+ REASON="root token empty ($TOKEN_FILE)"
101
101
  return 1
102
102
  fi
103
103
  return 0
104
104
  }
105
105
 
106
- # Remet la plateforme d'avant (github par défaut, ou l'instance GitLab avec son
107
- # URL). Le trap l'appelle aussi : une étape 6 interrompue ne laisse pas la
108
- # plateforme de l'utilisateur changée.
109
- restaurer_plateforme() {
110
- if [ "$PLATEFORME_AVANT" = gitlab ] && [ -n "$URL_AVANT" ]; then
111
- "$DEVZONE_BIN" platform gitlab --url "$URL_AVANT" >/dev/null 2>&1
106
+ # Restores the previous platform (github by default, or the GitLab instance with its
107
+ # URL). The trap calls it too: an interrupted step 6 does not leave the
108
+ # platform of the user changed.
109
+ restore_platform() {
110
+ if [ "$PLATFORM_BEFORE" = gitlab ] && [ -n "$URL_BEFORE" ]; then
111
+ "$DEVZONE_BIN" platform gitlab --url "$URL_BEFORE" >/dev/null 2>&1
112
112
  else
113
113
  "$DEVZONE_BIN" platform github >/dev/null 2>&1
114
114
  fi
115
115
  }
116
116
 
117
- # Nettoyage garanti : clé SSH jetable retirée de GitLab, dossiers temporaires
118
- # supprimés, plateforme d'avant restaurée. Même quand une étape a échoué.
119
- nettoyer() {
117
+ # Guaranteed cleanup: throwaway SSH key removed from GitLab, temporary folders
118
+ # deleted, previous platform restored. Even when a step failed.
119
+ cleanup() {
120
120
  local code=$? d
121
121
  trap - EXIT
122
- if [ -n "${CLE_ID:-}" ]; then
123
- api DELETE "/user/keys/$CLE_ID" >/dev/null 2>&1 || true
122
+ if [ -n "${KEY_ID:-}" ]; then
123
+ api DELETE "/user/keys/$KEY_ID" >/dev/null 2>&1 || true
124
124
  fi
125
- if [ "$PLATEFORME_CHANGEE" = 1 ]; then
126
- restaurer_plateforme || true
125
+ if [ "$PLATFORM_CHANGED" = 1 ]; then
126
+ restore_platform || true
127
127
  fi
128
128
  for d in ${TMP_DIRS[@]+"${TMP_DIRS[@]}"}; do
129
129
  [ -n "$d" ] && rm -rf "$d"
130
130
  done
131
131
  exit "$code"
132
132
  }
133
- trap nettoyer EXIT
133
+ trap cleanup EXIT
134
134
 
135
- # ---- Les étapes, une fonction par étape ----
135
+ # ---- The steps, one function per step ----
136
136
 
137
- # 1. Module : actif, sinon activé (l'activation installe aussi si besoin).
138
- etape_module() {
137
+ # 1. Module: active, otherwise enabled (the activation also installs if needed).
138
+ step_module() {
139
139
  if "$DEVZONE_BIN" is-enabled gitlab >/dev/null 2>&1; then
140
140
  return 0
141
141
  fi
142
142
  if ! "$DEVZONE_BIN" enable gitlab >/dev/null 2>&1; then
143
- RAISON="devzone enable gitlab a échoué"
143
+ REASON="devzone enable gitlab failed"
144
144
  return 1
145
145
  fi
146
146
  return 0
147
147
  }
148
148
 
149
- # 2. État : le module doit être prêt et son runner en ligne (sans runner, le
150
- # pipeline resterait en attente).
151
- etape_etat() {
152
- local etat
153
- etat="$(bash "$GITLAB" status 2>&1 || true)"
154
- if [[ "$etat" != *"prêt"* ]]; then
155
- RAISON="état : ${etat:-illisible}"
149
+ # 2. State: the module must be ready and its runner online (without a runner, the
150
+ # pipeline would wait forever).
151
+ step_state() {
152
+ local state
153
+ state="$(bash "$GITLAB" status 2>&1 || true)"
154
+ if [[ "$state" != *"ready"* ]]; then
155
+ REASON="state: ${state:-unreadable}"
156
156
  return 1
157
157
  fi
158
- if [[ "$etat" != *"runner en ligne"* ]]; then
159
- RAISON="runner hors ligne ($etat)"
158
+ if [[ "$state" != *"runner online"* ]]; then
159
+ REASON="runner offline ($state)"
160
160
  return 1
161
161
  fi
162
162
  return 0
163
163
  }
164
164
 
165
- # 3. Nom et relais : ssh et glab passent par le résolveur système ; curl et
166
- # git en HTTP résolvent *.localhost vers la boucle locale sans lire /etc/hosts.
167
- # gitlab.localhost doit donc pointer vers 127.0.0.1 ET les relais 8929/2224
168
- # doivent tourner dans le conteneur (gitlab.sh hote-poser, relay-start).
169
- etape_nom() {
170
- local hote ip_nom relais
171
- hote="$(getent hosts gitlab.localhost 2>/dev/null || true)"
172
- ip_nom="$(printf '%s\n' "$hote" | awk '{print $1; exit}')"
173
- if [ -z "$ip_nom" ]; then
174
- RAISON="gitlab.localhost non résolu (getent hosts)"
165
+ # 3. Name and relays: ssh and glab go through the system resolver; curl and
166
+ # git in HTTP resolve *.localhost to the loopback without reading /etc/hosts.
167
+ # gitlab.localhost must therefore point to 127.0.0.1 AND the relays 8929/2224
168
+ # must run in the container (gitlab.sh hote-poser, relay-start).
169
+ step_name() {
170
+ local host ip_name relays
171
+ host="$(getent hosts gitlab.localhost 2>/dev/null || true)"
172
+ ip_name="$(printf '%s\n' "$host" | awk '{print $1; exit}')"
173
+ if [ -z "$ip_name" ]; then
174
+ REASON="gitlab.localhost not resolved (getent hosts)"
175
175
  return 1
176
176
  fi
177
- if [ "$ip_nom" != "127.0.0.1" ]; then
178
- RAISON="gitlab.localhost résolu vers $ip_nom, attendu 127.0.0.1"
177
+ if [ "$ip_name" != "127.0.0.1" ]; then
178
+ REASON="gitlab.localhost resolves to $ip_name, expected 127.0.0.1"
179
179
  return 1
180
180
  fi
181
- if ! relais="$(bash "$GITLAB" relay-status 2>&1)"; then
182
- RAISON="gitlab.localhost pointe vers 127.0.0.1, mais ${relais:-relais gitlab arrêté}"
181
+ if ! relays="$(bash "$GITLAB" relay-status 2>&1)"; then
182
+ REASON="gitlab.localhost points to 127.0.0.1, but ${relays:-gitlab relay stopped}"
183
183
  return 1
184
184
  fi
185
185
  return 0
186
186
  }
187
187
 
188
- # 4. Pipeline : relance celui de devzone/demo sur main et attend success.
189
- etape_pipeline() {
190
- local reponse id web_url etat debut
191
- lire_jeton || return 1
192
- reponse="$(api POST "/projects/devzone%2Fdemo/pipeline" --data "ref=main" 2>/dev/null)" || {
193
- RAISON="création du pipeline de devzone/demo impossible"
188
+ # 4. Pipeline: starts the one of devzone/demo on main and waits for success.
189
+ step_pipeline() {
190
+ local response id web_url state start
191
+ read_token || return 1
192
+ response="$(api POST "/projects/devzone%2Fdemo/pipeline" --data "ref=main" 2>/dev/null)" || {
193
+ REASON="creation of the pipeline of devzone/demo impossible"
194
194
  return 1
195
195
  }
196
- id="$(printf '%s' "$reponse" | jq -r '.id // empty' 2>/dev/null || true)"
197
- web_url="$(printf '%s' "$reponse" | jq -r '.web_url // empty' 2>/dev/null || true)"
196
+ id="$(printf '%s' "$response" | jq -r '.id // empty' 2>/dev/null || true)"
197
+ web_url="$(printf '%s' "$response" | jq -r '.web_url // empty' 2>/dev/null || true)"
198
198
  if [ -z "$id" ]; then
199
- RAISON="réponse de création du pipeline sans identifiant"
199
+ REASON="pipeline creation response without id"
200
200
  return 1
201
201
  fi
202
- debut="$(date +%s)"
202
+ start="$(date +%s)"
203
203
  while :; do
204
- reponse="$(api GET "/projects/devzone%2Fdemo/pipelines/$id" 2>/dev/null || true)"
205
- etat="$(printf '%s' "$reponse" | jq -r '.status // empty' 2>/dev/null || true)"
206
- case "$etat" in
204
+ response="$(api GET "/projects/devzone%2Fdemo/pipelines/$id" 2>/dev/null || true)"
205
+ state="$(printf '%s' "$response" | jq -r '.status // empty' 2>/dev/null || true)"
206
+ case "$state" in
207
207
  success) return 0 ;;
208
208
  failed | canceled | skipped)
209
- RAISON="pipeline $etat : ${web_url:-$URL/devzone/demo/-/pipelines/$id}"
209
+ REASON="pipeline $state: ${web_url:-$URL/devzone/demo/-/pipelines/$id}"
210
210
  return 1
211
211
  ;;
212
212
  esac
213
- if [ $(( $(date +%s) - debut )) -ge "$DELAI_PIPELINE" ]; then
214
- RAISON="délai ${DELAI_PIPELINE} s dépassé (état ${etat:-inconnu}) : ${web_url:-$URL/devzone/demo/-/pipelines/$id}"
213
+ if [ $(( $(date +%s) - start )) -ge "$PIPELINE_TIMEOUT" ]; then
214
+ REASON="timeout ${PIPELINE_TIMEOUT} s exceeded (state ${state:-unknown}): ${web_url:-$URL/devzone/demo/-/pipelines/$id}"
215
215
  return 1
216
216
  fi
217
- sleep "$INTERVALLE"
217
+ sleep "$INTERVAL"
218
218
  done
219
219
  }
220
220
 
221
- # 5. Clones HTTP et SSH : clé ed25519 jetable déposée sur root, puis retirée
222
- # par le trap. Le clone HTTP s'authentifie en Basic oauth2 + jeton, fournie
223
- # par un assistant d'identifiants qui lit le fichier (un en-tête git
224
- # http.extraHeader passerait le jeton en clair dans les arguments d'un
225
- # processus) : le jeton ne paraît ni dans ces arguments, ni dans l'URL, ni
226
- # dans .git/config.
227
- etape_clones() {
228
- local d pub reponse
229
- lire_jeton || return 1
221
+ # 5. HTTP and SSH clones: throwaway ed25519 key placed on root, then removed
222
+ # by the trap. The HTTP clone authenticates with Basic oauth2 + token, provided
223
+ # by a credential helper that reads the file (a git http.extraHeader would pass
224
+ # the token in clear in the arguments of a process): the token appears neither
225
+ # in these arguments, nor in the URL, nor in .git/config.
226
+ step_clones() {
227
+ local d pub response
228
+ read_token || return 1
230
229
  d="$(mktemp -d "${TMPDIR:-/tmp}/devzone-test-gitlab-clones.XXXXXX")" || {
231
- RAISON="dossier temporaire impossible"
230
+ REASON="temporary directory impossible"
232
231
  return 1
233
232
  }
234
233
  TMP_DIRS+=("$d")
235
234
  if ! ssh-keygen -q -t ed25519 -N '' -f "$d/id_ed25519" >/dev/null 2>&1; then
236
- RAISON="génération de la clé ed25519 impossible"
235
+ REASON="ed25519 key generation impossible"
237
236
  return 1
238
237
  fi
239
238
  pub="$(cat "$d/id_ed25519.pub" 2>/dev/null || true)"
240
- reponse="$(api POST "/user/keys" --data-urlencode "title=devzone test-gitlab" \
239
+ response="$(api POST "/user/keys" --data-urlencode "title=devzone test-gitlab" \
241
240
  --data-urlencode "key=$pub" 2>/dev/null)" || {
242
- RAISON="dépôt de la clé SSH sur GitLab impossible"
241
+ REASON="SSH key upload to GitLab impossible"
243
242
  return 1
244
243
  }
245
- CLE_ID="$(printf '%s' "$reponse" | jq -r '.id // empty' 2>/dev/null || true)"
246
- if [ -z "$CLE_ID" ]; then
247
- RAISON="réponse de dépôt de clé sans identifiant"
244
+ KEY_ID="$(printf '%s' "$response" | jq -r '.id // empty' 2>/dev/null || true)"
245
+ if [ -z "$KEY_ID" ]; then
246
+ REASON="key upload response without id"
248
247
  return 1
249
248
  fi
250
249
  if ! git clone -q \
251
250
  -c "core.sshCommand=ssh -i $d/id_ed25519 -o UserKnownHostsFile=$d/known_hosts -o StrictHostKeyChecking=accept-new" \
252
251
  "ssh://git@gitlab.localhost:2224/devzone/demo.git" "$d/ssh-demo" >/dev/null 2>&1; then
253
- RAISON="clone SSH (ssh://git@gitlab.localhost:2224/devzone/demo.git) impossible"
252
+ REASON="SSH clone (ssh://git@gitlab.localhost:2224/devzone/demo.git) impossible"
254
253
  return 1
255
254
  fi
256
255
  if ! git -c credential.helper= \
257
- -c "credential.helper=!f() { echo username=oauth2; printf 'password='; cat \"$FICHIER_JETON\"; echo; }; f" \
256
+ -c "credential.helper=!f() { echo username=oauth2; printf 'password='; cat \"$TOKEN_FILE\"; echo; }; f" \
258
257
  clone -q "$URL/devzone/demo.git" "$d/http-demo" >/dev/null 2>&1; then
259
- RAISON="clone HTTP de devzone/demo impossible"
258
+ REASON="HTTP clone of devzone/demo impossible"
260
259
  return 1
261
260
  fi
262
- if grep -qF "$JETON" "$d/http-demo/.git/config" 2>/dev/null; then
263
- RAISON="le jeton a été écrit dans .git/config du clone"
261
+ if grep -qF "$TOKEN" "$d/http-demo/.git/config" 2>/dev/null; then
262
+ REASON="the token was written to .git/config of the clone"
264
263
  return 1
265
264
  fi
266
265
  return 0
267
266
  }
268
267
 
269
- # 6. Plateforme : gitlab (glab clone), puis retour à la plateforme d'avant ;
270
- # au retour à github, glab et sa configuration ne doivent plus être là.
271
- etape_plateforme() {
268
+ # 6. Platform: gitlab (glab clone), then back to the previous platform;
269
+ # when back to github, glab and its configuration must no longer be there.
270
+ step_platform() {
272
271
  local d
273
272
  d="$(mktemp -d "${TMPDIR:-/tmp}/devzone-test-gitlab-plateforme.XXXXXX")" || {
274
- RAISON="dossier temporaire impossible"
273
+ REASON="temporary directory impossible"
275
274
  return 1
276
275
  }
277
276
  TMP_DIRS+=("$d")
278
- PLATEFORME_CHANGEE=1
277
+ PLATFORM_CHANGED=1
279
278
  if ! "$DEVZONE_BIN" platform gitlab >/dev/null 2>&1; then
280
- RAISON="devzone platform gitlab a échoué"
279
+ REASON="devzone platform gitlab failed"
281
280
  return 1
282
281
  fi
283
282
  if ! "$GLAB" repo clone devzone/demo "$d/demo" >/dev/null 2>&1; then
284
- RAISON="glab repo clone devzone/demo a échoué"
283
+ REASON="glab repo clone devzone/demo failed"
285
284
  return 1
286
285
  fi
287
- if ! restaurer_plateforme; then
288
- RAISON="retour à la plateforme $PLATEFORME_AVANT impossible"
286
+ if ! restore_platform; then
287
+ REASON="return to platform $PLATFORM_BEFORE impossible"
289
288
  return 1
290
289
  fi
291
- if [ "$PLATEFORME_AVANT" = github ]; then
290
+ if [ "$PLATFORM_BEFORE" = github ]; then
292
291
  if [ -e "$GLAB" ] || [ -e "$HOME/.config/glab-cli" ]; then
293
- RAISON="glab ou sa configuration reste après le retour à github"
292
+ REASON="glab or its configuration remains after returning to github"
294
293
  return 1
295
294
  fi
296
295
  fi
297
- PLATEFORME_CHANGEE=0
296
+ PLATFORM_CHANGED=0
298
297
  return 0
299
298
  }
300
299
 
301
- # 7. Intégration repowarden : suite test/gitlab/ (#533) contre l'instance du
302
- # module, avec l'URL et le jeton en variables d'environnement. Absente à la
303
- # réf choisie → étape sautée, pas en échec.
304
- etape_repowarden() {
300
+ # 7. repowarden integration: test/gitlab/ suite (#533) against the instance of the
301
+ # module, with the URL and the token as environment variables. Missing at the
302
+ # chosen ref -> step skipped, not failed.
303
+ step_repowarden() {
305
304
  local d log bats_exit bats_output
306
- lire_jeton || return 1
305
+ read_token || return 1
307
306
  d="$(mktemp -d "${TMPDIR:-/tmp}/devzone-test-gitlab-repowarden.XXXXXX")" || {
308
- RAISON="dossier temporaire impossible"
307
+ REASON="temporary directory impossible"
309
308
  return 1
310
309
  }
311
310
  TMP_DIRS+=("$d")
312
311
  log="${TMPDIR:-/tmp}/devzone-test-gitlab-repowarden.log"
313
- if ! git clone -q --depth 1 --branch "$REF_REPOWARDEN" \
312
+ if ! git clone -q --depth 1 --branch "$REPOWARDEN_REF" \
314
313
  https://github.com/simdevWarden/repowarden.git "$d/repowarden" >/dev/null 2>&1; then
315
- RAISON="clone de repowarden (réf. $REF_REPOWARDEN) impossible"
314
+ REASON="clone of repowarden (ref $REPOWARDEN_REF) impossible"
316
315
  return 1
317
316
  fi
318
317
  if [ ! -d "$d/repowarden/test/gitlab" ]; then
319
- RAISON="test/gitlab absent à la réf. $REF_REPOWARDEN"
318
+ REASON="test/gitlab missing at ref $REPOWARDEN_REF"
320
319
  return 2
321
320
  fi
322
321
  if ! command -v bats >/dev/null 2>&1; then
323
- RAISON="bats introuvable"
322
+ REASON="bats not found"
324
323
  return 1
325
324
  fi
326
- if bats_output="$(REPOWARDEN_IT_GITLAB_URL="$URL" REPOWARDEN_IT_GITLAB_TOKEN="$JETON" \
325
+ if bats_output="$(REPOWARDEN_IT_GITLAB_URL="$URL" REPOWARDEN_IT_GITLAB_TOKEN="$TOKEN" \
327
326
  bats "$d/repowarden/test/gitlab/" 2>&1)"; then
328
327
  bats_exit=0
329
328
  else
330
329
  bats_exit=$?
331
330
  fi
332
- printf '%s' "$bats_output" | sed "s/${JETON}/TOKEN_MASQUE/g" > "$log"
331
+ printf '%s' "$bats_output" | sed "s/${TOKEN}/TOKEN_MASKED/g" > "$log"
333
332
  if [ "$bats_exit" -ne 0 ]; then
334
- RAISON="la suite test/gitlab a échoué (journal : $log)"
333
+ REASON="the test/gitlab suite failed (log: $log)"
335
334
  return 1
336
335
  fi
337
336
  return 0
338
337
  }
339
338
 
340
- # 8. --complet : désactivation d'abord, puis contrôle qu'il ne reste ni
341
- # namespace, ni conteneur, ni secrets, ni ligne /etc/hosts. Les étapes 1 à 7
342
- # réinstallent ensuite. Le namespace est suffixé par instance, comme gitlab.sh.
343
- etape_complet() {
344
- local restes="" instance namespace conteneurs
339
+ # 8. --complet: disabling first, then checks that no namespace, container, secret
340
+ # or /etc/hosts line remains. Steps 1 to 7 then reinstall. The namespace is
341
+ # suffixed per instance, as in gitlab.sh.
342
+ step_full() {
343
+ local leftovers="" instance namespace containers
345
344
  instance="${DEVZONE_INSTANCE:-devzone}"
346
345
  namespace="devzone-gitlab${INSTANCE_SUFFIX}"
347
346
  if ! "$DEVZONE_BIN" disable gitlab >/dev/null 2>&1; then
348
- restes="$restes désactivation en échec;"
347
+ leftovers="$leftovers disable failed;"
349
348
  fi
350
349
  if kubectl --context devzone get namespace "$namespace" >/dev/null 2>&1; then
351
- restes="$restes namespace $namespace;"
350
+ leftovers="$leftovers namespace $namespace;"
352
351
  fi
353
- conteneurs="$(gitlab_restes_conteneurs "$instance")"
354
- if [ -n "$conteneurs" ]; then
355
- restes="$restes conteneur(s) étiqueté(s) devzone.instance=$instance;"
352
+ containers="$(gitlab_restes_conteneurs "$instance")"
353
+ if [ -n "$containers" ]; then
354
+ leftovers="$leftovers labelled container(s) devzone.instance=$instance;"
356
355
  fi
357
356
  if [ -e "$SECRETS" ]; then
358
- restes="$restes $SECRETS;"
357
+ leftovers="$leftovers $SECRETS;"
359
358
  fi
360
359
  if grep -q '# devzone:gitlab' "$HOSTS" 2>/dev/null; then
361
- restes="$restes ligne /etc/hosts;"
360
+ leftovers="$leftovers /etc/hosts line;"
362
361
  fi
363
- if [ -n "$restes" ]; then
364
- RAISON="reste :$restes"
362
+ if [ -n "$leftovers" ]; then
363
+ REASON="remaining:$leftovers"
365
364
  return 1
366
365
  fi
367
366
  return 0
368
367
  }
369
368
 
370
- # ---- Cadre commun : chronomètre, mémorise ✔/✖/sauté + raison ----
369
+ # ---- Common frame: times, records ✔/✖/skipped + reason ----
371
370
 
372
- lancer_etape() {
373
- local nom="$1" fonction="$2" debut fin duree code symbole suffixe
374
- RAISON=""
375
- printf '▶ %s…\n' "$nom"
376
- debut="$(date +%s)"
377
- "$fonction"
371
+ run_step() {
372
+ local name="$1" func="$2" start end duration code symbol suffix
373
+ REASON=""
374
+ printf '▶ %s…\n' "$name"
375
+ start="$(date +%s)"
376
+ "$func"
378
377
  code=$?
379
- fin="$(date +%s)"
380
- duree=$((fin - debut))
378
+ end="$(date +%s)"
379
+ duration=$((end - start))
381
380
  case "$code" in
382
- 0) symbole="✔"; suffixe="" ;;
383
- 2) symbole="–"; suffixe=" — sauté : ${RAISON:-sans raison}" ;;
384
- *) symbole="✖"; ECHEC=1; suffixe=" — ${RAISON:-échec}" ;;
381
+ 0) symbol="✔"; suffix="" ;;
382
+ 2) symbol="–"; suffix=" — skipped: ${REASON:-no reason}" ;;
383
+ *) symbol="✖"; FAILED=1; suffix=" — ${REASON:-failed}" ;;
385
384
  esac
386
- NOMS+=("$nom")
387
- SYMBOLES+=("$symbole")
388
- DUREES+=("$duree")
389
- SUFFIXES+=("$suffixe")
390
- printf ' %s %s (%d s)%s\n' "$symbole" "$nom" "$duree" "$suffixe"
385
+ NAMES+=("$name")
386
+ SYMBOLS+=("$symbol")
387
+ DURATIONS+=("$duration")
388
+ SUFFIXES+=("$suffix")
389
+ printf ' %s %s (%d s)%s\n' "$symbol" "$name" "$duration" "$suffix"
391
390
  }
392
391
 
393
- # Résumé court pour le statut : jamais de jeton, une description < 140 signes.
394
- resume_court() {
395
- local i ok=0 ko=0 saute=0 premier_ko=""
396
- for i in "${!SYMBOLES[@]}"; do
397
- case "${SYMBOLES[$i]}" in
392
+ # Short summary for the status: never a token, a description < 140 characters.
393
+ short_summary() {
394
+ local i ok=0 failed=0 skipped=0 first_failed=""
395
+ for i in "${!SYMBOLS[@]}"; do
396
+ case "${SYMBOLS[$i]}" in
398
397
  ✔) ok=$((ok + 1)) ;;
399
- ✖) ko=$((ko + 1)); [ -n "$premier_ko" ] || premier_ko="${NOMS[$i]}" ;;
400
- *) saute=$((saute + 1)) ;;
398
+ ✖) failed=$((failed + 1)); [ -n "$first_failed" ] || first_failed="${NAMES[$i]}" ;;
399
+ *) skipped=$((skipped + 1)) ;;
401
400
  esac
402
401
  done
403
- if [ "$ko" -gt 0 ]; then
404
- printf '%d ✔, %d ✖ (%s), %d sauté — %d s' "$ok" "$ko" "$premier_ko" "$saute" "$TOTAL"
402
+ if [ "$failed" -gt 0 ]; then
403
+ printf '%d ✔, %d ✖ (%s), %d skipped — %d s' "$ok" "$failed" "$first_failed" "$skipped" "$TOTAL"
405
404
  else
406
- printf '%d ✔, %d sauté — %d s' "$ok" "$saute" "$TOTAL"
405
+ printf '%d ✔, %d skipped — %d s' "$ok" "$skipped" "$TOTAL"
407
406
  fi
408
407
  }
409
408
 
410
- resume() {
411
- local i ok=0 ko=0 saute=0
409
+ summary() {
410
+ local i ok=0 failed=0 skipped=0
412
411
  echo
413
- echo "devzone test-gitlab : résumé"
414
- for i in "${!SYMBOLES[@]}"; do
415
- printf ' %s %-28s %3d s%s\n' "${SYMBOLES[$i]}" "${NOMS[$i]}" "${DUREES[$i]}" "${SUFFIXES[$i]}"
416
- case "${SYMBOLES[$i]}" in
412
+ echo "devzone test-gitlab : summary"
413
+ for i in "${!SYMBOLS[@]}"; do
414
+ printf ' %s %-28s %3d s%s\n' "${SYMBOLS[$i]}" "${NAMES[$i]}" "${DURATIONS[$i]}" "${SUFFIXES[$i]}"
415
+ case "${SYMBOLS[$i]}" in
417
416
  ✔) ok=$((ok + 1)) ;;
418
- ✖) ko=$((ko + 1)) ;;
419
- *) saute=$((saute + 1)) ;;
417
+ ✖) failed=$((failed + 1)) ;;
418
+ *) skipped=$((skipped + 1)) ;;
420
419
  esac
421
420
  done
422
- printf ' total : %d étape(s), %d s, %d ✔, %d ✖, %d sauté\n' \
423
- "${#NOMS[@]}" "$TOTAL" "$ok" "$ko" "$saute"
421
+ printf ' total: %d step(s), %d s, %d ✔, %d ✖, %d skipped\n' \
422
+ "${#NAMES[@]}" "$TOTAL" "$ok" "$failed" "$skipped"
424
423
  }
425
424
 
426
- # --statut : publie le résultat sur le commit HEAD du dépôt courant, par l'API
427
- # GitHub de gh (jeton du mainteneur). Refus clair si gh n'est pas connecté.
428
- publier_statut() {
429
- local depot sha etat description
425
+ # --statut: publishes the result on the HEAD commit of the current repository, through
426
+ # the GitHub API of gh (maintainer token). Clear refusal if gh is not logged in.
427
+ publish_status() {
428
+ local repo sha state description
430
429
  if ! gh auth status >/dev/null 2>&1; then
431
- echo "devzone test-gitlab : gh non connecté, statut gitlab-integration non publié (gh auth login -s workflow)" >&2
430
+ echo "devzone test-gitlab : gh not logged in, gitlab-integration status not published (gh auth login -s workflow)" >&2
432
431
  return 1
433
432
  fi
434
- depot="$(gh repo view --json nameWithOwner -q .nameWithOwner 2>/dev/null || true)"
435
- if [ -z "$depot" ]; then
436
- echo "devzone test-gitlab : dépôt GitHub courant introuvable, statut non publié" >&2
433
+ repo="$(gh repo view --json nameWithOwner -q .nameWithOwner 2>/dev/null || true)"
434
+ if [ -z "$repo" ]; then
435
+ echo "devzone test-gitlab : current GitHub repository not found, status not published" >&2
437
436
  return 1
438
437
  fi
439
438
  sha="$(git rev-parse HEAD 2>/dev/null || true)"
440
439
  if [ -z "$sha" ]; then
441
- echo "devzone test-gitlab : commit HEAD introuvable, statut non publié" >&2
440
+ echo "devzone test-gitlab : HEAD commit not found, status not published" >&2
442
441
  return 1
443
442
  fi
444
- if [ "$ECHEC" -eq 0 ]; then etat=success; else etat=failure; fi
445
- description="$(resume_court)"
446
- if ! gh api -X POST "repos/$depot/statuses/$sha" \
447
- -f state="$etat" -f context=gitlab-integration -f description="$description" >/dev/null; then
448
- echo "devzone test-gitlab : publication du statut gitlab-integration impossible" >&2
443
+ if [ "$FAILED" -eq 0 ]; then state=success; else state=failure; fi
444
+ description="$(short_summary)"
445
+ if ! gh api -X POST "repos/$repo/statuses/$sha" \
446
+ -f state="$state" -f context=gitlab-integration -f description="$description" >/dev/null; then
447
+ echo "devzone test-gitlab : publishing the gitlab-integration status impossible" >&2
449
448
  return 1
450
449
  fi
451
- echo "devzone test-gitlab : statut gitlab-integration ($etat) publié sur $depot@$sha"
450
+ echo "devzone test-gitlab : gitlab-integration status ($state) published on $repo@$sha"
452
451
  }
453
452
 
454
- # ---- Options et déroulement ----
453
+ # ---- Options and run ----
455
454
 
456
455
  for arg in "$@"; do
457
456
  case "$arg" in
458
- --complet) COMPLET=1 ;;
459
- --statut) STATUT=1 ;;
457
+ --complet) FULL=1 ;;
458
+ --statut) PUBLISH=1 ;;
460
459
  -h | --help) usage; exit 0 ;;
461
460
  *)
462
- echo "devzone test-gitlab : option inconnue : $arg" >&2
461
+ echo "devzone test-gitlab : unknown option: $arg" >&2
463
462
  usage >&2
464
463
  exit 2
465
464
  ;;
466
465
  esac
467
466
  done
468
467
 
469
- DEBUT="$(date +%s)"
468
+ START_TIME="$(date +%s)"
470
469
 
471
- if [ "$COMPLET" = 1 ]; then
472
- lancer_etape "8. complet : désactivation" etape_complet
470
+ if [ "$FULL" = 1 ]; then
471
+ run_step "8. full: disable" step_full
473
472
  fi
474
- lancer_etape "1. module" etape_module
475
- lancer_etape "2. état" etape_etat
476
- lancer_etape "3. nom d'hôte" etape_nom
477
- lancer_etape "4. pipeline" etape_pipeline
478
- lancer_etape "5. clones HTTP et SSH" etape_clones
479
- lancer_etape "6. plateforme" etape_plateforme
480
- lancer_etape "7. intégration repowarden" etape_repowarden
473
+ run_step "1. module" step_module
474
+ run_step "2. state" step_state
475
+ run_step "3. host name" step_name
476
+ run_step "4. pipeline" step_pipeline
477
+ run_step "5. HTTP and SSH clones" step_clones
478
+ run_step "6. platform" step_platform
479
+ run_step "7. repowarden integration" step_repowarden
481
480
 
482
- TOTAL=$(( $(date +%s) - DEBUT ))
483
- resume
481
+ TOTAL=$(( $(date +%s) - START_TIME ))
482
+ summary
484
483
 
485
484
  CODE=0
486
- [ "$ECHEC" -eq 0 ] || CODE=1
487
- if [ "$STATUT" = 1 ]; then
488
- publier_statut || CODE=1
485
+ [ "$FAILED" -eq 0 ] || CODE=1
486
+ if [ "$PUBLISH" = 1 ]; then
487
+ publish_status || CODE=1
489
488
  fi
490
489
  exit "$CODE"