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
86 changes: 86 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# GitHub Actions Workflows

This directory contains CI/CD workflows for the Property Management System.

## Workflows

### 1. CI Pipeline (`ci.yml`)

Main continuous integration pipeline that runs on:
- Pull requests to `main`, `develop`, or `feature/**` branches
- Pushes to `main` and `develop` branches

**Jobs:**
- **Lint & Type Check**: Runs ESLint and TypeScript type checking
- **Build**: Builds the Next.js application
- **Test**: Runs test suite (when tests are added)
- **Security Audit**: Runs `npm audit` for dependency vulnerabilities
- **Database Migration Check**: Validates SQL migration files
- **Workflow Summary**: Generates a summary of all job results

### 2. Workflow System Tests (`workflow-tests.yml`)

Specialized workflow that validates the workflow system implementation. Runs on:
- Pull requests that modify workflow-related files
- Pushes to `main` and `develop` that modify workflow files

**Jobs:**
- **Workflow Schema Validation**: Validates SQL schema for workflow system
- **Workflow Actions Validation**: Type checks and validates workflow server actions
- **Workflow UI Validation**: Type checks and validates workflow UI components

## Workflow Triggers

### Pull Request Workflow
The CI pipeline automatically runs when:
- A pull request is opened
- A pull request is updated (new commits pushed)
- A pull request is synchronized (rebased/merged)

### Push Workflow
The CI pipeline runs on direct pushes to:
- `main` branch
- `develop` branch

## Required Secrets

The following secrets should be configured in GitHub repository settings:

- `NEXT_PUBLIC_SUPABASE_URL`: Supabase project URL
- `SUPABASE_SERVICE_ROLE_KEY`: Supabase service role key
- `NEXT_PUBLIC_SUPABASE_ANON_KEY`: Supabase anonymous key

## Local Testing

You can test the CI pipeline locally using [act](https://github.com/nektos/act):

```bash
# Install act
brew install act # macOS
# or download from https://github.com/nektos/act/releases

# Run the CI workflow
act pull_request

# Run a specific job
act -j lint-and-typecheck
```

## Adding New Workflows

When adding new workflows:

1. Create a new `.yml` file in `.github/workflows/`
2. Follow the existing workflow structure
3. Add appropriate triggers (pull_request, push, etc.)
4. Document the workflow in this README
5. Test locally using `act` before committing

## Workflow Status Badges

Add these badges to your README.md:

```markdown
![CI Pipeline](https://github.com/Exela-Tech/Propeerty_Management/workflows/CI%20Pipeline/badge.svg)
![Workflow System Tests](https://github.com/Exela-Tech/Propeerty_Management/workflows/Workflow%20System%20Tests/badge.svg)
```
147 changes: 147 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
name: CI Pipeline

on:
pull_request:
branches:
- main
- develop
- 'feature/**'
push:
branches:
- main
- develop

jobs:
lint-and-typecheck:
name: Lint & Type Check
runs-on: ubuntu-latest

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

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

- name: Install dependencies
run: npm ci --legacy-peer-deps

- name: Run ESLint
run: npm run lint
continue-on-error: false

- name: TypeScript type check
run: npx tsc --noEmit
continue-on-error: false

build:
name: Build Application
runs-on: ubuntu-latest
needs: lint-and-typecheck

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

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

- name: Install dependencies
run: npm ci --legacy-peer-deps

- name: Build Next.js application
run: npm run build
env:
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL || 'https://placeholder.supabase.co' }}
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY || 'placeholder-key' }}
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY || 'placeholder-key' }}

test:
name: Run Tests
runs-on: ubuntu-latest
needs: lint-and-typecheck

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

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

- name: Install dependencies
run: npm ci --legacy-peer-deps

- name: Run tests
run: npm test
continue-on-error: true

security-audit:
name: Security Audit
runs-on: ubuntu-latest

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

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

- name: Install dependencies
run: npm ci --legacy-peer-deps

- name: Run npm audit
run: npm audit --audit-level=moderate
continue-on-error: true

database-migration-check:
name: Database Migration Check
runs-on: ubuntu-latest

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

- name: Check SQL syntax
run: |
# Check if all SQL files are valid
for file in scripts/*.sql; do
if [ -f "$file" ]; then
echo "Checking $file..."
# Basic SQL syntax check (PostgreSQL)
# This is a placeholder - you might want to use a proper SQL linter
if ! grep -q "CREATE\|ALTER\|INSERT\|UPDATE\|DELETE" "$file"; then
echo "Warning: $file might not contain valid SQL statements"
fi
fi
done

workflow-summary:
name: Workflow Summary
runs-on: ubuntu-latest
needs: [lint-and-typecheck, build, test, security-audit, database-migration-check]
if: always()

steps:
- name: Workflow Status
run: |
echo "## CI Pipeline Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Job | Status |" >> $GITHUB_STEP_SUMMARY
echo "|-----|--------|" >> $GITHUB_STEP_SUMMARY
echo "| Lint & Type Check | ${{ needs.lint-and-typecheck.result }} |" >> $GITHUB_STEP_SUMMARY
echo "| Build | ${{ needs.build.result }} |" >> $GITHUB_STEP_SUMMARY
echo "| Tests | ${{ needs.test.result }} |" >> $GITHUB_STEP_SUMMARY
echo "| Security Audit | ${{ needs.security-audit.result }} |" >> $GITHUB_STEP_SUMMARY
echo "| Database Migration Check | ${{ needs.database-migration-check.result }} |" >> $GITHUB_STEP_SUMMARY
Loading
Loading