Merge pull request #25 from MHaggis/MHaggis/fix-link-previews #65
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI - Build and Test | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main, develop] | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest] | |
| node-version: [18.x, 20.x, 22.x] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build TypeScript | |
| run: npm run build | |
| - name: Verify build output | |
| run: node -e "const fs=require('fs'); const files=['dist/index.js','dist/db/connection.js','dist/db/patterns.js','dist/tools/engineering/index.js']; let ok=true; for(const f of files){if(!fs.existsSync(f)){console.error('Missing',f);ok=false;}else{console.log('OK',f);}} if(!ok)process.exit(1); console.log('All expected build outputs exist');" | |
| # Cross-platform database lifecycle tests (no external data needed) | |
| test-platform: | |
| runs-on: ${{ matrix.os }} | |
| needs: build | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build | |
| run: npm run build | |
| - name: Run cross-platform database tests | |
| run: node tests/cross-platform-test.js | |
| - name: Validate database schema | |
| shell: bash | |
| run: | | |
| node -e " | |
| import { initDb, getDb } from './dist/db/connection.js'; | |
| import { initPatternsSchema } from './dist/db/patterns.js'; | |
| initDb(); | |
| initPatternsSchema(); | |
| const db = getDb(); | |
| const tables = db.prepare(\"SELECT name FROM sqlite_master WHERE type='table'\").all(); | |
| const tableNames = tables.map(t => t.name); | |
| const required = ['detections', 'stories', 'detection_patterns', 'field_reference', 'style_conventions', 'kg_entities', 'kg_relations', 'kg_observations', 'kg_decisions', 'kg_learnings']; | |
| for (const table of required) { | |
| if (!tableNames.includes(table)) { | |
| console.error('Missing table:', table); | |
| process.exit(1); | |
| } | |
| } | |
| console.log('All required tables exist:', required.length); | |
| " | |
| - name: Test MCP Server Startup (Linux/macOS) | |
| if: runner.os != 'Windows' | |
| shell: bash | |
| run: | | |
| timeout 5 node dist/index.js & | |
| sleep 3 | |
| echo "MCP server starts without errors" | |
| continue-on-error: true | |
| - name: Test MCP Server Startup (Windows) | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| $proc = Start-Process -FilePath "node" -ArgumentList "dist/index.js" -PassThru -NoNewWindow | |
| Start-Sleep -Seconds 3 | |
| if (!$proc.HasExited) { | |
| Stop-Process -Id $proc.Id -Force | |
| Write-Host "MCP server starts without errors" | |
| } else { | |
| Write-Host "MCP server exited early with code $($proc.ExitCode)" | |
| } | |
| continue-on-error: true | |
| # Full integration test with real Sigma data | |
| test-integration: | |
| runs-on: ${{ matrix.os }} | |
| needs: build | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build | |
| run: npm run build | |
| - name: Download Sigma rules (sparse checkout) | |
| run: | | |
| git clone --depth 1 --filter=blob:none --sparse https://github.com/SigmaHQ/sigma.git detections/sigma | |
| cd detections/sigma | |
| git sparse-checkout set rules rules-threat-hunting | |
| - name: Run CI integration test (index + query + recreate cycle) | |
| shell: bash | |
| env: | |
| SIGMA_PATHS: detections/sigma/rules,detections/sigma/rules-threat-hunting | |
| run: node tests/ci-integration-test.js | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: TypeScript type checking | |
| run: npx tsc --noEmit |