-
-
Notifications
You must be signed in to change notification settings - Fork 0
335 lines (277 loc) · 9.97 KB
/
build.yml
File metadata and controls
335 lines (277 loc) · 9.97 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
name: Build All Components
# Comprehensive build workflow for all Palimpsest License components
# Compiles SCSS, builds validators, converts assets, and uploads artefacts
on:
pull_request:
branches: [ main ]
push:
branches: [ main ]
release:
types: [published]
# Default permissions for all jobs (principle of least privilege)
permissions:
contents: read
jobs:
build-styles:
name: SCSS → CSS Compilation
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build CSS from SCSS (production)
run: npm run scss:build
- name: Verify CSS output
run: |
if [ ! -f "styles/css/main.css" ]; then
echo "❌ CSS build failed - output file not found"
exit 1
fi
echo "✅ CSS built successfully"
- name: Upload CSS artefacts
uses: actions/upload-artifact@v5
with:
name: compiled-css
path: |
styles/css/*.css
retention-days: 30
build-haskell:
name: Build Haskell Validators
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Haskell
uses: haskell-actions/setup@v2
with:
ghc-version: '9.6.3'
cabal-version: '3.10'
- name: Cache Cabal dependencies
uses: actions/cache@v4
with:
path: |
~/.cabal/packages
~/.cabal/store
TOOLS/validation/haskell/dist-newstyle
key: ${{ runner.os }}-cabal-${{ hashFiles('**/cabal.project', '**/palimpsest-validator.cabal') }}
restore-keys: |
${{ runner.os }}-cabal-
- name: Update Cabal
working-directory: TOOLS/validation/haskell
run: cabal update
- name: Build Haskell validators (release mode)
working-directory: TOOLS/validation/haskell
run: cabal build --enable-optimization=2
- name: Find and copy executable
shell: bash
run: |
mkdir -p build-output
# Find the built executable
if [ -d "TOOLS/validation/haskell/dist-newstyle" ]; then
find TOOLS/validation/haskell/dist-newstyle -type f -executable -name "palimpsest-validator*" -exec cp {} build-output/ \; || echo "No executables found yet"
fi
- name: Upload Haskell binaries
uses: actions/upload-artifact@v5
with:
name: haskell-validator-${{ matrix.os }}
path: build-output/*
retention-days: 30
if-no-files-found: warn
build-rescript:
name: Build ReScript Components
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '20'
cache: 'npm'
- name: Install root dependencies
run: npm ci
- name: Install ReScript dependencies
working-directory: rescript
run: npm ci
- name: Build ReScript components
working-directory: rescript
run: npm run build
- name: Verify ReScript build
run: |
if [ ! -d "rescript/lib" ]; then
echo "❌ ReScript build failed"
exit 1
fi
echo "✅ ReScript built successfully"
- name: Upload ReScript artefacts
uses: actions/upload-artifact@v5
with:
name: rescript-compiled
path: |
rescript/lib/**/*.js
rescript/lib/**/*.d.ts
retention-days: 30
build-documentation:
name: Build Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Generate table of contents for key docs
run: |
echo "Generating TOCs..."
npx markdown-toc -i README.md || echo "No TOC markers in README.md"
npx markdown-toc -i GOVERNANCE.md || echo "No TOC markers in GOVERNANCE.md"
npx markdown-toc -i CONTRIBUTING.md || echo "No TOC markers in CONTRIBUTING.md"
- name: Validate documentation links
run: |
echo "Validating internal documentation links..."
# This is a basic check - full validation in rsr-compliance.yml
find docs -name "*.md" -exec grep -l "\[.*\](.*)" {} \; | head -10
- name: Bundle documentation metadata
run: |
echo "Bundling documentation..."
mkdir -p build-output/docs
# Copy key documentation files
cp README.md build-output/docs/ || true
cp CLAUDE.md build-output/docs/ || true
cp GOVERNANCE.md build-output/docs/ || true
cp -r GUIDES_v0.4 build-output/docs/ || true
cp -r docs build-output/docs/reference || true
echo "✅ Documentation bundled"
- name: Upload documentation bundle
uses: actions/upload-artifact@v5
with:
name: documentation-bundle
path: build-output/docs
retention-days: 30
convert-assets:
name: Asset Conversion (SVG → PNG/JPG/TIFF)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install ImageMagick and librsvg
run: |
sudo apt-get update
sudo apt-get install -y imagemagick librsvg2-bin
- name: Convert SVG badges to PNG
run: |
echo "Converting SVG assets to PNG..."
mkdir -p build-output/assets
# Find all SVG files in assets
if [ -d "assets" ]; then
for svg in $(find assets -name "*.svg" 2>/dev/null || true); do
if [ -f "$svg" ]; then
basename=$(basename "$svg" .svg)
dirname=$(dirname "$svg")
outdir="build-output/$dirname"
mkdir -p "$outdir"
echo "Converting: $svg"
# PNG (web)
rsvg-convert -h 256 "$svg" -o "$outdir/${basename}.png" || echo "Failed to convert $svg to PNG"
# JPG (compatibility)
convert "$svg" -resize 256x256 -background white -flatten "$outdir/${basename}.jpg" || echo "Failed to convert $svg to JPG"
# TIFF (print quality)
convert "$svg" -resize 1024x1024 "$outdir/${basename}.tiff" || echo "Failed to convert $svg to TIFF"
fi
done
fi
echo "✅ Asset conversion complete"
- name: Upload converted assets
uses: actions/upload-artifact@v5
with:
name: converted-assets
path: build-output/assets
retention-days: 30
if-no-files-found: warn
build-metadata:
name: Build Metadata Package
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install jq
run: sudo apt-get update && sudo apt-get install -y jq
- name: Validate and bundle metadata
run: |
echo "Building metadata package..."
mkdir -p build-output/metadata
# Validate all JSON files first
for file in $(find METADATA_v0.4 metadata -name "*.json" 2>/dev/null || true); do
echo "Validating: $file"
jq empty "$file" || exit 1
done
# Copy metadata files
if [ -d "METADATA_v0.4" ]; then
cp -r METADATA_v0.4 build-output/metadata/
fi
if [ -d "metadata" ]; then
cp -r metadata/* build-output/metadata/ 2>/dev/null || true
fi
echo "✅ Metadata package built"
- name: Upload metadata package
uses: actions/upload-artifact@v5
with:
name: metadata-package
path: build-output/metadata
retention-days: 30
build-summary:
name: Build Summary
runs-on: ubuntu-latest
needs: [build-styles, build-haskell, build-rescript, build-documentation, convert-assets, build-metadata]
if: always()
steps:
- name: Download all artefacts
uses: actions/download-artifact@v6
with:
path: all-artefacts
- name: Display build results
run: |
echo "============================================"
echo "🔨 BUILD RESULTS"
echo "============================================"
echo ""
echo "CSS compilation: ${{ needs.build-styles.result }}"
echo "Haskell validators: ${{ needs.build-haskell.result }}"
echo "ReScript components: ${{ needs.build-rescript.result }}"
echo "Documentation: ${{ needs.build-documentation.result }}"
echo "Asset conversion: ${{ needs.convert-assets.result }}"
echo "Metadata package: ${{ needs.build-metadata.result }}"
echo ""
echo "Built artefacts:"
find all-artefacts -type f | head -20
echo ""
echo "============================================"
# Fail if critical builds failed
if [ "${{ needs.build-styles.result }}" != "success" ] || \
[ "${{ needs.build-rescript.result }}" != "success" ] || \
[ "${{ needs.build-documentation.result }}" != "success" ]; then
echo "❌ Critical builds failed"
exit 1
fi
echo "✅ Build complete"
- name: Upload combined artefacts (release only)
if: github.event_name == 'release'
uses: actions/upload-artifact@v5
with:
name: palimpsest-license-build-${{ github.sha }}
path: all-artefacts
retention-days: 90