Compare commits

..

No commits in common. "dev-test-2" and "master" have entirely different histories.

37 changed files with 86 additions and 688 deletions

View File

@ -1,42 +0,0 @@
name: dev-test-2
on:
push:
branches:
- '*'
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Set up SSH agent
uses: webfactory/ssh-agent@v0.9.1
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Trust Gitea host and force SSH for git.4nkweb.com
run: |
ssh-keyscan -H git.4nkweb.com >> ~/.ssh/known_hosts
git config --global url.ssh://git@git.4nkweb.com/.insteadOf https://git.4nkweb.com/
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-flags: --allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host
- name: Login to Gitea Registry
uses: docker/login-action@v3
with:
registry: git.4nkweb.com
username: ${{ secrets.USER }}
password: ${{ secrets.TOKEN }}
- name: Init submodules (ensure up-to-date)
run: |
git submodule sync --recursive
git submodule update --init --recursive
- name: Build and push images
env:
REGISTRY: git.4nkweb.com
run: |
DOCKER_TAG=$(git rev-parse --abbrev-ref HEAD)
bash scripts/build_and_push.sh "$DOCKER_TAG"

View File

@ -1,56 +0,0 @@
name: dev
push:
branches:
- '*'
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Set up SSH agent
uses: webfactory/ssh-agent@v0.9.1
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Trust Gitea host and force SSH for git.4nkweb.com
run: |
ssh-keyscan -H git.4nkweb.com >> ~/.ssh/known_hosts
git config --global url.ssh://git@git.4nkweb.com/.insteadOf https://git.4nkweb.com/
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-flags: --allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host
- name: Login to Gitea Registry
uses: docker/login-action@v3
with:
registry: git.4nkweb.com
username: ${{ secrets.USER }}
password: ${{ secrets.TOKEN }}
- name: Init submodules (ensure up-to-date)
run: |
echo "Sanitize submodule config"
ALLOWED_PATHS=$(git config -f .gitmodules --get-regexp '^submodule\..*\.path$' | awk '{print $3}' || true)
for NAME in $(git config --local --name-only --get-regexp '^submodule\..*\.path$' | sed 's/\.path$//' || true); do
P=$(git config --local --get "$NAME.path" || true)
if ! printf "%s\n" "$ALLOWED_PATHS" | grep -qx "$P"; then
echo "[ci] deinit orphan submodule: $P ($NAME)"
git submodule deinit -f -- "$P" || true
git config --local --remove-section "$NAME" || true
rm -rf ".git/modules/$P" || true
fi
done
git submodule sync --recursive
git submodule update --init --recursive
- name: Build and push images
env:
REGISTRY: git.4nkweb.com
run: |
BR=$(git rev-parse --abbrev-ref HEAD)
# garde la dernière composante après '/'
DOCKER_TAG=${BR##*/}
# normalise en minuscules et remplace les chars invalides par '-'
DOCKER_TAG=$(printf "%s" "$DOCKER_TAG" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9_.-]/-/g')
bash scripts/build_and_push.sh "$DOCKER_TAG"

2
.gitignore vendored
View File

@ -10,5 +10,3 @@ sdk_relay/
sdk_signer/
sdk_signer_client/
sdk_storage/
blindbit-oracle/
sp-client/

69
.gitmodules vendored
View File

@ -1,69 +0,0 @@
[submodule "bitcoin-core"]
path = modules/bitcoin-core
url = https://github.com/bitcoin/bitcoin.git
branch = master
[submodule "blindbit-oracle"]
path = modules/blindbit-oracle
url = https://github.com/setavenger/blindbit-oracle
branch = master
[submodule "sp-client"]
path = modules/sp-client
url = https://github.com/Sosthene00/sp-client.git
branch = dev
[submodule "sdk_common"]
path = modules/sdk_common
url = https://git.4nkweb.com/4nk/sdk_common.git
branch = dev
[submodule "sdk_client"]
path = modules/sdk_client
url = https://git.4nkweb.com/4nk/sdk_client.git
branch = dev
[submodule "sdk_relay"]
path = modules/sdk_relay
url = https://git.4nkweb.com/4nk/sdk_relay.git
branch = dev
[submodule "sdk_storage"]
path = modules/sdk_storage
url = https://git.4nkweb.com/4nk/sdk_storage.git
branch = dev
[submodule "sdk-signer-client"]
path = modules/sdk-signer-client
url = https://git.4nkweb.com/4nk/sdk-signer-client.git
branch = dev
[submodule "ihm_client"]
path = modules/ihm_client
url = https://git.4nkweb.com/4nk/ihm_client.git
branch = dev
[submodule "4NK_node"]
path = deploy/4NK_node
url = git@git.4nkweb.com:4nk/4NK_node.git
branch = dev
[submodule "4NK_IA"]
path = modules/4NK_IA
url = git@git.4nkweb.com:4nk/4NK_IA.git
branch = dev
[submodule "tor"]
path = modules/tor
url = https://github.com/torproject/tor.git
branch = main
[submodule "sdk_signer_client"]
path = modules/sdk_signer_client
url = https://git.4nkweb.com/4nk/sdk_signer_client.git
branch = dev
[submodule "4NK_template"]
path = deploy/4NK_template
url = https://git.4nkweb.com/4nk/4NK_template.git
branch = main
[submodule "4NK_wallet"]
path = projects/4NK_wallet/4NK_wallet
url = https://git.4nkweb.com/4nk/4NK_wallet.git
branch = main
[submodule "lecoffre-front"]
path = projects/lecoffre/lecoffre-front
url = https://git.4nkweb.com/4nk/lecoffre-front.git
branch = dev
[submodule "lecoffre-back-mini"]
path = projects/lecoffre/lecoffre-back-mini
url = https://git.4nkweb.com/4nk/lecoffre-back-mini.git
branch = dev

View File

@ -1,10 +0,0 @@
# Changelog - 4NK_dev
## [v2025.09.1] - 2025-09-10
- Normalisation des chemins des submodules (modules/, deploy/, projects/)
- Ajout CI dev-test (workflow Gitea) + scripts build/push
- Scripts de synchronisation et réajout des submodules
## [v2025.08.1] - 2025-08-28
- Initialisation des modules et standardisation agents
- Repos.csv + update_repos.sh

116
README.md
View File

@ -1,116 +0,0 @@
# 4NK Development Environment
Ce dépôt contient l'environnement de développement complet pour l'écosystème 4NK, incluant tous les modules SDK, clients et services.
## 🏗️ Architecture
### Projets SDK (Rust)
- **sdk_common** : Bibliothèque commune avec types et utilitaires partagés
- **sdk_client** : Client SDK principal avec support WASM (migration flate2 en cours)
- **sdk_storage** : Service de stockage distribué
- **sdk_signer** : Service de signature avec interface TypeScript
### Clients (Node.js/TypeScript)
- **sdk_signer_client** : Client TypeScript pour sdk_signer
- **ihm_client** : Interface utilisateur web
### Services
- **4NK_node** : Infrastructure Docker complète avec Bitcoin, Tor, et services 4NK
- **sdk_relay** : Service de relais pour la communication P2P
### Outils
- **4NK_template** : Template Docker pour les nouveaux projets
- **4NK_wallet** : Application wallet
## 🚀 Démarrage rapide
### Prérequis
- Docker et Docker Compose v2
- Rust (latest stable)
- Node.js 18+
- Git
### Installation
```bash
# Cloner le dépôt
git clone <repository-url>
cd 4NK_dev
# Configurer l'environnement
./setup_dev_env.sh
# Démarrer l'infrastructure
cd 4NK_node
./scripts/manage_services.sh start
```
## 📦 Gestion des dépendances WASM
### État actuel
- **sdk_common** : ✅ Migré vers `flate2` (remplace `zstd`)
- **sdk_client** : 🔄 Stub WASM temporaire avec `flate2` (en attente de migration complète)
- **sdk_signer** : ✅ Compatible avec le stub WASM
### Migration en cours
1. **Phase 1** : ✅ Migration `sdk_common` vers `flate2`
2. **Phase 2** : 🔄 Migration `sdk_client` vers `k256` et `flate2`
3. **Phase 3** : ⏳ Intégration complète WASM
4. **Phase 4** : ⏳ Déploiement
## 🛠️ Développement
### Compilation des projets
```bash
# Compiler tous les projets Rust
for project in sdk_common sdk_client sdk_storage; do
cd $project && cargo build --release && cd ..
done
# Compiler les projets Node.js
for project in sdk_signer sdk_signer_client ihm_client; do
cd $project && npm install && npm run build && cd ..
done
```
### Gestion des services
```bash
# Arrêter tous les services
cd 4NK_node && ./scripts/manage_services.sh stop
# Nettoyer l'environnement
./scripts/manage_services.sh clean
# Redémarrer les services
./scripts/manage_services.sh start
```
## 📚 Documentation
- [Résultats de compilation](COMPILATION_RESULTS.md) - Statut détaillé de tous les projets
- [Modules Docker](docs/modules.md) - Documentation des modules Docker
- [Changelog](CHANGELOG.md) - Historique des versions
## 🔧 Scripts utiles
- `setup_dev_env.sh` : Configuration de l'environnement de développement
- `update_repos.sh` : Mise à jour des dépôts depuis repos.csv
- `4NK_node/scripts/manage_services.sh` : Gestion des services Docker
## 📋 Structure des branches
- **main** : Branche principale pour 4NK_dev et 4NK_node
- **docker-support** : Branche de développement pour les SDKs et clients
- **dev** : Branche de développement pour certaines fonctionnalités
## 🤝 Contribution
1. Créer une branche depuis `docker-support` ou `main` selon le projet
2. Développer et tester localement
3. Pousser les modifications sur la branche appropriée
4. Créer une pull request
## 📄 Licence
MIT License - voir les fichiers LICENSE individuels dans chaque projet.

View File

@ -1 +0,0 @@
v2025.09.1

View File

@ -1,11 +0,0 @@
{
"folders": [
{
"path": ".."
},
{
"path": "../../.4nk_template"
}
],
"settings": {}
}

View File

@ -1,13 +0,0 @@
# Architecture
## Arborescence
- `modules/`: dépôts modulaires (SDK, clients, outils)
- `deploy/`: dépôts de déploiement (ex: `deploy/4NK_node`)
- `projects/<projet>/<repo>`: dépôts par projets (ex: `projects/lecoffre/...`)
## Principes
- Submodules décrits dans `.gitmodules` avec `path`, `url`, `branch`.
- CI centrale dans `/.gitea/workflows/` pour build/push Docker.
- Images taggées par `DOCKER_TAG`.

View File

@ -1,15 +0,0 @@
# Intégration Continue (CI)
## Workflow
- Fichier: `.gitea/workflows/dev.yml`
- Trigger unique: push sur nimporte quelle branche (`*`).
## Résolution de DOCKER_TAG
- Nom de la branche courante (la branche est le `DOCKER_TAG`).
## Build
- Script: `scripts/build_and_push.sh <DOCKER_TAG>` (obligatoire)
- Parcourt les submodules; build/push si `Dockerfile` présent.

View File

@ -1,13 +0,0 @@
# Développement local
## Prérequis
- Git + accès SSH à `git.4nkweb.com`
- Docker + Buildx
## Commandes utiles
- Synchroniser submodules: `git submodule sync --recursive`
- Initialiser/mettre à jour: `git submodule update --init --recursive`
- Déclencher CI via branche: `scripts/commit_tag_env.sh <tag>`
- Taguer tous les repos: `scripts/tag.sh <tag>`

View File

@ -1,6 +0,0 @@
# Registry Docker
- Registry: `git.4nkweb.com`
- Namespace: `4nk`
- Tagging: basé sur `DOCKER_TAG` (obligatoire)
- Politique: ne jamais utiliser ni modifier un tag Docker `dev`.

View File

@ -1,15 +0,0 @@
# FAQ
## Est-ce que la CI sapplique aux submodules ?
- Oui pour le build/push Docker (via 4NK_dev), non pour déclencher leur CI interne.
## Comment choisir le tag dimage ?
- Message de commit: `ci: docker_tag=<valeur>`
- Ou `.ci/tag.env` via branche dédiée
- Ou nom de la branche
## Le tag Docker `dev` est-il utilisé ?
- Non. Il ne doit jamais être utilisé ni modifié.

View File

@ -1,24 +0,0 @@
# 4NK_dev — Documentation du projet
## Objectif du dépôt
- Dépôt agrégateur des projets 4NK via submodules Git.
- Normalise larborescence: `modules/`, `deploy/`, `projects/<projet>/<repo>`.
- Centralise CI de build/push dimages Docker pour chaque submodule éligible.
## Contenu de la documentation
- Architecture: voir `architecture.md`
- Submodules: voir `submodules.md`
- CI et publication Docker: voir `ci.md`
- Registry et tags: voir `docker_registry.md`
- Versioning et release: voir `release_versioning.md`
- Développement local: voir `development.md`
- Scripts utilitaires: voir `scripts.md`
- FAQ: voir `faq.md`
## Conventions
- Lint Markdown appliqué.
- Pas dexemples dans la documentation.
- Les changements doivent toujours être décrits dans `CHANGELOG.md` et `VERSION`.

37
docs/modules.md Normal file
View File

@ -0,0 +1,37 @@
# Modules Docker (4NK_dev)
## 4NK_node
- Sappuie sur le `docker-compose.yml` existant dans `4NK_node/`.
- Scripts:
- `modules/4NK_node/build.sh` : construit les services avec `docker compose build`.
- `modules/4NK_node/up.sh` : démarre les services en détaché.
- `modules/4NK_node/down.sh` : arrête et nettoie les services.
- `modules/4NK_node/logs.sh` : affiche les logs (suivi).
- `modules/4NK_node/clean.sh` : down -v + prune dimages.
- Version/tag: lit `4NK_node/VERSION` si présent, sinon utilise `git describe` pour définir `COMPOSE_PROJECT_NAME`.
## 4NK_template
- Dockerfile multi-stage Node fourni dans `modules/4NK_template/Dockerfile`.
- Scripts:
- `modules/4NK_template/build.sh` : build de limage à partir de `4NK_template/`.
- `modules/4NK_template/run.sh` : exécute limage, mappe le port 3000.
- `modules/4NK_template/clean.sh` : supprime limage construite et fait un prune.
- Version/tag: lit `4NK_template/VERSION` si présent, sinon `git describe`.
## Prérequis
- Docker et Docker Compose (plugin) installés.
## Utilisation (séquentielle)
1. Construire 4NK_node
- `bash modules/4NK_node/build.sh`
2. Démarrer 4NK_node
- `bash modules/4NK_node/up.sh`
3. Construire 4NK_template
- `bash modules/4NK_template/build.sh`
4. Lancer 4NK_template
- `bash modules/4NK_template/run.sh`
5. Logs 4NK_node
- `bash modules/4NK_node/logs.sh`
6. Arrêt 4NK_node
- `bash modules/4NK_node/down.sh`

View File

@ -1,7 +0,0 @@
# Versioning & Release
- Fichier `VERSION` et `CHANGELOG.md` à jour à chaque modification significative.
- Tags Git:
- `dev`: pointe sur la tête de la branche `dev` (ne pas utiliser en Docker)
- Tags de CI: `dev` selon besoin
- Politique Docker: images taggées par `DOCKER_TAG` uniquement.

View File

@ -1,16 +0,0 @@
# Scripts
## build_and_push.sh
- Usage: `scripts/build_and_push.sh <DOCKER_TAG>` (obligatoire)
- Construit et pousse chaque submodule avec `Dockerfile`.
## tag.sh
- Usage: `scripts/tag.sh [TAG_NAME]` (défaut `dev-test`)
- Pose le tag sur le dépôt racine et tous les submodules.
## commit_tag_env.sh
- Usage: `scripts/commit_tag_env.sh <TAG_NAME>`
- Crée/checkout une branche du même nom et écrit `.ci/tag.env`.

View File

View File

@ -1 +0,0 @@
Subproject commit 0c8c0f1c390f4109a192c32f1da3fba07a204d12

@ -1 +0,0 @@
Subproject commit 2c8a478db4b84e03cc376e52f463b828ab9366f6

@ -1 +0,0 @@
Subproject commit a6a5e879ca0198931cbc6e5a1a8a76d9b653c532

@ -1 +0,0 @@
Subproject commit c8ac815e2bc1673468d476058137663b585600de

@ -1 +0,0 @@
Subproject commit 1c9c625bb6641ee7e12c81244553082d5e5c17ff

@ -1 +0,0 @@
Subproject commit c09135c4eb785fa5ef242cd106bb1e628d5f68fa

@ -1 +0,0 @@
Subproject commit e205229e9219f6c3ad322a462903d2a740731aa3

@ -1 +0,0 @@
Subproject commit a056d44cbf61f75f7c71add30d94e30168de7018

@ -1 +0,0 @@
Subproject commit 120a3dc8d0b8398a4c83e27e24eff14c76f66a8f

@ -1 +0,0 @@
Subproject commit b1710e7d16592e52a2a77618ceb4d56d5d51db8e

@ -1 +0,0 @@
Subproject commit 27d4ba90f6dbf0c80d518a358b9600ae789509e4

11
repos.csv Normal file
View File

@ -0,0 +1,11 @@
name,url,type,target,directory
sdk_storage,https://git.4nkweb.com/4nk/sdk_storage.git,branch,docker-support,sdk_storage
sdk_signer_client,https://git.4nkweb.com/4nk/sdk_signer_client.git,create_from,master->docker-support,sdk_signer_client
sdk_signer,https://git.4nkweb.com/4nk/sdk_signer.git,branch,docker-support,sdk_signer
ihm_client,https://git.4nkweb.com/4nk/ihm_client.git,branch,docker-support,ihm_client
sdk_relay,https://git.4nkweb.com/4nk/sdk_relay.git,branch,docker-support,sdk_relay
sdk_common,https://git.4nkweb.com/4nk/sdk_common.git,branch,docker-support,sdk_common
4NK_wallet,https://git.4nkweb.com/4nk/4NK_wallet.git,create_from,main->docker-support,4NK_wallet
sdk_client,https://git.4nkweb.com/4nk/sdk_client.git,branch,docker-support,sdk_client
4NK_template,https://git.4nkweb.com/4nk/4NK_template.git,branch,main,4NK_template
4NK_node,git@git.4nkweb.com:4nk/4NK_node.git,branch,main,4NK_node
1 name url type target directory
2 sdk_storage https://git.4nkweb.com/4nk/sdk_storage.git branch docker-support sdk_storage
3 sdk_signer_client https://git.4nkweb.com/4nk/sdk_signer_client.git create_from master->docker-support sdk_signer_client
4 sdk_signer https://git.4nkweb.com/4nk/sdk_signer.git branch docker-support sdk_signer
5 ihm_client https://git.4nkweb.com/4nk/ihm_client.git branch docker-support ihm_client
6 sdk_relay https://git.4nkweb.com/4nk/sdk_relay.git branch docker-support sdk_relay
7 sdk_common https://git.4nkweb.com/4nk/sdk_common.git branch docker-support sdk_common
8 4NK_wallet https://git.4nkweb.com/4nk/4NK_wallet.git create_from main->docker-support 4NK_wallet
9 sdk_client https://git.4nkweb.com/4nk/sdk_client.git branch docker-support sdk_client
10 4NK_template https://git.4nkweb.com/4nk/4NK_template.git branch main 4NK_template
11 4NK_node git@git.4nkweb.com:4nk/4NK_node.git branch main 4NK_node

View File

@ -1,99 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
REGISTRY=${REGISTRY:-git.4nkweb.com}
NAMESPACE=${NAMESPACE:-4nk}
# Support d'un paramètre positionnel prioritaire pour le tag
if [ "${1:-}" != "" ]; then
DOCKER_TAG="$1"
fi
if [ -z "${DOCKER_TAG:-}" ]; then
echo "[docker][erreur] DOCKER_TAG non défini (obligatoire). Fournissez-le en argument ou via l'environnement." >&2
exit 1
fi
# Normalisation du tag pour Docker (sécurité côté script)
DOCKER_TAG=${DOCKER_TAG##*/}
DOCKER_TAG=$(printf "%s" "$DOCKER_TAG" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9_.-]/-/g')
echo "[docker] registry=${REGISTRY} namespace=${NAMESPACE} tag=${DOCKER_TAG}"
if ! command -v docker >/dev/null 2>&1; then
echo "[docker][erreur] docker introuvable" >&2
exit 1
fi
if [ ! -f .gitmodules ]; then
echo "[docker][erreur] .gitmodules introuvable dans $(pwd)" >&2
exit 1
fi
# Prépare le répertoire de logs
LOG_DIR="log/ci/${DOCKER_TAG}"
mkdir -p "${LOG_DIR}"
SUMMARY_FILE="${LOG_DIR}/summary.txt"
: > "${SUMMARY_FILE}"
# Parcourt les submodules déclarés
mapfile -t submodules < <(git config -f .gitmodules --name-only --get-regexp 'submodule\..*\.path' | sed -E 's/\.path$//')
for name in "${submodules[@]}"; do
path=$(git config -f .gitmodules --get "${name}.path" || true)
url=$(git config -f .gitmodules --get "${name}.url" || true)
branch=$(git config -f .gitmodules --get "${name}.branch" || echo "master")
if [ -z "${path}" ] || [ -z "${url}" ]; then
echo "[docker][warn] entrée incomplète pour ${name}, ignoré" >&2
continue
fi
image_name=$(basename "${path}")
image_name_lc=$(printf "%s" "${image_name}" | tr '[:upper:]' '[:lower:]')
full_ref="${REGISTRY}/${NAMESPACE}/${image_name_lc}:${DOCKER_TAG}"
if [ ! -d "${path}" ]; then
echo "[docker][warn] sous-dossier ${path} manquant, on saute" >&2
continue
fi
mapfile -t dockerfiles < <(find "${path}" -type f -name Dockerfile | sort)
if [ ${#dockerfiles[@]} -eq 0 ]; then
echo "[docker] aucun Dockerfile dans ${path}, ignoré"
echo "skip $(basename \"${path}\")" >> "${SUMMARY_FILE}"
continue
fi
for df in "${dockerfiles[@]}"; do
df_dir=$(dirname "${df}")
rel_dir=${df_dir#${path}/}
if [ "${rel_dir}" = "${df_dir}" ]; then rel_dir=""; fi
suffix=""
if [ -n "${rel_dir}" ]; then
suffix="-$(echo "${rel_dir}" | tr '[:upper:]' '[:lower:]' | tr '/' '-')"
fi
image_name_variant="${image_name_lc}${suffix}"
full_ref_variant="${REGISTRY}/${NAMESPACE}/${image_name_variant}:${DOCKER_TAG}"
log_file="${LOG_DIR}/${image_name_variant}.log"
echo "[docker] build ${full_ref_variant} depuis ${df_dir} (branche ${branch}) | log: ${log_file}"
{
echo "== BUILD+PUSH ${full_ref_variant} =="
echo "context=${df_dir} dockerfile=${df}"
date -Is
docker buildx build \
--pull \
--ssh default \
--progress=plain \
--file "${df}" \
--tag "${full_ref_variant}" \
--push \
"${df_dir}"
} 2>&1 | tee -a "${log_file}"
echo "${full_ref_variant} ${log_file}" >> "${SUMMARY_FILE}"
done
done
echo "[docker] terminé"
echo "[docker] récapitulatif: ${SUMMARY_FILE}"

View File

@ -1,39 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
# Usage: ./scripts/commit_tag_env.sh <TAG_NAME>
if [ $# -lt 1 ]; then
echo "[ci] usage: $0 <TAG_NAME>" >&2
exit 1
fi
TAG_NAME="$1"
ROOT_DIR="/home/desk/code/4NK_dev"
TAG_BRANCH="$TAG_NAME"
cd "$ROOT_DIR"
echo "[ci] préparer la branche ${TAG_BRANCH} (source dev si besoin)"
git fetch origin --prune >/dev/null 2>&1 || true
if git show-ref --verify --quiet "refs/heads/${TAG_BRANCH}"; then
git checkout "${TAG_BRANCH}"
else
if git ls-remote --exit-code --heads origin "${TAG_BRANCH}" >/dev/null 2>&1; then
git checkout -b "${TAG_BRANCH}" "origin/${TAG_BRANCH}"
else
git checkout -B "${TAG_BRANCH}" "origin/dev"
fi
fi
echo "[ci] écrire .ci/tag.env avec DOCKER_TAG=${TAG_NAME}"
mkdir -p .ci
printf "DOCKER_TAG=%s\n" "$TAG_NAME" > .ci/tag.env
git add .ci/tag.env
git commit -m "ci(tag): set DOCKER_TAG=${TAG_NAME} in .ci/tag.env"
git push origin "HEAD:refs/heads/${TAG_BRANCH}"
echo "[ci] terminé: branche ${TAG_BRANCH} mise à jour"

View File

@ -1,6 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
git submodule update --init --recursive
echo "[readd] git submodule update --init --recursive terminé"

View File

@ -1,91 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
# Usage: ./tag.sh [TAG_NAME]
# Par défaut, TAG_NAME="dev-test"
TAG_NAME="${1:-dev-test}"
ROOT_DIR="/home/desk/code/4NK_dev"
print_info() { echo "[tag] $*"; }
print_warn() { echo "[tag][warn] $*"; }
delete_tag_if_exists() {
local tag="$1"
if git show-ref --tags --quiet --verify "refs/tags/${tag}"; then
git tag -d "${tag}" >/dev/null || true
git push origin ":refs/tags/${tag}" >/dev/null || true
fi
}
ensure_branch_checked_out() {
local branch="$1"
if git rev-parse --verify "origin/${branch}" >/dev/null 2>&1; then
git checkout "${branch}" >/dev/null 2>&1 || git checkout -b "${branch}" "origin/${branch}" >/dev/null 2>&1 || true
git pull --ff-only >/dev/null 2>&1 || true
else
print_info "branche ${branch} introuvable, utilisation de la branche courante"
fi
}
tag_current_repo() {
local tag="$1"
local ref_sha
ref_sha=$(git rev-parse --verify HEAD)
delete_tag_if_exists "${tag}"
git tag -a "${tag}" -m "CI ${tag} trigger" "${ref_sha}"
git push origin "refs/tags/${tag}"
}
get_submodule_names() {
git config -f .gitmodules --name-only --get-regexp 'submodule\..*\.path' | sed -E 's/\.path$//'
}
tag_root_repo() {
cd "${ROOT_DIR}"
print_info "repository racine: $(basename "${ROOT_DIR}") -> ${TAG_NAME}"
local dev_head
dev_head=$(git rev-parse --verify refs/heads/dev)
delete_tag_if_exists "${TAG_NAME}"
git tag -a "${TAG_NAME}" -m "CI ${TAG_NAME} trigger" "${dev_head}"
git push origin "refs/tags/${TAG_NAME}"
}
tag_submodules() {
print_info "lecture des submodules depuis .gitmodules"
local names
mapfile -t names < <(get_submodule_names)
for name in "${names[@]}"; do
local sm_path sm_url sm_branch
sm_path=$(git config -f .gitmodules --get "${name}.path" || true)
sm_url=$(git config -f .gitmodules --get "${name}.url" || true)
sm_branch=$(git config -f .gitmodules --get "${name}.branch" || echo dev)
if [ -z "${sm_path}" ] || [ -z "${sm_url}" ]; then
print_warn "entrée incomplète: ${name}, ignorée"
continue
fi
if [ ! -d "${sm_path}" ]; then
print_warn "dossier manquant: ${sm_path}, on saute"
continue
fi
print_info "${sm_path} (${sm_url}) -> ${TAG_NAME} sur branche ${sm_branch}"
(
cd "${sm_path}"
git fetch --all --prune >/dev/null 2>&1 || true
ensure_branch_checked_out "${sm_branch}"
tag_current_repo "${TAG_NAME}"
) || print_warn "échec sur ${sm_path}, on continue"
done
}
main() {
cd "${ROOT_DIR}"
tag_root_repo
tag_submodules
print_info "terminé: ${TAG_NAME} posé sur le repo racine et submodules accessibles"
}
main "$@"

View File

@ -1,26 +0,0 @@
# Plan de tests CI "dev-test"
## Objectifs
- Vérifier que le tag `dev-test` déclenche le workflow.
- Vérifier la synchronisation des submodules sur leurs branches.
- Vérifier la construction et le push des images Docker pour les submodules avec `Dockerfile`.
## Pré-requis
- Secrets `REGISTRY_USERNAME` et `REGISTRY_PASSWORD` configurés.
- Accès au registry `git.4nkweb.com`.
## Scénarios
1. Tag `dev-test` sur le dépôt parent
- Attendu: workflow lancé, logs de sync visibles.
2. Submodule avec `Dockerfile`
- Attendu: image buildée et poussée avec tag `dev-test`.
3. Submodule sans `Dockerfile`
- Attendu: ignoré proprement.
## Vérifications
- Présence des images `git.4nkweb.com/4nk/<submodule>:dev-test` dans le registry.
- Logs dexécution sans erreurs fatales.

38
update_repos.sh Executable file
View File

@ -0,0 +1,38 @@
#!/usr/bin/env bash
set -euo pipefail
CSV_FILE="repos.csv"
IFS=,
while read -r name url type target directory; do
if [ "$name" = "name" ]; then continue; fi
echo "\n[Repo] $name -> $directory"
if [ ! -d "$directory" ]; then
echo "[Clone] $url"
git clone --progress "$url" "$directory" || true
fi
echo "[Fetch] $directory"
git -C "$directory" fetch --all --prune --tags --progress || true
case "$type" in
branch)
echo "[Checkout] $target"
if git -C "$directory" show-ref --verify --quiet "refs/remotes/origin/$target"; then
git -C "$directory" checkout "$target" 2>/dev/null || git -C "$directory" checkout -B "$target" "origin/$target"
git -C "$directory" reset --hard "origin/$target"
else
echo "[Warn] Branche $target introuvable pour $name"
fi
;;
create_from)
base="${target%%->*}"
newb="${target##*->}"
echo "[Create] $newb depuis $base"
if git -C "$directory" show-ref --verify --quiet "refs/remotes/origin/$base"; then
git -C "$directory" checkout -B "$newb" "origin/$base"
else
echo "[Error] Base $base introuvable pour $name"
fi
;;
*)
echo "[Warn] Type inconnu: $type"
;;
esac
done < "$CSV_FILE"