build(deps): bump dotnet/sdk from 8.0 to 10.0 in /backend #139
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/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" |