diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml new file mode 100644 index 0000000..cda403d --- /dev/null +++ b/.gitea/workflows/ci.yaml @@ -0,0 +1,61 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + check: + name: Vérification & lint + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Cache Cargo + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }} + restore-keys: ${{ runner.os }}-cargo- + + - name: Installation Rust stable + uses: dtolnay/rust-toolchain@stable + with: + components: clippy, rustfmt + + - name: Vérification compilation (cargo check) + run: cargo check --workspace + + - name: Lint (cargo clippy) + run: cargo clippy --workspace -- -D warnings + + - name: Format (cargo fmt) + run: cargo fmt --all -- --check + + test: + name: Tests + runs-on: ubuntu-latest + needs: check + steps: + - uses: actions/checkout@v4 + + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target/ + key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.toml') }} + + - uses: dtolnay/rust-toolchain@stable + + - name: Tests (cargo test) + run: cargo test --workspace + env: + DATABASE_URL: sqlite://:memory: diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml new file mode 100644 index 0000000..32d42f2 --- /dev/null +++ b/.gitea/workflows/release.yaml @@ -0,0 +1,110 @@ +name: Release + +on: + push: + tags: + - "v*" + +jobs: + build: + name: Build ${{ matrix.target }} + runs-on: ubuntu-latest + strategy: + matrix: + include: + - target: x86_64-unknown-linux-gnu + arch_label: amd64 + - target: aarch64-unknown-linux-gnu + arch_label: arm64 + - target: armv7-unknown-linux-gnueabihf + arch_label: armv7 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Installation Rust + cible cross + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + + - name: Installation cross + run: cargo install cross --git https://github.com/cross-rs/cross + + - name: Cache Cargo + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.toml') }} + + - name: Build backend + run: cross build --release --target ${{ matrix.target }} -p sentinelmesh-backend + + - name: Build agent-scan-network + run: cross build --release --target ${{ matrix.target }} -p agent-scan-network + + - name: Build agent-metric + run: cross build --release --target ${{ matrix.target }} -p agent-metric + + - name: Renommage des binaires + run: | + mkdir -p dist + cp target/${{ matrix.target }}/release/sentinelmesh-backend dist/sentinelmesh-backend-${{ matrix.arch_label }} + cp target/${{ matrix.target }}/release/agent-scan-network dist/agent-scan-network-${{ matrix.arch_label }} + cp target/${{ matrix.target }}/release/agent-metric dist/agent-metric-${{ matrix.arch_label }} + + - name: Upload artefacts + uses: actions/upload-artifact@v3 + with: + name: binaries-${{ matrix.arch_label }} + path: dist/ + + release: + name: Création de la release Gitea + runs-on: ubuntu-latest + needs: build + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Téléchargement des artefacts + uses: actions/download-artifact@v3 + with: + path: dist/ + + - name: Mise à plat des binaires + run: | + mkdir -p release + find dist/ -type f -exec cp {} release/ \; + ls -la release/ + + - name: Création de la release + uses: actions/gitea-release@v1 + with: + token: ${{ secrets.GITEA_TOKEN }} + tag_name: ${{ github.ref_name }} + release_name: "SentinelMesh ${{ github.ref_name }}" + body: | + ## SentinelMesh ${{ github.ref_name }} + + ### Binaires disponibles + + | Composant | amd64 | arm64 | armv7 (Raspberry Pi) | + |-----------|-------|-------|----------------------| + | Backend | ✅ | ✅ | ✅ | + | agent-scan-network | ✅ | ✅ | ✅ | + | agent-metric | ✅ | ✅ | ✅ | + + ### Installation rapide + + ```bash + curl -fsSL http://:8080/install.sh | sudo bash -s -- \ + --server http://:8080 \ + --token \ + --agent-type scan-network + ``` + files: release/* + draft: false + prerelease: false diff --git a/ROADMAP.md b/ROADMAP.md index 9c1ebc3..255ec40 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -41,13 +41,15 @@ - [ ] Icônes locales par type d'équipement — Phase 4+ - [ ] Favoris / personnalisation par équipement — Phase 4+ -## Phase 5 — Déploiement & Distribution +## Phase 5 — Déploiement & Distribution ✅ -- [ ] Script d'installation agents -- [ ] Gestion des mises à jour -- [ ] Docker Compose production -- [ ] Build multi-arch (amd64, arm64, Raspberry Pi) -- [ ] CI/CD Gitea +- [x] `install/install.sh` : script complet (détection arch, téléchargement, config, systemd, enregistrement) +- [x] `install/uninstall.sh` : désinstallation propre +- [x] Docker Compose production (healthcheck, réseau, volumes nommés) +- [x] `docker-compose.dev.yml` : profil développement +- [x] Dockerfiles agents multi-arch (amd64, arm64, armv7 Raspberry Pi) +- [x] `.gitea/workflows/ci.yaml` : check + clippy + fmt + tests sur push/PR +- [x] `.gitea/workflows/release.yaml` : build multi-arch + release Gitea sur tag v* ## Phase 6 — Extensions