bundleDependencies d'un paquet *workspace* est instable selon l'environnement npm
(mode -w, exécution en root sur un runner CI) : npm voyait shared comme un lien
workspace et n'embarquait AUCUN fichier ("bundled files: 0"), publiant un tarball
cassé — `Cannot find module '@arboretum/shared'` au démarrage chez le consommateur.
C'est ce que détectait (à juste titre) le job pack-smoke.
Nouveau mécanisme, identique sur tout environnement : scripts/inline-shared.mjs
(hook prepack) copie le JS compilé de shared dans dist/_shared/ et réécrit l'import
bare '@arboretum/shared' des .js du serveur vers ce chemin relatif. shared passe en
devDependency (résolu en dev via le symlink workspace, jamais exigé du consommateur).
Plus de node_modules embarqué ni de symlink dans le tarball.
ci.yml (pack-smoke) packe désormais en -w (comme release.yml) et asserte l'autonomie
(dist/_shared présent + zéro import bare) avant le boot smoke.
Validé de bout en bout sur checkout propre : npm ci + build + pack -w + install dans
projet vierge + boot -> HTTP 401, et 263 tests verts.
84 lines
2.9 KiB
YAML
84 lines
2.9 KiB
YAML
# CI Arboretum : build + tests sur Node 22/24, puis smoke de packaging npx.
|
|
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
test:
|
|
name: Build & test (Node ${{ matrix.node }})
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
node: [22, 24]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ matrix.node }}
|
|
cache: npm
|
|
- run: npm ci
|
|
- run: npm run typecheck
|
|
- run: npm run build
|
|
- run: npx vitest run
|
|
|
|
pack-smoke:
|
|
name: Pack & boot smoke (Node 22)
|
|
runs-on: ubuntu-latest
|
|
needs: test
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
cache: npm
|
|
- run: npm ci
|
|
- run: npm run build
|
|
# @arboretum/shared (paquet workspace NON publié) est INLINÉ dans dist/_shared au prepack
|
|
# (scripts/inline-shared.mjs) : le tarball est 100 % autonome — aucun node_modules embarqué,
|
|
# aucune bundleDependency, aucun symlink. On packe en mode workspace (-w), EXACTEMENT comme
|
|
# le fait « npm publish » dans release.yml, puis on l'installe seul comme un vrai consommateur.
|
|
- name: Pack tarball
|
|
run: |
|
|
rm -rf /tmp/tarballs && mkdir -p /tmp/tarballs
|
|
npm pack -w @johanleroy/git-arboretum --pack-destination /tmp/tarballs
|
|
ls -l /tmp/tarballs
|
|
- name: Assert the package is self-contained (@arboretum/shared inlined)
|
|
run: |
|
|
tgz=$(ls /tmp/tarballs/*.tgz)
|
|
rm -rf /tmp/inspect && mkdir -p /tmp/inspect && tar -xzf "$tgz" -C /tmp/inspect
|
|
test -f /tmp/inspect/package/dist/_shared/index.js \
|
|
|| { echo "ERREUR: dist/_shared/index.js absent de $tgz — inline-shared n'a pas tourné ?"; exit 1; }
|
|
if grep -rq '@arboretum/shared' /tmp/inspect/package/dist; then
|
|
echo "ERREUR: import bare '@arboretum/shared' encore présent dans le JS publié"
|
|
grep -rn '@arboretum/shared' /tmp/inspect/package/dist; exit 1
|
|
fi
|
|
echo "OK: paquet autonome — shared inliné dans dist/_shared, aucun import externe"
|
|
- name: Install tarball in an empty project
|
|
run: |
|
|
mkdir /tmp/smoke
|
|
cd /tmp/smoke
|
|
npm init -y
|
|
npm i /tmp/tarballs/*.tgz
|
|
- name: Boot smoke (expect 401 on /api/v1/sessions)
|
|
run: |
|
|
cd /tmp/smoke
|
|
timeout 30 node_modules/.bin/arboretum --port 7999 --db ./t.db &
|
|
server_pid=$!
|
|
code=000
|
|
for i in $(seq 1 20); do
|
|
sleep 0.5
|
|
code=$(curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:7999/api/v1/sessions || true)
|
|
if [ "$code" = "401" ]; then break; fi
|
|
done
|
|
echo "GET /api/v1/sessions -> HTTP $code"
|
|
kill "$server_pid" 2>/dev/null || true
|
|
test "$code" = "401"
|