From 3d61740f5acc5e2ec264840b0a01b5f5e45e8aa6 Mon Sep 17 00:00:00 2001 From: stilobique Date: Sun, 8 Nov 2026 14:08:59 +0100 Subject: [PATCH] Add simple CI --- .gitea/workflows/ci.yml | 82 +++++++++++++++++++++++++++++++++++++++++ .gitignore | 3 ++ CLAUDE.md | 3 ++ readme.md | 11 ++++++ tools/check-load.sh | 53 ++++++++++++++++++++++++++ 5 files changed, 152 insertions(+) create mode 100644 .gitea/workflows/ci.yml create mode 100755 tools/check-load.sh diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..dfcb65c --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,82 @@ +# Vérifications à chaque push / pull request, et release Gitea avec le paquet FreeStore +# sur un tag « vX.Y.Z » (qui doit correspondre à « version » dans manifest.json). +# Le téléversement sur la console FreeFactory reste manuel (pas d'API connue). +name: CI + +on: + push: + branches: ["**"] + tags: ["v*"] + pull_request: + +jobs: + check: + name: Vérifications et paquet + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Dépendances (Qt 5, qmllint, libfbxqml) + run: | + SUDO=$(command -v sudo || true) + $SUDO apt-get update -qq + DEBIAN_FRONTEND=noninteractive $SUDO apt-get install -y -qq --no-install-recommends \ + python3 git ca-certificates qmlscene qtdeclarative5-dev-tools \ + qml-module-qtquick2 qml-module-qtquick-window2 qml-module-qtmultimedia + git clone --depth 1 https://github.com/fbx/libfbxqml.git ../libfbxqml + + - name: Manifest, syntaxe QML/JS et paquet FreeStore + run: python3 tools/package.py + + - name: Chargement en HTTP, comme sur la box + run: tools/check-load.sh + + - name: Paquet en artefact + uses: actions/upload-artifact@v3 + with: + name: freestore-package + path: dist/*.tar.gz + + release: + name: Release Gitea + needs: check + if: startsWith(gitea.ref, 'refs/tags/v') + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Dépendances + run: | + SUDO=$(command -v sudo || true) + $SUDO apt-get update -qq + DEBIAN_FRONTEND=noninteractive $SUDO apt-get install -y -qq --no-install-recommends \ + python3 curl ca-certificates + + - name: Le tag correspond à la version du manifest + env: + TAG: ${{ gitea.ref_name }} + run: | + VERSION=$(python3 -c "import json; print(json.load(open('manifest.json'))['version'])") + if [ "$TAG" != "v$VERSION" ]; then + echo "Le tag $TAG ne correspond pas à la version du manifest (v$VERSION)." + exit 1 + fi + + - uses: actions/download-artifact@v3 + with: + name: freestore-package + path: dist + + - name: Créer la release et joindre le paquet + env: + TOKEN: ${{ secrets.GITHUB_TOKEN }} + API: ${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }} + TAG: ${{ gitea.ref_name }} + run: | + FILE=$(ls dist/*.tar.gz) + BODY=$(python3 -c "import json,sys; print(json.dumps({'tag_name': sys.argv[1], 'name': sys.argv[1], 'body': 'Paquet FreeStore à téléverser sur la console FreeFactory (http://factory.free.fr).'}))" "$TAG") + ID=$(curl -sSf -X POST -H "Authorization: token $TOKEN" -H "Content-Type: application/json" \ + "$API/releases" -d "$BODY" | python3 -c "import json,sys; print(json.load(sys.stdin)['id'])") + curl -sSf -X POST -H "Authorization: token $TOKEN" -F "attachment=@$FILE" \ + "$API/releases/$ID/assets?name=$(basename "$FILE")" > /dev/null + echo "Release $TAG créée avec $(basename "$FILE")." diff --git a/.gitignore b/.gitignore index bb4e3e4..e1db9bb 100644 --- a/.gitignore +++ b/.gitignore @@ -76,3 +76,6 @@ deploy.log # Paquets FreeStore (tools/package.py) dist/ + +# Environnement Python local (Rider) +.venv/ diff --git a/CLAUDE.md b/CLAUDE.md index 46a9d2b..4df7374 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -17,9 +17,12 @@ There is no build system or test suite. - `QT_QPA_PLATFORM=offscreen tools/run-local.sh` — headless run, useful to catch QML warnings. - HTTPS on the PC works with the system `qmlscene` (Qt 5.15 + OpenSSL 3). PyQt5 wheels from pip bundle a Qt built for OpenSSL 1.x and cannot do TLS here. - Lint: `qmllint Jellyfin.qml Components/*.qml Core/*.qml Shared/*.qml Views/*.qml` +- `tools/check-load.sh` — serves the repo over HTTP and loads it with `qmlscene` (offscreen, software renderer) like the box does; fails on any Qt warning not coming from libfbxqml. Run it after touching imports, `qmldir` files or singletons. - **Reproduce the box's loading mode**: the Player loads the app over HTTP, which behaves differently from local files (see constraints below). Check with `python3 -m http.server 8765 --directory .` then `QT_QPA_PLATFORM=offscreen qmlscene -I ../libfbxqml http://127.0.0.1:8765/Jellyfin.qml` — it must print no warnings. - The desktop has Qt 5.15 while the box targets QtQuick 2.5: code that runs locally can still use APIs too new for the box. +**CI** (`.gitea/workflows/ci.yml`, Gitea Actions on the `ubuntu-latest` runner image): on every push/PR, `tools/package.py` (manifest + qmllint + archive) and `tools/check-load.sh`, package uploaded as artifact (`upload-artifact@v3`/`download-artifact@v3`: v4 only works on recent Gitea versions). On tag `vX.Y.Z` matching `manifest.json` `version`, creates a Gitea release with the package attached (API calls with the job's `GITHUB_TOKEN`). Verified locally by replaying the `check` job's steps in a clean `ubuntu:24.04` container; the release job has not run yet. + **FreeStore package**: `tools/package.py` → `dist/.tar.gz` (gitignored). Replicates the QtCreator plugin's "Make FreeStore Package": same file selection as `Jellyfin.fbxproject` (QML/JS/images/fonts/`qmldir`/`manifest.json`, excluding `tools/` and hidden dirs), manifest checks (identifier `\w+(\.\w+)+`, `version` x.y.z equal to `Session.clientVersion`, entry-point files present), `qmllint` on all sources, ustar tar with directory entries, gzipped. Upload is manual on the FreeFactory console (http://factory.free.fr), followed by Free's review. **Deploying a test build to the Freebox**: `tools/deploy.py` (Python stdlib only; Player must be in developer mode). It discovers the Player via SSDP (`fbx:devel`) or takes `--box `, serves the repo over HTTP, calls JSON-RPC `debug_qml_app` on `http:///pub/devel`, and streams the app's stdout/stderr until it exits. `--server ` and `--user name[:password]` (both repeatable) serve a virtual `dev-config.json` next to the app; at startup `Session.loadDevConfig()` adds each listed server and stores users in `Session.devUsers`, which `UserSelectView` merges with public users (one-click sign-in when a password is given; never log passwords) (only when the app is loaded over HTTP; 404 otherwise, ignored) — the workaround for the lack of persistence in dev mode. Output is also written to `deploy.log` (repo root, gitignored, overwritten each run) — read it to diagnose on-box failures. The Player fetches files lazily from that HTTP server, so the script must keep running while the app is in use. This replicates the "Run" of the official QtCreator plugin, whose own setup is: diff --git a/readme.md b/readme.md index ab3877f..671c7e3 100644 --- a/readme.md +++ b/readme.md @@ -45,3 +45,14 @@ tools/package.py # crée dist/com.stilobique.jellyfin-.tar.gz Pour une nouvelle version, modifier `version` dans `manifest.json` **et** `clientVersion` dans `Core/Session.qml` (le script refuse de créer le paquet si elles diffèrent). Le script reproduit « Make FreeStore Package » du plugin QtCreator : il vérifie `manifest.json` et la syntaxe QML/JS (`qmllint`), puis crée l'archive à téléverser sur la console [FreeFactory](http://factory.free.fr) (compte développeur requis, validation par Free avant publication). + +## Intégration continue +Le workflow Gitea Actions `.gitea/workflows/ci.yml` : +- à chaque push / pull request : vérifie le manifest et la syntaxe QML/JS, charge l'application en HTTP comme le Player (`tools/check-load.sh`) et publie le paquet en artefact ; +- sur un tag `vX.Y.Z` (égal à la version du manifest) : crée une release Gitea avec le paquet FreeStore en pièce jointe. + +```bash +git tag v0.1.0 && git push origin v0.1.0 +``` + +Le téléversement sur la console FreeFactory reste manuel. diff --git a/tools/check-load.sh b/tools/check-load.sh new file mode 100755 index 0000000..ed56edb --- /dev/null +++ b/tools/check-load.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash +# Charge l'application comme le fait le Freebox Player (fichiers servis en HTTP) et échoue +# si Qt signale une erreur ou un avertissement venant de l'app. +# En HTTP, Qt ne peut pas lister les dossiers : c'est là qu'apparaissent les « X is not a type » +# (qmldir manquant) ou « Cyclic dependency » (singletons), invisibles en lançant depuis le disque. +# +# Usage : tools/check-load.sh (LIBFBXQML=… pour un autre emplacement de libfbxqml) +set -euo pipefail + +ROOT="$(cd "$(dirname "$0")/.." && pwd)" +LIBFBXQML="${LIBFBXQML:-$ROOT/../libfbxqml}" +QMLSCENE="${QMLSCENE:-$(command -v qmlscene || echo /usr/lib/qt5/bin/qmlscene)}" +DURATION="${DURATION:-6}" + +if [ ! -d "$LIBFBXQML/fbx" ]; then + echo "libfbxqml introuvable : git clone https://github.com/fbx/libfbxqml.git \"$LIBFBXQML\"" >&2 + exit 2 +fi + +WORK="$(mktemp -d)" +trap 'kill "$SERVER_PID" 2>/dev/null || true; rm -rf "$WORK"' EXIT + +# Serveur HTTP sur un port libre (choisi par le système). +python3 -I - "$ROOT" > "$WORK/port" <<'EOF' & +import functools, http.server, sys +class Quiet(http.server.SimpleHTTPRequestHandler): + def log_message(self, *args): + pass +server = http.server.ThreadingHTTPServer(("127.0.0.1", 0), functools.partial(Quiet, directory=sys.argv[1])) +print(server.server_address[1], flush=True) +server.serve_forever() +EOF +SERVER_PID=$! +for _ in $(seq 50); do [ -s "$WORK/port" ] && break; sleep 0.1; done +PORT="$(cat "$WORK/port")" + +echo "Chargement de http://127.0.0.1:$PORT/Jellyfin.qml pendant ${DURATION} s…" +# Rendu logiciel : la CI (conteneur) n'a pas d'OpenGL. +mkdir -p "$WORK/runtime" && chmod 700 "$WORK/runtime" +XDG_RUNTIME_DIR="$WORK/runtime" QT_QPA_PLATFORM=offscreen QT_QUICK_BACKEND=software \ + timeout "$DURATION" "$QMLSCENE" -I "$LIBFBXQML" \ + "http://127.0.0.1:$PORT/Jellyfin.qml" > "$WORK/output" 2>&1 || true + +# Messages attendus hors de la box : Settings de libfbxqml (pas d'objet App sur PC). +grep -v -e "/libfbxqml/" -e "^qml: Setting" -e "^qml: Getting settings failed" -e "^\s*$" \ + "$WORK/output" > "$WORK/problems" || true + +if [ -s "$WORK/problems" ]; then + echo "Échec : messages inattendus au chargement :" >&2 + cat "$WORK/problems" >&2 + exit 1 +fi +echo "OK : chargement sans erreur."