|
1 | 1 | name: CI |
2 | 2 |
|
3 | 3 | # ────────────────────────────────────────────────────────────────────────────── |
4 | | -# Runs on every pull request and on pushes to non-main branches. |
5 | | -# Purpose: Fast quality gate (syntax + tests + audit). |
6 | | -# The full deploy pipeline lives in deploy.yml (push to main only). |
| 4 | +# PURPOSE: |
| 5 | +# - Runs on all PRs and pushes to non-main branches. |
| 6 | +# - Fast, deterministic quality gate: syntax → tests → audit → smoke. |
| 7 | +# - Never deploys. Never touches the VPS. Never writes artifacts. |
| 8 | +# - Full deploy pipeline lives in deploy.yml (main branch only). |
7 | 9 | # ────────────────────────────────────────────────────────────────────────────── |
8 | 10 | on: |
9 | 11 | pull_request: |
10 | 12 | push: |
11 | 13 | branches-ignore: [main] |
12 | 14 |
|
13 | | -# Minimal read-only permissions — no write access needed for CI validation |
14 | 15 | permissions: |
15 | 16 | contents: read |
16 | 17 |
|
17 | 18 | jobs: |
| 19 | + |
| 20 | + # ──────────────────────────────────────────────────────────────────────────── |
| 21 | + # Job 1: Validate (syntax, tests, audit) |
| 22 | + # ──────────────────────────────────────────────────────────────────────────── |
18 | 23 | validate: |
19 | 24 | name: Validate |
20 | 25 | runs-on: ubuntu-latest |
21 | 26 |
|
22 | 27 | steps: |
23 | | - - uses: actions/checkout@v4 |
| 28 | + - name: Checkout |
| 29 | + uses: actions/checkout@v4 |
24 | 30 |
|
25 | | - - uses: actions/setup-node@v4 |
| 31 | + - name: Setup Node.js 20 |
| 32 | + uses: actions/setup-node@v4 |
26 | 33 | with: |
27 | 34 | node-version: '20' |
28 | 35 | cache: 'npm' |
29 | 36 |
|
30 | 37 | - name: Install dependencies |
31 | 38 | run: npm ci |
32 | 39 |
|
| 40 | + # Syntax / type / lint checks |
33 | 41 | - name: Syntax check |
34 | 42 | run: npm run check |
35 | 43 |
|
| 44 | + # Unit tests (fail-fast) |
36 | 45 | - name: Run tests |
37 | 46 | run: npm test |
38 | 47 |
|
| 48 | + # Security audit (warn only) |
39 | 49 | - name: Security audit (high+critical only) |
40 | 50 | run: npm audit --audit-level=high |
41 | | - continue-on-error: true # Warn but don't block PR for advisories |
| 51 | + continue-on-error: true |
42 | 52 |
|
43 | | - # Lightweight integration check (does the bot start without crashing?) |
| 53 | + # ──────────────────────────────────────────────────────────────────────────── |
| 54 | + # Job 2: Smoke test (lightweight integration) |
| 55 | + # Ensures the bot can be required without crashing. |
| 56 | + # Does NOT start the bot (no BOT_TOKEN in CI). |
| 57 | + # ──────────────────────────────────────────────────────────────────────────── |
44 | 58 | smoke: |
45 | | - name: Smoke |
| 59 | + name: Smoke Test |
46 | 60 | runs-on: ubuntu-latest |
47 | 61 | needs: validate |
48 | 62 |
|
49 | 63 | steps: |
50 | | - - uses: actions/checkout@v4 |
| 64 | + - name: Checkout |
| 65 | + uses: actions/checkout@v4 |
51 | 66 |
|
52 | | - - uses: actions/setup-node@v4 |
| 67 | + - name: Setup Node.js 20 |
| 68 | + uses: actions/setup-node@v4 |
53 | 69 | with: |
54 | 70 | node-version: '20' |
55 | 71 | cache: 'npm' |
56 | 72 |
|
57 | 73 | - name: Install dependencies |
58 | 74 | run: npm ci |
59 | 75 |
|
60 | | - - name: Check entrypoint can be required without errors |
| 76 | + - name: Validate entrypoint loads cleanly |
61 | 77 | run: | |
62 | | - # We can't fully start the bot (no BOT_TOKEN), but we can check |
63 | | - # that the file is syntactically and structurally valid. |
| 78 | + # node --check ensures syntax correctness |
64 | 79 | node --check index.js |
65 | 80 | echo "✅ index.js passes node --check" |
| 81 | +
|
| 82 | + # Try requiring the bot without executing Telegram logic |
| 83 | + node -e "require('./index.js'); console.log('✅ index.js can be required without crashing')" |
0 commit comments