Publish all sheet builds as Jenkins artifacts

This commit is contained in:
Dandaedre 2026-09-19 00:33:12 +02:00
parent b9cdf09ff0
commit b843cb602b
Signed by: Dandaedre
GPG Key ID: 440C6592E8A26D99
7 changed files with 126 additions and 1 deletions

1
.gitignore vendored
View File

@ -10,6 +10,7 @@ __pycache__/
# Distribution / packaging
.Python
build/
/RPG/d10_character_sheet/
develop-eggs/
dist/
downloads/

35
Jenkinsfile vendored Normal file
View File

@ -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
}
}
}
}

View File

@ -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/<variante>/<thème>/`. 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

View File

@ -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

View File

@ -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()

View File

@ -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(/<script type="text\/worker">\s*([\s\S]*?)<\/script>/)?.[1];
assert.ok(script, `${variant}: generated sheet worker`);
const handlers = new Map();

37
tools/publish_builds.py Normal file
View File

@ -0,0 +1,37 @@
#!/usr/bin/env python3
"""Generate the complete artifact tree archived by Jenkins."""
import argparse
from pathlib import Path
import shutil
import build
DEFAULT_OUTPUT = build.ROOT / 'RPG' / 'd10_character_sheet'
def publish(output=DEFAULT_OUTPUT):
themes = build.read_yaml(build.DATA / 'themes.yaml')['themes']
output.mkdir(parents=True, exist_ok=True)
assets = output / 'assets'
assets.mkdir(exist_ok=True)
for kind in ('health', 'armor'):
filename = f'robotman_{kind}_r.png'
shutil.copyfile(build.ASSETS / filename, assets / filename)
for variant in ('base', 'cyberpunk'):
for theme in themes:
target = output / variant / theme
build.build(variant, theme, target)
build.build(variant, theme, target, check=True)
return output
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--output-dir', type=Path, default=DEFAULT_OUTPUT)
args = parser.parse_args()
print(publish(args.output_dir))
if __name__ == '__main__':
main()