From b843cb602b3538d704115b5cd022a72f16461b10 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Sat, 19 Sep 2026 00:33:12 +0200 Subject: [PATCH] Publish all sheet builds as Jenkins artifacts --- .gitignore | 1 + Jenkinsfile | 35 ++++++++++++++++++++++++++++++++++ README.md | 19 ++++++++++++++++++ TASKS.md | 1 + tests/test_publish_builds.py | 30 +++++++++++++++++++++++++++++ tests/test_tabs.mjs | 4 +++- tools/publish_builds.py | 37 ++++++++++++++++++++++++++++++++++++ 7 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 Jenkinsfile create mode 100644 tests/test_publish_builds.py create mode 100644 tools/publish_builds.py diff --git a/.gitignore b/.gitignore index 812c7d8..5449f11 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ __pycache__/ # Distribution / packaging .Python build/ +/RPG/d10_character_sheet/ develop-eggs/ dist/ downloads/ diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..96714d7 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,35 @@ +pipeline { + agent any + + options { + skipDefaultCheckout(true) + timestamps() + } + + stages { + stage('Checkout') { + steps { + deleteDir() + checkout scm + } + } + stage('Dependencies') { + steps { + sh 'python3 -m venv .venv' + sh '.venv/bin/python -m pip install -r requirements.txt' + } + } + stage('Build and verify') { + steps { + sh '.venv/bin/python -m unittest discover -s tests -v' + sh '.venv/bin/python tools/publish_builds.py' + sh 'D10_BUILD_ROOT=RPG/d10_character_sheet node tests/test_tabs.mjs' + } + } + stage('Publish') { + steps { + archiveArtifacts artifacts: 'RPG/d10_character_sheet/**', fingerprint: true, onlyIfSuccessful: true + } + } + } +} diff --git a/README.md b/README.md index 7013728..3fadf06 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,25 @@ puis reconstruire avec `--asset-base-url` pointant vers leur dossier : Le HTML généré référence alors les deux URL complètes. Charger ce HTML dans l'éditeur Roll20 avec le CSS et la traduction. +## Publication Jenkins + +L'agent Jenkins doit disposer de Python 3 avec `venv` et de Node.js. Le +`Jenkinsfile` exécute les tests, construit les deux variantes dans les 20 +thèmes et archive tous les résultats sous `RPG/d10_character_sheet/`. Le +dossier `RPG/d10_character_sheet/assets/` contient les deux PNG originaux. Les +fichiers HTML, CSS et JSON de chaque build sont dans +`RPG/d10_character_sheet///`. La commande locale équivalente +est : + +```sh +.venv/bin/python tools/publish_builds.py +D10_BUILD_ROOT=RPG/d10_character_sheet node tests/test_tabs.mjs +``` + +Jenkins expose ces fichiers comme artifacts du job. Après avoir obtenu une URL +HTTPS publique et stable pour le dossier `assets/`, reconstruire les feuilles +cyberpunk avec `--asset-base-url` afin que les images fonctionnent dans Roll20. + ## Vérifier ```sh diff --git a/TASKS.md b/TASKS.md index 18d5d75..0b7c1d6 100644 --- a/TASKS.md +++ b/TASKS.md @@ -16,6 +16,7 @@ - [x] Restore readable labels in night-theme repeating rows after Roll20 restructures their fieldsets. - [x] Add cyberpunk skill category subtabs for the full catalogue, preserving fixed skills and repeating fields. - [x] Map all supplied corporation palettes into the D10 theme model and add a saved cyberpunk theme selector. +- [x] Add Jenkins artifact publication under RPG/d10_character_sheet/ for both variants, all themes, and the original body images. ## Live Roll20 checks after local verification diff --git a/tests/test_publish_builds.py b/tests/test_publish_builds.py new file mode 100644 index 0000000..db3d9e1 --- /dev/null +++ b/tests/test_publish_builds.py @@ -0,0 +1,30 @@ +from pathlib import Path +import sys +import tempfile +import unittest + +sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'tools')) +import build +import publish_builds + + +class PublishBuildsTests(unittest.TestCase): + def test_complete_artifact_tree(self): + themes = build.read_yaml(build.DATA / 'themes.yaml')['themes'] + with tempfile.TemporaryDirectory() as tmp: + root = publish_builds.publish(Path(tmp) / 'RPG' / 'd10_character_sheet') + for kind in ('health', 'armor'): + filename = f'robotman_{kind}_r.png' + self.assertEqual((root / 'assets' / filename).read_bytes(), + (build.ASSETS / filename).read_bytes()) + for variant in ('base', 'cyberpunk'): + self.assertEqual({path.name for path in (root / variant).iterdir()}, set(themes)) + for theme in themes: + target = root / variant / theme + self.assertTrue((target / 'sheet.html').is_file()) + self.assertTrue((target / 'sheet.css').is_file()) + build.build(variant, theme, target, check=True) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/test_tabs.mjs b/tests/test_tabs.mjs index eb83a73..437c515 100644 --- a/tests/test_tabs.mjs +++ b/tests/test_tabs.mjs @@ -2,11 +2,13 @@ import assert from 'node:assert/strict'; import { readFileSync } from 'node:fs'; import vm from 'node:vm'; +const buildRoot = process.env.D10_BUILD_ROOT ?? 'build'; + for (const variant of ['base', 'cyberpunk']) { const tabs = variant === 'base' ? ['skills', 'combat'] : ['skills', 'combat', 'other']; const skillTabs = variant === 'base' ? ['fight', 'free', 'magic', 'equipment'] : []; const categoryTabs = variant === 'cyberpunk' ? ['physique', 'intellectuelles', 'social'] : []; - const html = readFileSync(`build/${variant}/parchment/sheet.html`, 'utf8'); + const html = readFileSync(`${buildRoot}/${variant}/parchment/sheet.html`, 'utf8'); const script = html.match(/