-
Notifications
You must be signed in to change notification settings - Fork 0
197 lines (162 loc) Β· 5.63 KB
/
workflow.yaml
File metadata and controls
197 lines (162 loc) Β· 5.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
name: CI/CD Pipeline - Finance System
on:
push:
branches: [ "main", "master", "develop" ]
pull_request:
branches: [ "main", "master" ]
env:
DOTNET_VERSION: '8.0.x'
NODE_VERSION: '18.x'
jobs:
# Backend CI Job
backend-build:
name: π§ Backend Build & Test
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend
steps:
- name: π₯ Checkout code
uses: actions/checkout@v4
- name: π οΈ Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: π¦ Cache .NET packages
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: π Restore dependencies
run: dotnet restore
- name: ποΈ Build backend
run: dotnet build --no-restore --configuration Release
- name: π§ͺ Run backend tests
run: dotnet test --no-build --configuration Release --verbosity normal --collect:"XPlat Code Coverage"
- name: π Upload coverage reports
uses: codecov/codecov-action@v3
with:
directory: ./backend/TestResults
fail_ci_if_error: false
# Frontend CI Job
frontend-build:
name: π¨ Frontend Build & Test
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend/project
steps:
- name: π₯ Checkout code
uses: actions/checkout@v4
- name: π οΈ Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: ./frontend/project/package-lock.json
- name: π¦ Install dependencies
run: npm ci
- name: π Lint frontend
run: npm run lint --if-present
- name: π§ͺ Run frontend tests
run: npm test --if-present
- name: ποΈ Build frontend
run: npm run build
- name: π€ Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: frontend-build
path: ./frontend/project/dist
# Docker Build & Security
docker-build:
name: π³ Docker Build & Security
runs-on: ubuntu-latest
needs: [backend-build, frontend-build]
if: github.event_name == 'push'
steps:
- name: π₯ Checkout code
uses: actions/checkout@v4
- name: π οΈ Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: ποΈ Build backend Docker image
uses: docker/build-push-action@v5
with:
context: ./backend
file: ./backend/Dockerfile
push: false
tags: finace-system-backend:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: ποΈ Build frontend Docker image
uses: docker/build-push-action@v5
with:
context: ./frontend/project
file: ./frontend/project/Dockerfile
push: false
tags: finace-system-frontend:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: π Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: 'finace-system-backend:latest'
format: 'sarif'
output: 'trivy-results.sarif'
- name: π Upload Trivy scan results
uses: github/codeql-action/upload-sarif@v2
if: always()
with:
sarif_file: 'trivy-results.sarif'
# Integration Tests with Docker Compose
integration-tests:
name: π§ͺ Integration Tests
runs-on: ubuntu-latest
needs: [backend-build, frontend-build]
steps:
- name: π₯ Checkout code
uses: actions/checkout@v4
- name: π³ Start services with Docker Compose
run: |
docker-compose up -d --build
sleep 30 # Wait for services to be ready
- name: π©Ί Health check backend
run: |
curl -f http://localhost:8080/swagger || exit 1
echo "β
Backend is healthy"
- name: π©Ί Health check frontend
run: |
curl -f http://localhost:3000 || exit 1
echo "β
Frontend is healthy"
- name: π Test API endpoints
run: |
# Test basic API endpoints
curl -f http://localhost:8080/swagger/v1/swagger.json || exit 1
echo "β
Swagger API documentation accessible"
- name: π Show container logs
if: failure()
run: |
echo "=== Backend Logs ==="
docker-compose logs backend
echo "=== Frontend Logs ==="
docker-compose logs frontend
echo "=== MySQL Logs ==="
docker-compose logs mysql
- name: π Stop services
if: always()
run: docker-compose down
# Notify Success
notify-success:
name: π Deployment Ready
runs-on: ubuntu-latest
needs: [backend-build, frontend-build, docker-build, integration-tests]
if: success() && github.ref == 'refs/heads/master'
steps:
- name: π Success notification
run: |
echo "π All tests passed! System is ready for deployment."
echo "β
Backend: Built and tested"
echo "β
Frontend: Built and tested"
echo "β
Docker: Images built successfully"
echo "β
Integration: All services healthy"