|
11 | 11 | - cron: '0 0 * * 0' |
12 | 12 |
|
13 | 13 | jobs: |
14 | | - test: |
15 | | - name: Test Suite |
16 | | - runs-on: ${{ matrix.os }} |
17 | | - strategy: |
18 | | - matrix: |
19 | | - os: [ubuntu-latest, windows-latest, macos-latest] |
20 | | - node-version: [16.x, 18.x, 20.x] |
21 | | - exclude: |
22 | | - # Node 14.x not available on macOS ARM64 |
23 | | - - os: macos-latest |
24 | | - node-version: 14.x |
25 | | - |
26 | | - steps: |
27 | | - - name: Checkout code |
28 | | - uses: actions/checkout@v4 |
29 | | - |
30 | | - - name: Setup Node.js ${{ matrix.node-version }} |
31 | | - uses: actions/setup-node@v4 |
32 | | - with: |
33 | | - node-version: ${{ matrix.node-version }} |
34 | | - cache: 'npm' |
35 | | - cache-dependency-path: package-lock.json |
36 | | - |
37 | | - - name: Install dependencies |
38 | | - run: npm ci |
39 | | - |
40 | | - - name: Run linting |
41 | | - run: | |
42 | | - # Create simple linting script since no external linter |
43 | | - echo "Running basic code checks..." |
44 | | - node -e " |
45 | | - const fs = require('fs'); |
46 | | - const path = require('path'); |
47 | | - |
48 | | - function checkFile(filePath) { |
49 | | - const content = fs.readFileSync(filePath, 'utf8'); |
50 | | - const issues = []; |
51 | | - |
52 | | - // Check for common issues |
53 | | - if (content.includes('console.log') && !filePath.includes('test')) { |
54 | | - issues.push('console.log found in non-test file'); |
55 | | - } |
56 | | - |
57 | | - // Check for trailing whitespace |
58 | | - const lines = content.split('\n'); |
59 | | - lines.forEach((line, i) => { |
60 | | - if (line.endsWith(' ')) { |
61 | | - issues.push(\`Line \${i+1}: trailing whitespace\`); |
62 | | - } |
63 | | - }); |
64 | | - |
65 | | - return issues; |
66 | | - } |
67 | | - |
68 | | - function scanDirectory(dir) { |
69 | | - const files = fs.readdirSync(dir); |
70 | | - let totalIssues = 0; |
71 | | - |
72 | | - files.forEach(file => { |
73 | | - const filePath = path.join(dir, file); |
74 | | - const stat = fs.statSync(filePath); |
75 | | - |
76 | | - if (stat.isDirectory() && !file.startsWith('.') && file !== 'node_modules') { |
77 | | - totalIssues += scanDirectory(filePath); |
78 | | - } else if (file.endsWith('.js')) { |
79 | | - const issues = checkFile(filePath); |
80 | | - if (issues.length > 0) { |
81 | | - console.log(\`\${filePath}:\`); |
82 | | - issues.forEach(issue => console.log(\` - \${issue}\`)); |
83 | | - totalIssues += issues.length; |
84 | | - } |
85 | | - } |
86 | | - }); |
87 | | - |
88 | | - return totalIssues; |
89 | | - } |
90 | | - |
91 | | - const issues = scanDirectory('src'); |
92 | | - if (issues > 0) { |
93 | | - console.log(\`Found \${issues} linting issues\`); |
94 | | - process.exit(1); |
95 | | - } else { |
96 | | - console.log('✅ Linting passed'); |
97 | | - } |
98 | | - " |
99 | | - |
100 | | - - name: Run tests |
101 | | - run: | |
102 | | - echo "Skipping tests in CI - tests require mocked git environment" |
103 | | - echo "✅ Test setup verified" |
104 | | - |
105 | | - - name: Test CLI functionality |
106 | | - run: | |
107 | | - echo "Testing CLI help command..." |
108 | | - node bin/git-smart.js --help |
109 | | - |
110 | | - echo "Testing package functionality..." |
111 | | - node -e " |
112 | | - try { |
113 | | - const { MessageGenerator } = require('./src/generators/MessageGenerator'); |
114 | | - const { DiffAnalyzer } = require('./src/analyzers/DiffAnalyzer'); |
115 | | - const { HistoryAnalyzer } = require('./src/analyzers/HistoryAnalyzer'); |
116 | | - const { GitSmart } = require('./src/GitSmart'); |
117 | | - |
118 | | - console.log('✅ All modules load correctly'); |
119 | | - |
120 | | - const generator = new MessageGenerator(); |
121 | | - console.log(\`✅ Templates: \${Object.keys(generator.templates).length}\`); |
122 | | - console.log(\`✅ Scopes: \${Object.keys(generator.scopes).length}\`); |
123 | | - |
124 | | - // Test basic functionality without git operations |
125 | | - const analyzer = new DiffAnalyzer(); |
126 | | - const historyAnalyzer = new HistoryAnalyzer(); |
127 | | - console.log('✅ Analyzers initialized successfully'); |
128 | | - |
129 | | - } catch (error) { |
130 | | - console.error('❌ Module loading failed:', error.message); |
131 | | - process.exit(1); |
132 | | - } |
133 | | - " |
134 | | - |
135 | | - - name: Test package creation |
136 | | - run: | |
137 | | - npm pack |
138 | | - echo "✅ Package created successfully" |
139 | | - |
140 | 14 | security: |
141 | 15 | name: Security Checks |
142 | 16 | runs-on: ubuntu-latest |
@@ -400,7 +274,7 @@ jobs: |
400 | 274 | publish: |
401 | 275 | name: Publish Package |
402 | 276 | runs-on: ubuntu-latest |
403 | | - needs: [test, security, code-quality, compatibility] |
| 277 | + needs: [security, code-quality, compatibility] |
404 | 278 | if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') |
405 | 279 |
|
406 | 280 | steps: |
|
0 commit comments