-
Notifications
You must be signed in to change notification settings - Fork 0
148 lines (134 loc) · 5 KB
/
deploy.yml
File metadata and controls
148 lines (134 loc) · 5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: Compiler WASM et deployer sur GitHub Pages
on:
pull_request:
branches: ["main"]
push:
branches: ["main"]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build:
name: Compiler le source francais -> WebAssembly
runs-on: ubuntu-latest
steps:
- name: Cloner le depot
uses: actions/checkout@v4
- name: Configurer Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Configurer Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Installer multilingualprogramming[wasm]
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements-build.txt
- name: Compiler le source francais vers WebAssembly
run: python -m multilingualprogramming scripts/compile_wasm.ml
- name: Verifier les artefacts de compilation
run: |
ls -la public
test -f public/cellcosmos.wasm
- name: Verifier la syntaxe JavaScript
run: node --check public/ui.js
- name: Valider le WASM ou basculer sur JavaScript
run: |
node -e "
const fs = require('fs');
const wasmPath = 'public/cellcosmos.wasm';
const watPath = 'public/cellcosmos.wat';
const fallback = (message, detail) => {
console.warn(message);
if (detail) {
console.warn(detail);
}
if (fs.existsSync(wasmPath)) fs.unlinkSync(wasmPath);
if (fs.existsSync(watPath)) fs.unlinkSync(watPath);
console.log('Publication en mode JavaScript uniquement.');
process.exit(0);
};
if (!fs.existsSync(wasmPath)) {
fallback('WASM absent apres compilation.');
}
const bytes = fs.readFileSync(wasmPath);
const module = new WebAssembly.Module(bytes);
const importObject = {};
for (const entry of WebAssembly.Module.imports(module)) {
if (!importObject[entry.module]) {
importObject[entry.module] = {};
}
if (entry.kind === 'function') {
importObject[entry.module][entry.name] = () => 0;
} else if (entry.kind === 'memory') {
importObject[entry.module][entry.name] = new WebAssembly.Memory({ initial: 16 });
} else if (entry.kind === 'table') {
importObject[entry.module][entry.name] = new WebAssembly.Table({ initial: 0, element: 'anyfunc' });
} else if (entry.kind === 'global') {
importObject[entry.module][entry.name] = new WebAssembly.Global({ value: 'i32', mutable: true }, 0);
}
}
if (!importObject.env) {
importObject.env = {};
}
WebAssembly.instantiate(module, importObject).then((instance) => {
const exports = instance.exports;
const required = ['cellule_suivante', 'classe_wolfram'];
const missing = required.filter((name) => typeof exports[name] !== 'function');
if (missing.length) {
fallback('Exports WASM manquants.', missing.join(', '));
}
const transitionChecks = [
[90, 1, 0, 1, 0],
[90, 1, 0, 0, 1],
[30, 1, 1, 1, 0],
[30, 0, 1, 0, 1],
];
for (const [rule, left, center, right, expected] of transitionChecks) {
const actual = Number(exports.cellule_suivante(rule, left, center, right));
if (actual !== expected) {
fallback('Transition WASM invalide.', JSON.stringify({ rule, left, center, right, expected, actual }));
}
}
const classChecks = [
[30, 3],
[110, 4],
[255, 1],
[73, 2],
];
for (const [rule, expected] of classChecks) {
const actual = Number(exports.classe_wolfram(rule));
if (actual !== expected) {
fallback('Classification WASM invalide.', JSON.stringify({ rule, expected, actual }));
}
}
console.log('WASM smoke test OK');
}).catch((err) => {
fallback('Instantiation WASM impossible.', err && err.stack ? err.stack : String(err));
});
"
- name: Configurer GitHub Pages
uses: actions/configure-pages@v5
- name: Preparer l'artefact Pages
uses: actions/upload-pages-artifact@v3
with:
path: "public"
deploy:
name: Deployer sur GitHub Pages
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: build
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deployer sur GitHub Pages
id: deployment
uses: actions/deploy-pages@v4