|
| 1 | +name: Node.js CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "main" ] |
| 6 | + pull_request: |
| 7 | + branches: [ "main" ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + test: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + node-version: [18.x, 20.x] |
| 16 | + |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Use Node.js ${{ matrix.node-version }} |
| 21 | + uses: actions/setup-node@v4 |
| 22 | + with: |
| 23 | + node-version: ${{ matrix.node-version }} |
| 24 | + cache: 'npm' |
| 25 | + cache-dependency-path: 'bot/package-lock.json' |
| 26 | + |
| 27 | + - name: Install dependencies |
| 28 | + run: cd bot && npm ci |
| 29 | + |
| 30 | + - name: Verify bot structure |
| 31 | + run: | |
| 32 | + cd bot |
| 33 | + node -e " |
| 34 | + const fs = require('fs'); |
| 35 | + const path = require('path'); |
| 36 | + |
| 37 | + // Check required files exist |
| 38 | + const requiredFiles = [ |
| 39 | + 'index.js', |
| 40 | + 'package.json', |
| 41 | + 'commands/badge-collect.js', |
| 42 | + 'events/deploy-commands.js' |
| 43 | + ]; |
| 44 | + |
| 45 | + requiredFiles.forEach(file => { |
| 46 | + if (!fs.existsSync(file)) { |
| 47 | + console.error('Missing file:', file); |
| 48 | + process.exit(1); |
| 49 | + } |
| 50 | + }); |
| 51 | + |
| 52 | + // Verify package.json has required dependencies |
| 53 | + const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); |
| 54 | + if (!pkg.dependencies['discord.js']) { |
| 55 | + console.error('Missing discord.js dependency'); |
| 56 | + process.exit(1); |
| 57 | + } |
| 58 | + |
| 59 | + console.log('All files and dependencies verified'); |
| 60 | + " |
| 61 | + |
| 62 | + - name: Syntax validation |
| 63 | + run: cd bot && node -c index.js && node -c events/deploy-commands.js && node -c commands/badge-collect.js |
| 64 | + |
| 65 | + - name: Security audit |
| 66 | + run: cd bot && npm audit --audit-level moderate |
0 commit comments