Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
307 changes: 228 additions & 79 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,64 @@
name: CI/CD Pipeline

on:
pull_request:
branches: [master, main]
push:
branches: [master, main]
branches: [main, develop]
pull_request:
branches: [main, develop]
release:
types: [published]

jobs:
lint-and-type-check:
name: Lint and Type Check
lint-and-test:
name: Lint & Test
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x, 20.x]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: '20'
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies
run: |
npm install || echo "Root install failed, continuing..."
cd backend && npm ci
cd ../frontend && npm ci
cd ../sdk && npm ci
cd ../task-manager-app && npm ci

- name: Lint backend
- name: Type checking
run: |
cd backend
npm install --no-save || echo "Backend install completed with warnings"
npm run lint || echo "Backend linting completed with warnings"
cd backend && npm run type-check
cd ../frontend && npm run type-check
cd ../sdk && npm run type-check

- name: Lint frontend
- name: Lint code
run: |
cd frontend
npm install --no-save || echo "Frontend install completed with warnings"
npm run lint || echo "Frontend linting completed with warnings"
cd backend && npm run lint
cd ../frontend && npm run lint
cd ../sdk && npm run lint

- name: Type check backend
run: |
cd backend
npm run type-check || echo "Backend type check completed with warnings"
- name: Run backend tests
run: cd backend && npm test

- name: Type check frontend
run: |
cd frontend
npm run type-check || echo "Frontend type check completed with warnings"
- name: Run frontend tests
run: cd frontend && npm test

- name: Run SDK tests
run: cd sdk && npm test

build:
name: Build All Packages
name: Build Applications
runs-on: ubuntu-latest
needs: lint-and-type-check
needs: lint-and-test

steps:
- name: Checkout code
Expand All @@ -59,28 +67,56 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '20.x'
cache: 'npm'

- name: Install dependencies
run: npm install || echo "Root install completed with warnings"
run: |
cd backend && npm ci
cd ../frontend && npm ci
cd ../sdk && npm ci
cd ../task-manager-app && npm ci

- name: Build backend
run: |
cd backend
npm install --no-save || echo "Install completed with warnings"
npm run build || echo "Backend build completed with warnings"
run: cd backend && npm run build

- name: Build frontend
run: |
cd frontend
npm install --no-save || echo "Install completed with warnings"
npm run build || echo "Frontend build completed with warnings"
run: cd frontend && npm run build

test:
name: Run Tests
- name: Build SDK
run: cd sdk && npm run build

- name: Build task manager app
run: cd task-manager-app && npm run build

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: |
backend/dist/
frontend/dist/
sdk/dist/
task-manager-app/dist/

integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
needs: lint-and-type-check
needs: build

services:
postgres:
image: postgres:15
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: frontfuse_test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

steps:
- name: Checkout code
Expand All @@ -89,27 +125,52 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '20.x'
cache: 'npm'

- name: Install dependencies
run: npm install || echo "Root install completed with warnings"
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts

- name: Run backend tests
- name: Install dependencies
run: |
cd backend
npm install --no-save || echo "Install completed with warnings"
npm test || echo "Backend tests completed"
cd backend && npm ci
cd ../frontend && npm ci

- name: Run frontend tests
run: |
cd frontend
npm install --no-save || echo "Install completed with warnings"
npm test || echo "Frontend tests completed"
- name: Run integration tests
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/frontfuse_test
NODE_ENV: test
run: cd backend && npm run test:integration

security-scan:
name: Security Scan
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
format: 'sarif'
output: 'trivy-results.sarif'

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: 'trivy-results.sarif'

security-audit:
name: Security Audit
publish-sdk:
name: Publish SDK
runs-on: ubuntu-latest
needs: [lint-and-test, build]
if: github.event_name == 'release' && github.event.action == 'published'

steps:
- name: Checkout code
Expand All @@ -118,50 +179,138 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '20.x'
cache: 'npm'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: npm install || echo "Root install completed with warnings"
- name: Install SDK dependencies
run: cd sdk && npm ci

- name: Build SDK
run: cd sdk && npm run build

- name: Extract version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT

- name: Update SDK version
run: |
cd sdk
npm version ${{ steps.get_version.outputs.VERSION }} --no-git-tag-version

- name: Publish to npm
run: cd sdk && npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Create GitHub release for SDK
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: sdk-v${{ steps.get_version.outputs.VERSION }}
release_name: SDK v${{ steps.get_version.outputs.VERSION }}
body: |
## SDK Release v${{ steps.get_version.outputs.VERSION }}

This release includes the FuzeFront React SDK for building microfrontend applications.

- name: Run security audit
run: npm audit --audit-level=high || echo "Security audit completed with warnings"
### Installation
```bash
npm install @fuzefront/sdk-react@${{ steps.get_version.outputs.VERSION }}
```

commit-lint:
name: Commit Message Lint
See the [README](https://github.com/izzywdev/FuzeFront/blob/main/sdk/README.md) for usage instructions.
draft: false
prerelease: false

deploy-docs:
name: Deploy Documentation
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
needs: build
if: github.ref == 'refs/heads/main'

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
node-version: '20.x'

- name: Install dependencies
run: npm install || echo "Root install completed with warnings"
- name: Build documentation
run: |
mkdir -p docs
cp sdk/README.md docs/sdk-guide.md
cp README.md docs/index.md

- name: Validate current commit (last commit)
run: npx commitlint --last --verbose || echo "Commit lint completed with warnings"
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs

deployment-ready:
name: Deployment Ready
docker-build:
name: Build Docker Images
runs-on: ubuntu-latest
needs: [lint-and-type-check, build, test, security-audit]
needs: build
if: github.ref == 'refs/heads/main' || github.event_name == 'release'

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts

- name: Build and push backend image
uses: docker/build-push-action@v5
with:
context: ./backend
push: true
tags: |
fuzefront/backend:latest
fuzefront/backend:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Build and push frontend image
uses: docker/build-push-action@v5
with:
context: ./frontend
push: true
tags: |
fuzefront/frontend:latest
fuzefront/frontend:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max

notify:
name: Notify Team
runs-on: ubuntu-latest
needs: [lint-and-test, build, integration-tests]
if: always()

steps:
- name: Check all jobs status
- name: Notify on success
if: ${{ needs.lint-and-test.result == 'success' && needs.build.result == 'success' && needs.integration-tests.result == 'success' }}
run: |
echo "✅ All checks passed! Ready for deployment."

- name: Notify on failure
if: ${{ needs.lint-and-test.result == 'failure' || needs.build.result == 'failure' || needs.integration-tests.result == 'failure' }}
run: |
echo "✅ All CI checks completed successfully!"
echo "Lint & Type Check: ${{ needs.lint-and-type-check.result }}"
echo "Build: ${{ needs.build.result }}"
echo "Test: ${{ needs.test.result }}"
echo "Security Audit: ${{ needs.security-audit.result }}"
echo "🚀 Ready for deployment!"
echo "❌ Some checks failed. Please review the logs."
exit 1
Loading