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
115 changes: 115 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: CI

on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
# Test TypeScript projects
typescript:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

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

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9.0.0

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Lint
run: pnpm lint

- name: Type check
run: pnpm check-types

- name: Test
run: pnpm test

- name: Generate Prisma Client
run: pnpm --filter=web db:generate

- name: Build
run: pnpm build
env:
DATABASE_URL: "postgresql://dummy:dummy@localhost:5432/dummy"
AUTH_SECRET: "dummy-secret-for-build"
NEXTAUTH_URL: "http://localhost:3000"

# Test Go project
go:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./apps/agent
steps:
- uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.24'

- name: Install tools
run: |
go install honnef.co/go/tools/cmd/staticcheck@latest
go install golang.org/x/tools/cmd/goimports@latest

- name: Lint
run: |
go vet ./...
staticcheck ./...

- name: Format check
run: |
if [ -n "$(gofmt -s -l .)" ]; then
echo "Go code is not properly formatted"
gofmt -s -d .
exit 1
fi
if [ -n "$(goimports -l .)" ]; then
echo "Go imports are not properly formatted"
goimports -d .
exit 1
fi

- name: Test
run: go test -v -race ./...

- name: Build
run: go build -o bin/agent .

# Security scanning
security:
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- uses: actions/checkout@v4

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

- name: Upload scan results
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: 'trivy-results.sarif'
54 changes: 54 additions & 0 deletions .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Dependencies

on:
schedule:
- cron: '0 9 * * 1' # Weekly on Monday
workflow_dispatch:

jobs:
update:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4

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

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9.0.0

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.24'

- name: Update dependencies
run: |
pnpm update --latest
cd apps/agent && go get -u ./... && go mod tidy

- name: Test updates
run: |
pnpm install
pnpm --filter=web db:generate
pnpm lint
pnpm build
env:
DATABASE_URL: "postgresql://dummy:dummy@localhost:5432/dummy"
AUTH_SECRET: "dummy-secret"
NEXTAUTH_URL: "http://localhost:3000"

- name: Create PR
uses: peter-evans/create-pull-request@v5
with:
title: 'chore: update dependencies'
body: 'Automated dependency updates'
branch: deps-update
delete-branch: true
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,19 @@ yarn-error.log*
# Misc
.DS_Store
*.pem

# Go
bin/
*.exe
*.exe~
*.dll
*.so
*.dylib
coverage.out
tmp/

# CI/CD artifacts
*.tar.gz
*.zip
trivy-results.sarif
gosec-results.sarif
122 changes: 122 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Thank you for your interest in contributing to Dev8.dev! πŸŽ‰ We're building the
3. **Install dependencies**:
```bash
pnpm install
# For Go development tools
make setup-go
```
4. **Set up environment variables**:
```bash
Expand All @@ -22,8 +24,128 @@ Thank you for your interest in contributing to Dev8.dev! πŸŽ‰ We're building the
5. **Start development**:
```bash
pnpm dev
# Or use the Makefile
make dev
```

## πŸ”§ Development Workflow

### Prerequisites

- **Node.js** 18+
- **pnpm** 9.0.0+
- **Go** 1.24+
- **PostgreSQL** 15+

### Local Development Commands

We provide both `pnpm` scripts and a `Makefile` for convenience:

```bash
# Install dependencies
make install # or pnpm install

# Start development servers
make dev # or pnpm dev

# Run all checks (recommended before committing)
make check-all # runs lint, format, type-check, test, build

# Individual checks
make lint # or pnpm lint
make format # or pnpm format
make test # or pnpm test
make build # or pnpm build
make check-types # or pnpm check-types

# Simulate CI pipeline locally
make ci

# Clean build artifacts
make clean # or pnpm clean
```

### Before Committing

Always run the full check suite:

```bash
make check-all
```

This ensures your changes will pass our CI pipeline.

## πŸ€– CI/CD Pipeline

Our simple GitHub Actions CI pipeline runs on every pull request and push:

### Three Simple Jobs

- **🟦 TypeScript**: Lint β†’ Type Check β†’ Test β†’ Build
- **🟩 Go**: Lint β†’ Format Check β†’ Test β†’ Build
- **πŸ›‘οΈ Security**: Trivy vulnerability scanning

### Local Testing

Test your changes locally:

````bash
# Run the full CI suite
make ci

#### **🟦 TypeScript Pipeline**

- **🧹 Linting**: ESLint with strict rules
- **🎨 Formatting**: Prettier validation
- **πŸ”’ Type Checking**: TypeScript compiler strict checks
- **πŸ§ͺ Testing**: Unit and integration tests
- **πŸ—οΈ Building**: Next.js application builds
- **πŸ“¦ Security**: npm audit + CodeQL analysis

#### **🟩 Go Pipeline**

- **🧹 Linting**: go vet + staticcheck
- **🎨 Formatting**: gofmt + goimports validation
- **πŸ§ͺ Testing**: Unit tests with race detection + coverage
- **πŸ—οΈ Building**: Binary compilation
- **πŸ” Security**: gosec + CodeQL analysis

#### **�️ General Security & Testing**

- **πŸ” Vulnerability Scanning**: Trivy for all dependencies
- **�️ Database**: PostgreSQL migration testing

### Performance Optimizations

- **πŸ“¦ Smart Caching**: Go modules, pnpm store, and build artifacts
- **🎯 Change Detection**: Only runs relevant pipelines based on changed files
- **⚑ Parallel Execution**: Language pipelines run concurrently

### Local CI Simulation

Test your changes against the same pipeline locally:

```bash
# Run the full CI suite
make ci

# Or step by step
make lint
make format
make check-types
make test
make build
````

### Status Checks

All PRs must pass these consolidated checks:

- βœ… TypeScript Pipeline (lint + format + type-check + test + build + security)
- βœ… Go Pipeline (lint + format + test + build + security)
- βœ… General Security Scanning (Trivy)
- βœ… Database Migrations (PostgreSQL)

## 🎯 Ways to Contribute

### πŸ› Bug Reports
Expand Down
Loading
Loading