|
1 | | -name: Vesting API Tests |
| 1 | +name: Vesting Vault Tests |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
|
9 | 9 | jobs: |
10 | 10 | test: |
11 | 11 | runs-on: ubuntu-latest |
12 | | - |
13 | | - services: |
14 | | - sqlite: |
15 | | - image: keinos/sqlite3:latest |
16 | | - options: >- |
17 | | - --health-cmd "sqlite3 --version" |
18 | | - --health-interval 10s |
19 | | - --health-timeout 5s |
20 | | - --health-retries 5 |
21 | 12 |
|
22 | | - steps: |
23 | | - - uses: actions/checkout@v4 |
24 | | - |
25 | | - - name: Setup Node.js |
26 | | - uses: actions/setup-node@v4 |
27 | | - with: |
28 | | - node-version: '18' |
29 | | - cache: 'npm' |
30 | | - |
31 | | - - name: Install dependencies |
32 | | - run: npm ci |
33 | | - |
34 | | - - name: Create environment file |
35 | | - run: cp .env.example .env |
36 | | - |
37 | | - - name: Create data directory |
38 | | - run: mkdir -p data |
39 | | - |
40 | | - - name: Run unit tests |
41 | | - run: npm test |
42 | | - |
43 | | - - name: Run RBAC tests specifically |
44 | | - run: npm test -- --testPathPattern=rbac |
45 | | - |
46 | | - - name: Generate coverage report |
47 | | - run: npm run test:coverage |
48 | | - |
49 | | - - name: Upload coverage to Codecov |
50 | | - uses: codecov/codecov-action@v3 |
51 | | - with: |
52 | | - file: ./coverage/lcov.info |
53 | | - flags: unittests |
54 | | - name: codecov-umbrella |
55 | | - fail_ci_if_error: false |
56 | | - |
57 | | - rbac-security-test: |
58 | | - runs-on: ubuntu-latest |
59 | | - steps: |
60 | | - - uses: actions/checkout@v4 |
61 | | - |
62 | | - - name: Setup Node.js |
63 | | - uses: actions/setup-node@v4 |
64 | | - with: |
65 | | - node-version: '18' |
66 | | - cache: 'npm' |
67 | | - |
68 | | - - name: Install dependencies |
69 | | - run: npm ci |
70 | | - |
71 | | - - name: Create environment file |
72 | | - run: cp .env.example .env |
73 | | - |
74 | | - - name: Create data directory |
75 | | - run: mkdir -p data |
76 | | - |
77 | | - - name: Start application in background |
78 | | - run: | |
79 | | - npm start & |
80 | | - sleep 10 |
81 | | - |
82 | | - - name: Test RBAC endpoints |
83 | | - run: | |
84 | | - # Test token generation for all roles |
85 | | - curl -X POST http://localhost:3000/api/auth/token/generate \ |
86 | | - -H "Content-Type: application/json" \ |
87 | | - -d '{"id":"test-super","email":"super@test.com","role":"super_admin"}' \ |
88 | | - || exit 1 |
89 | | - |
90 | | - curl -X POST http://localhost:3000/api/auth/token/generate \ |
91 | | - -H "Content-Type: application/json" \ |
92 | | - -d '{"id":"test-finance","email":"finance@test.com","role":"finance_manager"}' \ |
93 | | - || exit 1 |
94 | | - |
95 | | - curl -X POST http://localhost:3000/api/auth/token/generate \ |
96 | | - -H "Content-Type: application/json" \ |
97 | | - -d '{"id":"test-hr","email":"hr@test.com","role":"hr_manager"}' \ |
98 | | - || exit 1 |
99 | | - |
100 | | - curl -X POST http://localhost:3000/api/auth/token/generate \ |
101 | | - -H "Content-Type: application/json" \ |
102 | | - -d '{"id":"test-auditor","email":"auditor@test.com","role":"read_only_auditor"}' \ |
103 | | - || exit 1 |
104 | | - |
105 | | - - name: Cleanup |
106 | | - run: pkill -f "node index.js" || true |
107 | | - |
108 | | - security-audit: |
109 | | - runs-on: ubuntu-latest |
110 | | - steps: |
111 | | - - uses: actions/checkout@v4 |
112 | | - |
113 | | - - name: Setup Node.js |
114 | | - uses: actions/setup-node@v4 |
115 | | - with: |
116 | | - node-version: '18' |
117 | | - cache: 'npm' |
118 | | - |
119 | | - - name: Install dependencies |
120 | | - run: npm ci |
121 | | - |
122 | | - - name: Run security audit |
123 | | - run: npm audit --audit-level=moderate |
124 | | - continue-on-error: true |
125 | | - |
126 | | - lint: |
127 | | - runs-on: ubuntu-latest |
128 | | - steps: |
129 | | - - uses: actions/checkout@v4 |
130 | | - |
131 | | - - name: Setup Node.js |
132 | | - uses: actions/setup-node@v4 |
133 | | - with: |
134 | | - node-version: '18' |
135 | | - cache: 'npm' |
136 | | - |
137 | | - - name: Install dependencies |
138 | | - run: npm ci |
139 | | - |
140 | | - - name: Run ESLint |
141 | | - run: | |
142 | | - npm install -g eslint |
143 | | - eslint . --ext .js || true |
144 | | - continue-on-error: true |
0 commit comments