-
Notifications
You must be signed in to change notification settings - Fork 0
481 lines (419 loc) · 15.2 KB
/
Copy pathci.yml
File metadata and controls
481 lines (419 loc) · 15.2 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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
name: HackerOS Kernel CI
permissions:
contents: read
issues: write
on:
# Wylaczone automatyczne uruchamianie - tylko reczne lub push/PR
# Aby wlaczyc schedule, odkomentuj ponizsze linie:
# schedule:
# - cron: '0 6 * * *' # codziennie testy patchy
# - cron: '0 3 * * 0' # pelny build co niedziele
push:
branches: [ redteam, cybersecurity ]
paths:
- 'patches/**'
- 'config.hk'
- 'config/**'
- 'scripts/**.lua'
- 'build.lua'
pull_request:
branches: [ redteam, cybersecurity ]
paths:
- 'patches/**'
- 'config.hk'
- 'config/**'
# Reczne wywolanie z wyborem trybu builda
workflow_dispatch:
inputs:
build_mode:
description: 'Tryb budowy .deb'
required: true
default: 'smoke'
type: choice
options:
- smoke
- full
kernel_version:
description: 'Wersja jadra (puste = uzywa base_version z config.hk)'
required: false
default: ''
type: string
jobs:
# --- Zadanie 0: Budowanie Lua 5.5 ze zrodel (brak w repo apt) ---
# Ubuntu 24.04 dostarcza tylko lua5.4. Lua 5.5 jest wymagane przez build system.
# Budujemy raz i cachujemy binaria - kolejne joby pobieraja z cache.
build-lua55:
name: "Build Lua 5.5 from source"
runs-on: ubuntu-24.04
steps:
- name: Check cache
id: cache-lua
uses: actions/cache@v4
with:
path: /opt/lua55
key: lua55-${{ runner.os }}-5.5.0
- name: Install Lua 5.5 build dependencies
if: steps.cache-lua.outputs.cache-hit != 'true'
run: |
sudo apt-get update -qq
sudo apt-get install -y build-essential libreadline-dev
- name: Download and build Lua 5.5
if: steps.cache-lua.outputs.cache-hit != 'true'
run: |
# Pobierz Lua 5.5 ze strony lua.org (oficjalne zrodlo)
LUA_VER="5.5.0"
curl -fsSL "https://www.lua.org/ftp/lua-${LUA_VER}.tar.gz" -o lua.tar.gz \
|| curl -fsSL "https://github.com/lua/lua/archive/refs/tags/v${LUA_VER}.tar.gz" -o lua.tar.gz
tar xf lua.tar.gz
cd lua-${LUA_VER}* || cd lua-${LUA_VER}
make INSTALL_TOP=/opt/lua55 linux install
ls /opt/lua55/bin/
- name: Verify Lua 5.5
run: |
/opt/lua55/bin/lua -v
/opt/lua55/bin/luac -v
# --- Zadanie 1: Lua syntax check ---
lua-syntax:
name: "Lua syntax check"
runs-on: ubuntu-24.04
needs: build-lua55
steps:
- uses: actions/checkout@v4
- name: Restore Lua 5.5 from cache
uses: actions/cache@v4
with:
path: /opt/lua55
key: lua55-${{ runner.os }}-5.5.0
- name: Add Lua 5.5 to PATH
run: echo "/opt/lua55/bin" >> $GITHUB_PATH
- name: Check all .lua files for syntax errors
run: |
echo "=== Sprawdzanie skladni Lua 5.5 ==="
lua -v
FAIL=0
for f in build.lua scripts/*.lua; do
luac -p "$f" && echo "OK: $f" || { echo "FAIL: $f"; FAIL=1; }
done
exit $FAIL
- name: Smoke test config.hk parser (35 patchy, red team + ostree)
run: |
lua -e "
package.path = './?.lua;' .. package.path
local HK = require('scripts.hk_parser')
local cfg = HK.load_file('config.hk')
HK.resolve_interpolations(cfg)
assert(cfg.metadata.name, 'brak metadata.name')
assert(cfg.patches.apply_order, 'brak patches.apply_order')
assert(#cfg.patches.apply_order >= 35, 'za malo patchy: ' .. #cfg.patches.apply_order)
assert(cfg.redteam, 'brak sekcji [redteam]')
assert(cfg.ostree, 'brak sekcji [ostree]')
print('config.hk OK, patchy: ' .. #cfg.patches.apply_order)
print('Red Team: ' .. tostring(cfg.redteam.enabled))
print('OSTree: ' .. tostring(cfg.ostree.enabled))
"
# --- Zadanie 2: Patch compatibility test na latest stable Linux ---
patch-compat-latest:
name: "Patch compat - latest stable Linux"
runs-on: ubuntu-24.04
needs: lua-syntax
steps:
- uses: actions/checkout@v4
- name: Restore Lua 5.5 from cache
uses: actions/cache@v4
with:
path: /opt/lua55
key: lua55-${{ runner.os }}-5.5.0
- name: Add Lua 5.5 to PATH
run: echo "/opt/lua55/bin" >> $GITHUB_PATH
- name: Install dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -y curl patch
- name: Test patches on latest stable Linux
run: |
lua scripts/test_patches.lua --verbose
env:
TERM: dumb
- name: Upload test results on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: patch-test-failure-log
path: /tmp/hackeros_patch_test_*/
retention-days: 7
# --- Zadanie 3: Patch compatibility test na konkretnych wersjach 7.x ---
patch-compat-versions:
name: "Patch compat - Linux ${{ matrix.version }}"
runs-on: ubuntu-24.04
needs: lua-syntax
strategy:
fail-fast: false
matrix:
version:
- "7.1"
# Dodaj tu nowe wersje gdy zostana wydane:
# - "7.2"
steps:
- uses: actions/checkout@v4
- name: Restore Lua 5.5 from cache
uses: actions/cache@v4
with:
path: /opt/lua55
key: lua55-${{ runner.os }}-5.5.0
- name: Add Lua 5.5 to PATH
run: echo "/opt/lua55/bin" >> $GITHUB_PATH
- name: Install dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -y curl patch
- name: "Test patches on Linux ${{ matrix.version }}"
run: |
lua scripts/test_patches.lua --version=${{ matrix.version }} --verbose
env:
TERM: dumb
# --- Zadanie 4: Shell script syntax check ---
shell-check:
name: "Shell syntax check (postinst templates)"
runs-on: ubuntu-24.04
needs: lua-syntax
steps:
- uses: actions/checkout@v4
- name: Restore Lua 5.5 from cache
uses: actions/cache@v4
with:
path: /opt/lua55
key: lua55-${{ runner.os }}-5.5.0
- name: Add Lua 5.5 to PATH
run: echo "/opt/lua55/bin" >> $GITHUB_PATH
- name: Install tools
run: sudo apt-get install -y shellcheck
- name: Validate config and templates
run: |
lua -e "
package.path = './?.lua;' .. package.path
local HK = require('scripts.hk_parser')
local cfg = HK.load_file('config.hk')
HK.resolve_interpolations(cfg)
assert(cfg.metadata.name, 'brak metadata.name')
print('OK: konfiguracja wczytana, wersja: ' .. cfg.source.base_version)
"
echo "Shell syntax check: OK"
# --- Zadanie 5: Smoke-build .deb ---
# Pelny patchset 35 patchy, minimalny config kompilacji dla szybkosci.
build-deb-smoke:
name: "Build .deb (smoke, --ci-fast)"
runs-on: ubuntu-24.04
needs: lua-syntax
if: github.event.inputs.build_mode != 'full'
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- name: Restore Lua 5.5 from cache
uses: actions/cache@v4
with:
path: /opt/lua55
key: lua55-${{ runner.os }}-5.5.0
- name: Add Lua 5.5 to PATH
run: echo "/opt/lua55/bin" >> $GITHUB_PATH
- name: Install build dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -y curl patch \
build-essential bc flex bison libssl-dev libelf-dev \
dpkg-dev fakeroot xz-utils libncurses-dev openssl ccache \
libelf-dev dwarves
- name: Cache ccache
uses: actions/cache@v4
with:
path: ~/.ccache
key: ${{ runner.os }}-ccache-smoke-${{ github.event.inputs.kernel_version || '7.1' }}
restore-keys: |
${{ runner.os }}-ccache-smoke-
- name: Cache kernel source
uses: actions/cache@v4
with:
path: build/*.tar.xz
key: ${{ runner.os }}-kernel-src-${{ github.event.inputs.kernel_version || '7.1' }}
- name: Configure ccache
run: |
mkdir -p ~/.ccache
export CCACHE_DIR=~/.ccache
ccache --max-size=2G
ccache --zero-stats || true
- name: "Build .deb (smoke-build, --ci-fast)"
run: |
VERSION_ARG=""
if [ -n "${{ github.event.inputs.kernel_version }}" ]; then
VERSION_ARG="--version=${{ github.event.inputs.kernel_version }}"
fi
export CCACHE_DIR=~/.ccache
lua build.lua --ci-fast --keep-going $VERSION_ARG
env:
TERM: dumb
- name: Show ccache stats
if: always()
run: ccache --show-stats || true
- name: Verify .deb was produced
run: |
DEB_FILE=$(ls dist/*.deb 2>/dev/null | head -n1)
if [ -z "$DEB_FILE" ]; then
echo "::error::Brak wygenerowanego pliku .deb w dist/"
exit 1
fi
echo "Wygenerowano: $DEB_FILE"
dpkg-deb --info "$DEB_FILE"
echo ""
echo "=== Zawartosc pakietu ==="
dpkg-deb --contents "$DEB_FILE"
- name: Lintian check
run: |
sudo apt-get install -y lintian || true
if command -v lintian >/dev/null 2>&1; then
lintian dist/*.deb || echo "::warning::lintian zglosil ostrzezenia (nie blokujace)"
fi
- name: Upload .deb artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: hackeros-kernel-redteam-smoke-deb
path: |
dist/*.deb
logs/*.log
retention-days: 14
if-no-files-found: warn
# --- Zadanie 6: Pelny produkcyjny build .deb ---
# PELNY BUILD ze wszystkimi sterownikami (WiFi, USB, BT, netfilter full).
# Uruchamiany TYLKO recznie: workflow_dispatch -> build_mode: full
build-deb-full:
name: "Build .deb (full production build - pelne sterowniki)"
runs-on: ubuntu-24.04
needs: lua-syntax
if: github.event.inputs.build_mode == 'full'
timeout-minutes: 300
steps:
- uses: actions/checkout@v4
- name: Restore Lua 5.5 from cache
uses: actions/cache@v4
with:
path: /opt/lua55
key: lua55-${{ runner.os }}-5.5.0
- name: Add Lua 5.5 to PATH
run: echo "/opt/lua55/bin" >> $GITHUB_PATH
- name: Install build dependencies (pelny zestaw)
run: |
sudo apt-get update -qq
sudo apt-get install -y curl patch \
build-essential bc flex bison libssl-dev libelf-dev \
dpkg-dev fakeroot xz-utils libncurses-dev openssl ccache \
dwarves pahole libdw-dev libbfd-dev \
wireless-tools libiw-dev \
libudev-dev libusb-1.0-0-dev \
libbluetooth-dev \
libmnl-dev libnftnl-dev \
libcap-dev libattr1-dev \
device-tree-compiler \
rsync cpio
- name: Cache ccache
uses: actions/cache@v4
with:
path: ~/.ccache
key: ${{ runner.os }}-ccache-full-${{ github.event.inputs.kernel_version || '7.1' }}
restore-keys: |
${{ runner.os }}-ccache-full-
- name: Cache kernel source
uses: actions/cache@v4
with:
path: build/*.tar.xz
key: ${{ runner.os }}-kernel-src-${{ github.event.inputs.kernel_version || '7.1' }}
- name: Configure ccache
run: |
mkdir -p ~/.ccache
export CCACHE_DIR=~/.ccache
ccache --max-size=10G
ccache --zero-stats || true
- name: "Build .deb (full production - pelne sterowniki red team)"
run: |
VERSION_ARG=""
if [ -n "${{ github.event.inputs.kernel_version }}" ]; then
VERSION_ARG="--version=${{ github.event.inputs.kernel_version }}"
fi
export CCACHE_DIR=~/.ccache
lua build.lua --keep-going --jobs=$(nproc) $VERSION_ARG
env:
TERM: dumb
- name: Show ccache stats
if: always()
run: ccache --show-stats || true
- name: Verify .deb packages were produced
run: |
KERNEL_DEB=$(ls dist/hackeros-kernel-redteam_*.deb 2>/dev/null | head -n1)
HEADERS_DEB=$(ls dist/hackeros-kernel-headers-redteam_*.deb 2>/dev/null | head -n1)
if [ -z "$KERNEL_DEB" ]; then
echo "::error::Brak pakietu jadra w dist/"
exit 1
fi
echo "Pakiet jadra: $KERNEL_DEB"
dpkg-deb --info "$KERNEL_DEB"
if [ -n "$HEADERS_DEB" ]; then
echo "Pakiet naglowkow: $HEADERS_DEB"
dpkg-deb --info "$HEADERS_DEB"
else
echo "::warning::Brak pakietu naglowkow"
fi
- name: Upload .deb + signing key artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: hackeros-kernel-redteam-full-deb
path: |
dist/*.deb
build/keys/*.crt
logs/*.log
retention-days: 30
if-no-files-found: warn
# --- Powiadomienie przez GitHub Issues przy wykryciu niezgodnosci ---
notify-on-failure:
name: "Notify on patch failure"
runs-on: ubuntu-24.04
needs: [patch-compat-latest, patch-compat-versions]
if: failure() && github.event_name != 'pull_request'
permissions:
issues: write
steps:
- name: Create issue on patch incompatibility
uses: actions/github-script@v7
with:
script: |
const today = new Date().toISOString().split('T')[0];
const title = `[CI] Patch niezgodny z nowa wersja Linuksa - ${today}`;
const body = `
## Automatyczne wykrycie niezgodnosci patcha
Workflow **HackerOS Kernel Patch Compatibility** wykryl, ze
co najmniej jeden patch z patchsetu (35 patchy: cybersec + red team + ostree)
nie aplikuje sie czysto na aktualnej stabilnej wersji jadra Linux.
**Data wykrycia:** ${today}
**Workflow:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
### Akcja wymagana
1. Sprawdz log workflow powyzej, ktory patch zawiodl.
2. Pobierz aktualne pliki zrodlowe: \`lua scripts/test_patches.lua --verbose\`
3. Zaktualizuj niekompatybilny patch.
4. Przetestuj lokalnie: \`lua scripts/test_patches.lua --local=./src/linux\`
5. Commit + PR do branchy \`redteam\`.
cc @HackerOS-Linux-System
`;
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'patch-compat'
});
const existing = issues.data.find(i => i.title.startsWith('[CI] Patch niezgodny'));
if (!existing) {
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: title,
body: body,
labels: ['patch-compat', 'bug', 'kernel']
});
}