From e4d90a0bbb8ec15cb1d8941ee189657f22889ddc Mon Sep 17 00:00:00 2001 From: VAIBHAVSING Date: Wed, 27 Aug 2025 17:05:23 +0530 Subject: [PATCH 1/4] feat: added ci and fixes monorepo --- .github/workflows/ci.yml | 431 +++++++++++++++++++++++++++++ .github/workflows/dependencies.yml | 70 +++++ .github/workflows/release.yml | 109 ++++++++ .github/workflows/security.yml | 106 +++++++ .gitignore | 16 ++ CONTRIBUTING.md | 104 +++++++ Makefile | 75 +++++ README.md | 50 ++++ apps/agent/main_test.go | 66 +++++ apps/docs/package.json | 3 +- apps/web/package.json | 1 + package.json | 1 + turbo.json | 4 + 13 files changed, 1035 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/dependencies.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/security.yml create mode 100644 Makefile create mode 100644 apps/agent/main_test.go diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..486a2db --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,431 @@ +name: CI + +on: + push: + branches: [main, develop] + pull_request: + branches: [main, develop] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + # Job for detecting changes to optimize CI runs + changes: + runs-on: ubuntu-latest + outputs: + go: ${{ steps.changes.outputs.go }} + typescript: ${{ steps.changes.outputs.typescript }} + web: ${{ steps.changes.outputs.web }} + docs: ${{ steps.changes.outputs.docs }} + agent: ${{ steps.changes.outputs.agent }} + steps: + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: changes + with: + filters: | + go: + - 'apps/agent/**' + - 'go.mod' + - 'go.sum' + typescript: + - 'apps/web/**' + - 'apps/docs/**' + - 'packages/**' + - 'package.json' + - 'pnpm-lock.yaml' + - 'turbo.json' + web: + - 'apps/web/**' + - 'packages/**' + - 'package.json' + - 'pnpm-lock.yaml' + docs: + - 'apps/docs/**' + - 'packages/**' + - 'package.json' + - 'pnpm-lock.yaml' + agent: + - 'apps/agent/**' + + # TypeScript/Node.js jobs + typescript-lint: + needs: changes + if: ${{ needs.changes.outputs.typescript == 'true' }} + 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: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - name: Setup pnpm cache + uses: actions/cache@v4 + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Lint TypeScript + run: pnpm lint + + typescript-format: + needs: changes + if: ${{ needs.changes.outputs.typescript == 'true' }} + 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: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - name: Setup pnpm cache + uses: actions/cache@v4 + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Check TypeScript formatting + run: | + pnpm format + if [ -n "$(git status --porcelain)" ]; then + echo "Code is not properly formatted. Please run 'pnpm format' and commit the changes." + git diff + exit 1 + fi + + typescript-typecheck: + needs: changes + if: ${{ needs.changes.outputs.typescript == 'true' }} + 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: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - name: Setup pnpm cache + uses: actions/cache@v4 + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Type check + run: pnpm check-types + + typescript-build: + needs: changes + if: ${{ needs.changes.outputs.typescript == 'true' }} + 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: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - name: Setup pnpm cache + uses: actions/cache@v4 + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Build applications + run: pnpm build + env: + # Provide dummy values for build-time environment variables + DATABASE_URL: "postgresql://dummy:dummy@localhost:5432/dummy" + AUTH_SECRET: "dummy-secret-for-build" + NEXTAUTH_URL: "http://localhost:3000" + + # Go jobs + go-lint: + needs: changes + if: ${{ needs.changes.outputs.go == 'true' }} + 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: Cache Go modules + uses: actions/cache@v4 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Download dependencies + run: go mod download + + - name: Install staticcheck + run: go install honnef.co/go/tools/cmd/staticcheck@latest + + - name: Run go vet + run: go vet ./... + + - name: Run staticcheck + run: staticcheck ./... + + go-format: + needs: changes + if: ${{ needs.changes.outputs.go == 'true' }} + 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 goimports + run: go install golang.org/x/tools/cmd/goimports@latest + + - name: Check Go formatting + run: | + gofmt -s -d . + if [ -n "$(gofmt -s -l .)" ]; then + echo "Go code is not properly formatted. Please run 'go fmt ./...' and commit the changes." + exit 1 + fi + + - name: Check goimports + run: | + goimports -d . + if [ -n "$(goimports -l .)" ]; then + echo "Go imports are not properly formatted. Please run 'goimports -w .' and commit the changes." + exit 1 + fi + + go-test: + needs: changes + if: ${{ needs.changes.outputs.go == 'true' }} + 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: Cache Go modules + uses: actions/cache@v4 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Download dependencies + run: go mod download + + - name: Run tests + run: go test -v -race -coverprofile=coverage.out ./... + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + with: + file: ./apps/agent/coverage.out + flags: go + name: go-coverage + + go-build: + needs: changes + if: ${{ needs.changes.outputs.go == 'true' }} + 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: Cache Go modules + uses: actions/cache@v4 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Download dependencies + run: go mod download + + - name: Build application + run: go build -v -o bin/agent . + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: agent-binary + path: apps/agent/bin/agent + + # Database migration test (for web app) + test-db-migrations: + needs: changes + if: ${{ needs.changes.outputs.web == 'true' }} + runs-on: ubuntu-latest + services: + postgres: + image: postgres:15 + env: + POSTGRES_PASSWORD: postgres + POSTGRES_DB: test_db + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + defaults: + run: + working-directory: ./apps/web + 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: Test database migrations + run: | + pnpm db:generate + pnpm db:deploy + env: + DATABASE_URL: "postgresql://postgres:postgres@localhost:5432/test_db" + + # Final status check + ci-success: + runs-on: ubuntu-latest + needs: [ + changes, + typescript-lint, + typescript-format, + typescript-typecheck, + typescript-build, + go-lint, + go-format, + go-test, + go-build, + test-db-migrations + ] + if: always() + steps: + - name: Check CI success + run: | + if [[ "${{ needs.typescript-lint.result }}" == "failure" || \ + "${{ needs.typescript-format.result }}" == "failure" || \ + "${{ needs.typescript-typecheck.result }}" == "failure" || \ + "${{ needs.typescript-build.result }}" == "failure" || \ + "${{ needs.go-lint.result }}" == "failure" || \ + "${{ needs.go-format.result }}" == "failure" || \ + "${{ needs.go-test.result }}" == "failure" || \ + "${{ needs.go-build.result }}" == "failure" || \ + "${{ needs.test-db-migrations.result }}" == "failure" ]]; then + echo "One or more CI jobs failed" + exit 1 + fi + echo "All CI jobs completed successfully" diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml new file mode 100644 index 0000000..bde896b --- /dev/null +++ b/.github/workflows/dependencies.yml @@ -0,0 +1,70 @@ +name: Dependency Updates + +on: + schedule: + # Run weekly on Monday at 9 AM UTC + - cron: '0 9 * * 1' + workflow_dispatch: + +jobs: + update-dependencies: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - 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 Node.js dependencies + run: | + pnpm update --latest + + - name: Update Go dependencies + run: | + cd apps/agent + go get -u ./... + go mod tidy + + - name: Run tests after updates + run: | + pnpm install + pnpm test + cd apps/agent && go test ./... + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: 'chore: update dependencies' + title: 'chore: automated dependency updates' + body: | + This PR contains automated dependency updates. + + ## Changes + - Updated Node.js dependencies to latest versions + - Updated Go modules to latest versions + + ## Testing + - โœ… All tests passing + - โœ… Build successful + + Please review the changes and merge if everything looks good. + branch: automated-dependency-updates + delete-branch: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..1e51acd --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,109 @@ +name: Release + +on: + push: + tags: + - 'v*' + workflow_dispatch: + inputs: + version: + description: 'Release version (e.g., v1.0.0)' + required: true + type: string + +jobs: + release: + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - 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: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Build TypeScript applications + run: pnpm build + env: + DATABASE_URL: "postgresql://dummy:dummy@localhost:5432/dummy" + AUTH_SECRET: "dummy-secret-for-build" + NEXTAUTH_URL: "http://localhost:3000" + + - name: Build Go application + run: | + cd apps/agent + go build -ldflags="-s -w" -o bin/agent . + + - name: Create release archives + run: | + # Create web app archive + tar -czf web-app.tar.gz -C apps/web .next package.json + + # Create agent binary archive + tar -czf agent-binary.tar.gz -C apps/agent bin/agent + + - name: Generate changelog + id: changelog + run: | + if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then + VERSION="${{ github.event.inputs.version }}" + else + VERSION="${{ github.ref_name }}" + fi + + echo "## What's Changed" > CHANGELOG.md + echo "" >> CHANGELOG.md + echo "See the full changelog at [CHANGELOG.md](./CHANGELOG.md)" >> CHANGELOG.md + + echo "changelog<> $GITHUB_OUTPUT + cat CHANGELOG.md >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: Create Release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.event.inputs.version || github.ref_name }} + release_name: Release ${{ github.event.inputs.version || github.ref_name }} + body: ${{ steps.changelog.outputs.changelog }} + draft: false + prerelease: false + + - name: Upload Web App Archive + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./web-app.tar.gz + asset_name: web-app.tar.gz + asset_content_type: application/gzip + + - name: Upload Agent Binary Archive + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./agent-binary.tar.gz + asset_name: agent-binary.tar.gz + asset_content_type: application/gzip diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml new file mode 100644 index 0000000..da9d2db --- /dev/null +++ b/.github/workflows/security.yml @@ -0,0 +1,106 @@ +name: Security + +on: + push: + branches: [main] + pull_request: + branches: [main] + schedule: + # Run security scans daily at 3 AM UTC + - cron: '0 3 * * *' + +jobs: + security-scan: + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + steps: + - 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' + + nodejs-security: + 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: Run npm audit + run: pnpm audit --audit-level high + + go-security: + 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 gosec + run: go install github.com/securecodewarrior/gosec/v2/cmd/gosec@latest + + - name: Run gosec Security Scanner + run: gosec -fmt sarif -out gosec-results.sarif ./... + + - name: Upload gosec scan results to GitHub Security tab + uses: github/codeql-action/upload-sarif@v3 + if: always() + with: + sarif_file: apps/agent/gosec-results.sarif + + codeql: + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + strategy: + fail-fast: false + matrix: + language: ['javascript', 'go'] + steps: + - uses: actions/checkout@v4 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + + - name: Autobuild + uses: github/codeql-action/autobuild@v3 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{matrix.language}}" diff --git a/.gitignore b/.gitignore index 96fab4f..cc9f64a 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bb5ee54..449d6b3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 @@ -22,8 +24,110 @@ 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 GitHub Actions CI pipeline automatically runs on every pull request and push to main: + +### Continuous Integration Checks + +- **๐Ÿ” Change Detection**: Optimizes CI runs by detecting which parts of the codebase changed +- **๐Ÿงน Linting**: ESLint for TypeScript, go vet + staticcheck for Go +- **๐ŸŽจ Formatting**: Prettier for TypeScript, gofmt + goimports for Go +- **๐Ÿ”’ Type Checking**: TypeScript compiler strict checks +- **๐Ÿงช Testing**: Unit tests for both Go and TypeScript +- **๐Ÿ—๏ธ Building**: Next.js builds and Go binary compilation +- **๐Ÿ—„๏ธ Database**: PostgreSQL migration testing + +### Security Scanning + +- **๐Ÿ›ก๏ธ CodeQL**: Semantic code analysis +- **๐Ÿ” Trivy**: Vulnerability scanning +- **๐Ÿ” gosec**: Go security analysis +- **๐Ÿ“ฆ npm audit**: Node.js dependency security + +### Performance Optimizations + +- **๐Ÿ“ฆ Caching**: Go modules, pnpm store, and build artifacts +- **โšก Parallelization**: Jobs run in parallel when possible +- **๐ŸŽฏ Smart Triggers**: Only runs relevant checks based on changed files + +### 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 checks: +- โœ… Linting (TypeScript + Go) +- โœ… Formatting (TypeScript + Go) +- โœ… Type checking (TypeScript) +- โœ… Tests (TypeScript + Go) +- โœ… Build (Next.js + Go binary) +- โœ… Database migrations (PostgreSQL) + ## ๐ŸŽฏ Ways to Contribute ### ๐Ÿ› Bug Reports diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..dbe8f39 --- /dev/null +++ b/Makefile @@ -0,0 +1,75 @@ +# Development Makefile for Dev8.dev + +.PHONY: help install dev build test lint format clean setup-go check-all + +# Default target +help: ## Show this help message + @echo "Available commands:" + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}' + +install: ## Install all dependencies + @echo "Installing dependencies..." + pnpm install + @echo "Setting up Go tools..." + cd apps/agent && ./setup-go-tools.sh + +dev: ## Start development servers + @echo "Starting development servers..." + pnpm dev + +build: ## Build all applications + @echo "Building all applications..." + pnpm build + +test: ## Run all tests + @echo "Running tests..." + pnpm test + +lint: ## Run linting for all languages + @echo "Running TypeScript linting..." + pnpm lint + @echo "Running Go linting..." + pnpm lint:go + +format: ## Format code for all languages + @echo "Formatting TypeScript code..." + pnpm format + @echo "Formatting Go code..." + pnpm format:go + +check-types: ## Type check TypeScript code + @echo "Type checking..." + pnpm check-types + +clean: ## Clean build artifacts + @echo "Cleaning build artifacts..." + pnpm clean + +setup-go: ## Setup Go development tools + @echo "Setting up Go tools..." + cd apps/agent && ./setup-go-tools.sh + +check-all: ## Run all checks (lint, format, type-check, test, build) + @echo "Running all checks..." + @echo "1. Linting..." + make lint + @echo "2. Format checking..." + make format + @echo "3. Type checking..." + make check-types + @echo "4. Testing..." + make test + @echo "5. Building..." + make build + @echo "โœ… All checks passed!" + +# CI simulation +ci: ## Simulate CI pipeline locally + @echo "๐Ÿš€ Simulating CI pipeline..." + @echo "This will run the same checks as our GitHub Actions" + make check-all + +# Quick development setup +quick-start: install ## Quick setup and start development + @echo "๐Ÿš€ Quick start complete! Starting development servers..." + make dev diff --git a/README.md b/README.md index 8ace354..47cbdb7 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,9 @@ *Launch customizable VS Code instances in the cloud with zero setup. Code anywhere, anytime.* [![Discord](https://img.shields.io/discord/YOUR_DISCORD_ID?color=7289da&label=Discord&logo=discord&logoColor=white&style=for-the-badge)](https://discord.gg/xE2u4b8S8g) + [![CI](https://github.com/VAIBHAVSING/Dev8.dev/actions/workflows/ci.yml/badge.svg)](https://github.com/VAIBHAVSING/Dev8.dev/actions/workflows/ci.yml) + [![Security](https://github.com/VAIBHAVSING/Dev8.dev/actions/workflows/security.yml/badge.svg)](https://github.com/VAIBHAVSING/Dev8.dev/actions/workflows/security.yml) + [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![License](https://img.shields.io/github/license/VAIBHAVSING/Dev8.dev?style=for-the-badge)](LICENSE) [![GitHub stars](https://img.shields.io/github/stars/VAIBHAVSING/Dev8.dev?style=for-the-badge)](https://github.com/VAIBHAVSING/Dev8.dev/stargazers) @@ -116,6 +119,53 @@ cp apps/web/.env.example apps/web/.env.local pnpm dev ``` +## ๐Ÿค– CI/CD Pipeline + +This project uses GitHub Actions for continuous integration and deployment: + +### Automated Checks + +Every pull request and push triggers: + +- **๐Ÿ” Smart Change Detection**: Only runs relevant jobs based on changed files +- **๐Ÿงน Linting**: ESLint (TypeScript) + go vet + staticcheck (Go) +- **๐ŸŽจ Code Formatting**: Prettier (TypeScript) + gofmt + goimports (Go) +- **๐Ÿ”’ Type Safety**: TypeScript strict compiler checks +- **๐Ÿงช Testing**: Unit tests for both Go and TypeScript applications +- **๐Ÿ—๏ธ Build Verification**: Next.js builds + Go binary compilation +- **๐Ÿ—„๏ธ Database Testing**: PostgreSQL migration validation + +### Security & Quality + +- **๐Ÿ›ก๏ธ CodeQL Analysis**: Semantic security scanning +- **๐Ÿ” Vulnerability Scanning**: Trivy for dependencies +- **๐Ÿ” Go Security**: gosec static analysis +- **๐Ÿ“ฆ Dependency Auditing**: npm audit for Node.js packages + +### Local Development + +Simulate the CI pipeline locally: + +```bash +# Install the development tools +make install + +# Run all CI checks locally +make ci + +# Individual checks +make lint # Lint all code +make format # Format all code +make test # Run all tests +make build # Build all applications +``` + +### Performance Features + +- **๐Ÿ“ฆ Intelligent Caching**: Go modules, pnpm store, build artifacts +- **โšก Parallel Execution**: Jobs run concurrently when possible +- **๐ŸŽฏ Conditional Execution**: Skip unchanged components + ## ๐Ÿ“ Project Structure ``` diff --git a/apps/agent/main_test.go b/apps/agent/main_test.go new file mode 100644 index 0000000..45fed7c --- /dev/null +++ b/apps/agent/main_test.go @@ -0,0 +1,66 @@ +package main + +import ( + "net/http" + "net/http/httptest" + "testing" +) + +func TestHealthHandler(t *testing.T) { + // Create a request to pass to our handler + req, err := http.NewRequest("GET", "/health", nil) + if err != nil { + t.Fatal(err) + } + + // Create a ResponseRecorder (which satisfies http.ResponseWriter) to record the response + rr := httptest.NewRecorder() + handler := http.HandlerFunc(healthHandler) + + // Call the handler with our request and recorder + handler.ServeHTTP(rr, req) + + // Check the status code is what we expect + if status := rr.Code; status != http.StatusOK { + t.Errorf("handler returned wrong status code: got %v want %v", + status, http.StatusOK) + } + + // Check the response body contains expected content + if contentType := rr.Header().Get("Content-Type"); contentType != "application/json" { + t.Errorf("handler returned wrong content type: got %v want %v", + contentType, "application/json") + } + + // Check if the response body is not empty + if rr.Body.String() == "" { + t.Error("handler returned empty body") + } +} + +func TestHelloHandler(t *testing.T) { + // Create a request to pass to our handler + req, err := http.NewRequest("GET", "/hello", nil) + if err != nil { + t.Fatal(err) + } + + // Create a ResponseRecorder to record the response + rr := httptest.NewRecorder() + handler := http.HandlerFunc(helloHandler) + + // Call the handler + handler.ServeHTTP(rr, req) + + // Check the status code + if status := rr.Code; status != http.StatusOK { + t.Errorf("handler returned wrong status code: got %v want %v", + status, http.StatusOK) + } + + // Check content type + if contentType := rr.Header().Get("Content-Type"); contentType != "application/json" { + t.Errorf("handler returned wrong content type: got %v want %v", + contentType, "application/json") + } +} diff --git a/apps/docs/package.json b/apps/docs/package.json index af13a3d..3e65a20 100644 --- a/apps/docs/package.json +++ b/apps/docs/package.json @@ -8,7 +8,8 @@ "build": "next build", "start": "next start", "lint": "next lint --max-warnings 0", - "check-types": "tsc --noEmit" + "check-types": "tsc --noEmit", + "test": "echo 'No tests specified yet' && exit 0" }, "dependencies": { "@repo/ui": "workspace:*", diff --git a/apps/web/package.json b/apps/web/package.json index 91c25c1..f78a1bb 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -9,6 +9,7 @@ "start": "next start", "lint": "next lint --max-warnings 0", "check-types": "tsc --noEmit", + "test": "echo 'No tests specified yet' && exit 0", "db:generate": "prisma generate", "db:migrate": "prisma migrate dev", "db:studio": "prisma studio", diff --git a/package.json b/package.json index 2378dc7..f35dd63 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "format": "prettier --write \"**/*.{ts,tsx,md}\" && turbo run format:go", "format:go": "turbo run format:go", "check-types": "turbo run check-types", + "test": "turbo run test", "setup:go": "cd apps/agent && ./setup-go-tools.sh", "clean": "turbo run clean" }, diff --git a/turbo.json b/turbo.json index 44a30a3..1dbac64 100644 --- a/turbo.json +++ b/turbo.json @@ -34,6 +34,10 @@ "check-types": { "dependsOn": ["^check-types"] }, + "test": { + "dependsOn": ["^test"], + "inputs": ["src/**/*.{ts,tsx,js,jsx}", "test/**/*", "tests/**/*", "**/*.test.*", "**/*.spec.*"] + }, "dev": { "cache": false, "persistent": true, From 75335b3d198be2f2512bae6119f5d0bdf54e6349 Mon Sep 17 00:00:00 2001 From: VAIBHAVSING Date: Wed, 27 Aug 2025 17:19:52 +0530 Subject: [PATCH 2/4] feat: fix ci --- .github/workflows/ci.yml | 288 +++++++++------------------- .github/workflows/dependencies.yml | 17 +- .github/workflows/release.yml | 109 ----------- .github/workflows/security.yml | 106 ---------- CONTRIBUTING.md | 58 +++--- README.md | 49 +++-- apps/agent/README.md | 8 + apps/agent/bin/agent | Bin 8488653 -> 8488653 bytes apps/web/app/(auth)/signin/page.tsx | 3 +- apps/web/app/(auth)/signup/page.tsx | 3 +- apps/web/app/page.tsx | 6 +- apps/web/lib/auth-config.ts | 35 +++- apps/web/middleware.ts | 2 +- 13 files changed, 200 insertions(+), 484 deletions(-) delete mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/security.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 486a2db..0222686 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,9 @@ on: branches: [main, develop] pull_request: branches: [main, develop] + schedule: + # Run security scans daily at 3 AM UTC + - cron: '0 3 * * *' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -50,11 +53,15 @@ jobs: agent: - 'apps/agent/**' - # TypeScript/Node.js jobs - typescript-lint: + # TypeScript/Node.js Complete Pipeline + typescript-pipeline: needs: changes if: ${{ needs.changes.outputs.typescript == 'true' }} runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write steps: - uses: actions/checkout@v4 @@ -86,39 +93,6 @@ jobs: - name: Lint TypeScript run: pnpm lint - - typescript-format: - needs: changes - if: ${{ needs.changes.outputs.typescript == 'true' }} - 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: Get pnpm store directory - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - - name: Setup pnpm cache - uses: actions/cache@v4 - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Install dependencies - run: pnpm install --frozen-lockfile - name: Check TypeScript formatting run: | @@ -128,75 +102,12 @@ jobs: git diff exit 1 fi - - typescript-typecheck: - needs: changes - if: ${{ needs.changes.outputs.typescript == 'true' }} - 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: Get pnpm store directory - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - - name: Setup pnpm cache - uses: actions/cache@v4 - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Install dependencies - run: pnpm install --frozen-lockfile - name: Type check run: pnpm check-types - - typescript-build: - needs: changes - if: ${{ needs.changes.outputs.typescript == 'true' }} - 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: Get pnpm store directory - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - - name: Setup pnpm cache - uses: actions/cache@v4 - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Install dependencies - run: pnpm install --frozen-lockfile + + - name: Run tests + run: pnpm test - name: Build applications run: pnpm build @@ -205,12 +116,29 @@ jobs: DATABASE_URL: "postgresql://dummy:dummy@localhost:5432/dummy" AUTH_SECRET: "dummy-secret-for-build" NEXTAUTH_URL: "http://localhost:3000" + + - name: Run npm audit + run: pnpm audit --audit-level high + + - name: Initialize CodeQL (JavaScript) + uses: github/codeql-action/init@v3 + with: + languages: 'javascript' + + - name: Perform CodeQL Analysis (JavaScript) + uses: github/codeql-action/analyze@v3 + with: + category: "/language:javascript" - # Go jobs - go-lint: + # Go Complete Pipeline + go-pipeline: needs: changes if: ${{ needs.changes.outputs.go == 'true' }} runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write defaults: run: working-directory: ./apps/agent @@ -235,32 +163,17 @@ jobs: - name: Download dependencies run: go mod download - - name: Install staticcheck - run: go install honnef.co/go/tools/cmd/staticcheck@latest + - name: Install Go tools + run: | + go install honnef.co/go/tools/cmd/staticcheck@latest + go install golang.org/x/tools/cmd/goimports@latest + go install github.com/securecodewarrior/gosec/v2/cmd/gosec@latest - name: Run go vet run: go vet ./... - name: Run staticcheck run: staticcheck ./... - - go-format: - needs: changes - if: ${{ needs.changes.outputs.go == 'true' }} - 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 goimports - run: go install golang.org/x/tools/cmd/goimports@latest - name: Check Go formatting run: | @@ -277,75 +190,38 @@ jobs: echo "Go imports are not properly formatted. Please run 'goimports -w .' and commit the changes." exit 1 fi - - go-test: - needs: changes - if: ${{ needs.changes.outputs.go == 'true' }} - 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: Cache Go modules - uses: actions/cache@v4 - with: - path: | - ~/.cache/go-build - ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - - name: Download dependencies - run: go mod download - - name: Run tests + - name: Run tests with coverage run: go test -v -race -coverprofile=coverage.out ./... + - name: Build application + run: go build -v -o bin/agent . + + - name: Run gosec Security Scanner + run: gosec -fmt sarif -out gosec-results.sarif ./... + + - name: Upload gosec scan results to GitHub Security tab + uses: github/codeql-action/upload-sarif@v3 + if: always() + with: + sarif_file: apps/agent/gosec-results.sarif + + - name: Initialize CodeQL (Go) + uses: github/codeql-action/init@v3 + with: + languages: 'go' + + - name: Perform CodeQL Analysis (Go) + uses: github/codeql-action/analyze@v3 + with: + category: "/language:go" + - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 with: file: ./apps/agent/coverage.out flags: go name: go-coverage - - go-build: - needs: changes - if: ${{ needs.changes.outputs.go == 'true' }} - 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: Cache Go modules - uses: actions/cache@v4 - with: - path: | - ~/.cache/go-build - ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - - name: Download dependencies - run: go mod download - - - name: Build application - run: go build -v -o bin/agent . - name: Upload build artifact uses: actions/upload-artifact@v4 @@ -353,6 +229,30 @@ jobs: name: agent-binary path: apps/agent/bin/agent + # General Security Scanning + security-scan: + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + steps: + - 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' + # Database migration test (for web app) test-db-migrations: needs: changes @@ -402,28 +302,18 @@ jobs: runs-on: ubuntu-latest needs: [ changes, - typescript-lint, - typescript-format, - typescript-typecheck, - typescript-build, - go-lint, - go-format, - go-test, - go-build, + typescript-pipeline, + go-pipeline, + security-scan, test-db-migrations ] if: always() steps: - name: Check CI success run: | - if [[ "${{ needs.typescript-lint.result }}" == "failure" || \ - "${{ needs.typescript-format.result }}" == "failure" || \ - "${{ needs.typescript-typecheck.result }}" == "failure" || \ - "${{ needs.typescript-build.result }}" == "failure" || \ - "${{ needs.go-lint.result }}" == "failure" || \ - "${{ needs.go-format.result }}" == "failure" || \ - "${{ needs.go-test.result }}" == "failure" || \ - "${{ needs.go-build.result }}" == "failure" || \ + if [[ "${{ needs.typescript-pipeline.result }}" == "failure" || \ + "${{ needs.go-pipeline.result }}" == "failure" || \ + "${{ needs.security-scan.result }}" == "failure" || \ "${{ needs.test-db-migrations.result }}" == "failure" ]]; then echo "One or more CI jobs failed" exit 1 diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml index bde896b..fb0433a 100644 --- a/.github/workflows/dependencies.yml +++ b/.github/workflows/dependencies.yml @@ -33,8 +33,7 @@ jobs: go-version: '1.24' - name: Update Node.js dependencies - run: | - pnpm update --latest + run: pnpm update --latest - name: Update Go dependencies run: | @@ -42,11 +41,12 @@ jobs: go get -u ./... go mod tidy - - name: Run tests after updates + - name: Run basic checks after updates run: | pnpm install - pnpm test - cd apps/agent && go test ./... + pnpm lint + pnpm check-types + cd apps/agent && go vet ./... && go build . - name: Create Pull Request uses: peter-evans/create-pull-request@v5 @@ -62,9 +62,10 @@ jobs: - Updated Go modules to latest versions ## Testing - - โœ… All tests passing - - โœ… Build successful + - โœ… Linting passed + - โœ… Type checking passed + - โœ… Basic build successful - Please review the changes and merge if everything looks good. + Please review the changes and run full tests before merging. branch: automated-dependency-updates delete-branch: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 1e51acd..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,109 +0,0 @@ -name: Release - -on: - push: - tags: - - 'v*' - workflow_dispatch: - inputs: - version: - description: 'Release version (e.g., v1.0.0)' - required: true - type: string - -jobs: - release: - runs-on: ubuntu-latest - permissions: - contents: write - packages: write - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - 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: Install dependencies - run: pnpm install --frozen-lockfile - - - name: Build TypeScript applications - run: pnpm build - env: - DATABASE_URL: "postgresql://dummy:dummy@localhost:5432/dummy" - AUTH_SECRET: "dummy-secret-for-build" - NEXTAUTH_URL: "http://localhost:3000" - - - name: Build Go application - run: | - cd apps/agent - go build -ldflags="-s -w" -o bin/agent . - - - name: Create release archives - run: | - # Create web app archive - tar -czf web-app.tar.gz -C apps/web .next package.json - - # Create agent binary archive - tar -czf agent-binary.tar.gz -C apps/agent bin/agent - - - name: Generate changelog - id: changelog - run: | - if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then - VERSION="${{ github.event.inputs.version }}" - else - VERSION="${{ github.ref_name }}" - fi - - echo "## What's Changed" > CHANGELOG.md - echo "" >> CHANGELOG.md - echo "See the full changelog at [CHANGELOG.md](./CHANGELOG.md)" >> CHANGELOG.md - - echo "changelog<> $GITHUB_OUTPUT - cat CHANGELOG.md >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - - - name: Create Release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.event.inputs.version || github.ref_name }} - release_name: Release ${{ github.event.inputs.version || github.ref_name }} - body: ${{ steps.changelog.outputs.changelog }} - draft: false - prerelease: false - - - name: Upload Web App Archive - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./web-app.tar.gz - asset_name: web-app.tar.gz - asset_content_type: application/gzip - - - name: Upload Agent Binary Archive - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./agent-binary.tar.gz - asset_name: agent-binary.tar.gz - asset_content_type: application/gzip diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml deleted file mode 100644 index da9d2db..0000000 --- a/.github/workflows/security.yml +++ /dev/null @@ -1,106 +0,0 @@ -name: Security - -on: - push: - branches: [main] - pull_request: - branches: [main] - schedule: - # Run security scans daily at 3 AM UTC - - cron: '0 3 * * *' - -jobs: - security-scan: - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - steps: - - 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' - - nodejs-security: - 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: Run npm audit - run: pnpm audit --audit-level high - - go-security: - 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 gosec - run: go install github.com/securecodewarrior/gosec/v2/cmd/gosec@latest - - - name: Run gosec Security Scanner - run: gosec -fmt sarif -out gosec-results.sarif ./... - - - name: Upload gosec scan results to GitHub Security tab - uses: github/codeql-action/upload-sarif@v3 - if: always() - with: - sarif_file: apps/agent/gosec-results.sarif - - codeql: - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - strategy: - fail-fast: false - matrix: - language: ['javascript', 'go'] - steps: - - uses: actions/checkout@v4 - - - name: Initialize CodeQL - uses: github/codeql-action/init@v3 - with: - languages: ${{ matrix.language }} - - - name: Autobuild - uses: github/codeql-action/autobuild@v3 - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 - with: - category: "/language:${{matrix.language}}" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 449d6b3..9e4759a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -32,7 +32,7 @@ Thank you for your interest in contributing to Dev8.dev! ๐ŸŽ‰ We're building the ### Prerequisites -- **Node.js** 18+ +- **Node.js** 18+ - **pnpm** 9.0.0+ - **Go** 1.24+ - **PostgreSQL** 15+ @@ -53,7 +53,7 @@ make check-all # runs lint, format, type-check, test, build # Individual checks make lint # or pnpm lint -make format # or pnpm format +make format # or pnpm format make test # or pnpm test make build # or pnpm build make check-types # or pnpm check-types @@ -79,28 +79,37 @@ This ensures your changes will pass our CI pipeline. Our GitHub Actions CI pipeline automatically runs on every pull request and push to main: -### Continuous Integration Checks +### Consolidated Pipeline Structure -- **๐Ÿ” Change Detection**: Optimizes CI runs by detecting which parts of the codebase changed -- **๐Ÿงน Linting**: ESLint for TypeScript, go vet + staticcheck for Go -- **๐ŸŽจ Formatting**: Prettier for TypeScript, gofmt + goimports for Go +We use a single CI workflow with two main language-specific pipelines: + +#### **๐ŸŸฆ TypeScript Pipeline** + +- **๐Ÿงน Linting**: ESLint with strict rules +- **๐ŸŽจ Formatting**: Prettier validation - **๐Ÿ”’ Type Checking**: TypeScript compiler strict checks -- **๐Ÿงช Testing**: Unit tests for both Go and TypeScript -- **๐Ÿ—๏ธ Building**: Next.js builds and Go binary compilation -- **๐Ÿ—„๏ธ Database**: PostgreSQL migration testing +- **๐Ÿงช Testing**: Unit and integration tests +- **๐Ÿ—๏ธ Building**: Next.js application builds +- **๐Ÿ“ฆ Security**: npm audit + CodeQL analysis + +#### **๐ŸŸฉ Go Pipeline** -### Security Scanning +- **๐Ÿงน Linting**: go vet + staticcheck +- **๐ŸŽจ Formatting**: gofmt + goimports validation +- **๐Ÿงช Testing**: Unit tests with race detection + coverage +- **๐Ÿ—๏ธ Building**: Binary compilation +- **๐Ÿ” Security**: gosec + CodeQL analysis -- **๐Ÿ›ก๏ธ CodeQL**: Semantic code analysis -- **๐Ÿ” Trivy**: Vulnerability scanning -- **๐Ÿ” gosec**: Go security analysis -- **๐Ÿ“ฆ npm audit**: Node.js dependency security +#### **๏ฟฝ๏ธ General Security & Testing** + +- **๐Ÿ” Vulnerability Scanning**: Trivy for all dependencies +- **๏ฟฝ๏ธ Database**: PostgreSQL migration testing ### Performance Optimizations -- **๐Ÿ“ฆ Caching**: Go modules, pnpm store, and build artifacts -- **โšก Parallelization**: Jobs run in parallel when possible -- **๐ŸŽฏ Smart Triggers**: Only runs relevant checks based on changed files +- **๐Ÿ“ฆ 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 @@ -112,7 +121,7 @@ make ci # Or step by step make lint -make format +make format make check-types make test make build @@ -120,13 +129,12 @@ make build ### Status Checks -All PRs must pass these checks: -- โœ… Linting (TypeScript + Go) -- โœ… Formatting (TypeScript + Go) -- โœ… Type checking (TypeScript) -- โœ… Tests (TypeScript + Go) -- โœ… Build (Next.js + Go binary) -- โœ… Database migrations (PostgreSQL) +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 diff --git a/README.md b/README.md index 47cbdb7..4bad7e6 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ [![Discord](https://img.shields.io/discord/YOUR_DISCORD_ID?color=7289da&label=Discord&logo=discord&logoColor=white&style=for-the-badge)](https://discord.gg/xE2u4b8S8g) [![CI](https://github.com/VAIBHAVSING/Dev8.dev/actions/workflows/ci.yml/badge.svg)](https://github.com/VAIBHAVSING/Dev8.dev/actions/workflows/ci.yml) - [![Security](https://github.com/VAIBHAVSING/Dev8.dev/actions/workflows/security.yml/badge.svg)](https://github.com/VAIBHAVSING/Dev8.dev/actions/workflows/security.yml) + [![Dependencies](https://github.com/VAIBHAVSING/Dev8.dev/actions/workflows/dependencies.yml/badge.svg)](https://github.com/VAIBHAVSING/Dev8.dev/actions/workflows/dependencies.yml) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![License](https://img.shields.io/github/license/VAIBHAVSING/Dev8.dev?style=for-the-badge)](LICENSE) [![GitHub stars](https://img.shields.io/github/stars/VAIBHAVSING/Dev8.dev?style=for-the-badge)](https://github.com/VAIBHAVSING/Dev8.dev/stargazers) @@ -121,26 +121,39 @@ pnpm dev ## ๐Ÿค– CI/CD Pipeline -This project uses GitHub Actions for continuous integration and deployment: +This project uses a consolidated GitHub Actions CI pipeline organized by language: -### Automated Checks +### Single CI Workflow -Every pull request and push triggers: +Every pull request and push triggers a comprehensive pipeline with two main tracks: -- **๐Ÿ” Smart Change Detection**: Only runs relevant jobs based on changed files -- **๐Ÿงน Linting**: ESLint (TypeScript) + go vet + staticcheck (Go) -- **๐ŸŽจ Code Formatting**: Prettier (TypeScript) + gofmt + goimports (Go) +#### **๐ŸŸฆ TypeScript Pipeline** + +- **๐Ÿงน Linting**: ESLint with strict rules +- **๐ŸŽจ Code Formatting**: Prettier validation - **๐Ÿ”’ Type Safety**: TypeScript strict compiler checks -- **๐Ÿงช Testing**: Unit tests for both Go and TypeScript applications -- **๐Ÿ—๏ธ Build Verification**: Next.js builds + Go binary compilation -- **๐Ÿ—„๏ธ Database Testing**: PostgreSQL migration validation +- **๐Ÿงช Testing**: Unit and integration tests +- **๐Ÿ—๏ธ Build Verification**: Next.js application builds +- **๐Ÿ“ฆ Security**: npm audit + CodeQL analysis + +#### **๐ŸŸฉ Go Pipeline** + +- **๐Ÿงน Linting**: go vet + staticcheck +- **๐ŸŽจ Code Formatting**: gofmt + goimports validation +- **๐Ÿงช Testing**: Unit tests with race detection + coverage +- **๐Ÿ—๏ธ Build Verification**: Binary compilation +- **๐Ÿ” Security**: gosec + CodeQL analysis -### Security & Quality +#### **๐Ÿ›ก๏ธ General Security** -- **๐Ÿ›ก๏ธ CodeQL Analysis**: Semantic security scanning -- **๐Ÿ” Vulnerability Scanning**: Trivy for dependencies -- **๐Ÿ” Go Security**: gosec static analysis -- **๐Ÿ“ฆ Dependency Auditing**: npm audit for Node.js packages +- **๐Ÿ” Vulnerability Scanning**: Trivy for all dependencies +- **๏ฟฝ๏ธ Database Testing**: PostgreSQL migration validation + +### Performance Features + +- **๐Ÿ“ฆ Smart Caching**: Go modules, pnpm store, build artifacts +- **๐ŸŽฏ Change Detection**: Only runs relevant pipelines based on file changes +- **โšก Parallel Execution**: Language pipelines run concurrently ### Local Development @@ -160,12 +173,6 @@ make test # Run all tests make build # Build all applications ``` -### Performance Features - -- **๐Ÿ“ฆ Intelligent Caching**: Go modules, pnpm store, build artifacts -- **โšก Parallel Execution**: Jobs run concurrently when possible -- **๐ŸŽฏ Conditional Execution**: Skip unchanged components - ## ๐Ÿ“ Project Structure ``` diff --git a/apps/agent/README.md b/apps/agent/README.md index ea070c8..bd09e09 100644 --- a/apps/agent/README.md +++ b/apps/agent/README.md @@ -27,6 +27,7 @@ Run the setup script to install all Go development tools: ``` This will install: + - `golangci-lint` - Comprehensive linter - `goimports` - Import formatting - `gofumpt` - Enhanced Go formatter @@ -142,9 +143,11 @@ pnpm dev ## ๐Ÿ“ก API Endpoints ### `GET /` + Root endpoint with basic information. **Response:** + ```json { "message": "Go Agent API", @@ -153,9 +156,11 @@ Root endpoint with basic information. ``` ### `GET /health` + Health check endpoint. **Response:** + ```json { "message": "Agent is healthy", @@ -164,9 +169,11 @@ Health check endpoint. ``` ### `GET /hello` + Hello world endpoint. **Response:** + ```json { "message": "Hello from Go Agent", @@ -231,6 +238,7 @@ make check ``` This will: + 1. Check code formatting 2. Run the linter 3. Execute all tests diff --git a/apps/agent/bin/agent b/apps/agent/bin/agent index 518fb73c3d78759efa120f30dc9376cc4a82a1f0..1e04bc78c784fb720a5553ce7d4fad5cdcaeafb3 100755 GIT binary patch delta 837 zcmb`?Nlz1T0EY1*RYBCMps2X7bt%)CY0JO3Ko>1wTgp=E)CD_B*#>EWf+AXti9LDp z(0JnmnCPwFz)M47Jn6}!F-`aeCO+Q$03LpqH+c`w=G!;UO?xmQ%48s-_*OK@7N(XQPed~D zV4^VQUC5_wkHhJ3I6BabSTgPCTrdABefZWbzPP`BuK#`?{#cJo_KY6zNv|8OO2gHJ zZD@uQ+pz;X(Sla&LK}8t5BB2kcOUlS0NT-kgE)jv9L5nGMHi0YI8NXsPT@4p;4IGJ zJTBlO+_;3xxPq(jpc@jrkfA_@4}JvDQ){?{YPQR=>Q_{c+FrfF3BOQNeqmU~ryucB7BLSxFi?@eu$jgmkRy|{+! zxPhDKLq9?YBZ4Sy;WlCzz#xWj2XQ2j#4u7Ascn=-TkHQjqe2G8k;VivxC;$g+{1l5 zz(Y*p5pvLBz=VZ7rZ9~e%wi5U=J6N{D4>W%EMXZXtY8&S@Dyu!hIKs03zYG)wiSBy GBl-sx5mik9 delta 837 zcmb`?xldC80LSqnMM2c6;E5+*c;LI*cOWV)M@1`@LTRgF?R&3<)*|+J74Se~Vkcc3 zx{{b^Vi?@I`41QdM+f6*ViV%-;@8bTz~Qs}lHc%Md-c-2hL3sAa!JW)(p)?}s$?U+ z#o^d&u{b3ZjBuh<4n>!887DtsB*nl;MM%tq$5pG4PozQ-IjIiH-bzB4jFxRH7Shte zc`Gj2X1L@8TyB@k)rn>V$D*#nuXjJYU%y}d@@;xy^>_b=x9*ltLOyG%Ug1TcA^8F*oEELgT2^?{pi909K<0U#t|GvH;&;r zPT(X?p$DgN24`^&y*Lj6A|%LA;Drw=w0gs%D|Uxyh^j30DyF9U#FVMZW~wHY^&dU| zE?!;nX||p5W(-ZX3`Nu}QPpKjGSjKrfTMS{ibkKP_Q_Ih-9I6}`P$T8U2$|6=)(o{ z<03BMG6vvB0D~C9Fh&r>6^!C4t|5f$7(*C0FkWAAB5j}lcSe;AOd^UY#1KaUH*pKM zF^xM&;x1A!VZlZk8O&f7S>$jJdCcKH=J5ap6j4GM4k~zv1uS9-kMI~z@D$5 { router.push("/signin"); }, 2000); - } catch (error) { + } catch (error: unknown) { + console.error("Sign up error:", error); setError("An error occurred. Please try again."); } finally { setIsLoading(false); diff --git a/apps/web/app/page.tsx b/apps/web/app/page.tsx index abffd2f..416379d 100644 --- a/apps/web/app/page.tsx +++ b/apps/web/app/page.tsx @@ -11,7 +11,7 @@ export default function HomePage() {

Your development platform for modern web applications

- +

Get started with your development journey @@ -32,7 +32,7 @@ export default function HomePage() {

- +

Modern Stack

@@ -56,4 +56,4 @@ export default function HomePage() {
); -} \ No newline at end of file +} diff --git a/apps/web/lib/auth-config.ts b/apps/web/lib/auth-config.ts index 9ad8ea7..fd55e53 100644 --- a/apps/web/lib/auth-config.ts +++ b/apps/web/lib/auth-config.ts @@ -5,12 +5,16 @@ import { PrismaAdapter } from "@auth/prisma-adapter"; import { prisma } from "./prisma"; import bcrypt from "bcryptjs"; import { signInSchema } from "./zod"; +import type { AuthOptions } from "next-auth"; +import type { JWT } from "next-auth/jwt"; +import type { Session, User } from "next-auth"; +import type { Account, Profile } from "next-auth"; /** * Shared NextAuth configuration factory * This ensures DRY principles and consistency between auth.ts and route.ts */ -export function createAuthConfig(): any { +export function createAuthConfig(): AuthOptions { const providers = []; // Only add Google provider if credentials are available @@ -19,8 +23,10 @@ export function createAuthConfig(): any { Google({ clientId: process.env.AUTH_GOOGLE_ID, clientSecret: process.env.AUTH_GOOGLE_SECRET, - authorization: { params: { access_type: "offline", prompt: "consent" } }, - }) + authorization: { + params: { access_type: "offline", prompt: "consent" }, + }, + }), ); } @@ -30,7 +36,7 @@ export function createAuthConfig(): any { GitHub({ clientId: process.env.AUTH_GITHUB_ID, clientSecret: process.env.AUTH_GITHUB_SECRET, - }) + }), ); } @@ -43,7 +49,8 @@ export function createAuthConfig(): any { }, authorize: async (credentials) => { try { - const { email, password } = await signInSchema.parseAsync(credentials); + const { email, password } = + await signInSchema.parseAsync(credentials); // Find user in database const user = await prisma.user.findUnique({ @@ -71,7 +78,7 @@ export function createAuthConfig(): any { return null; } }, - }) + }), ); return { @@ -81,21 +88,29 @@ export function createAuthConfig(): any { }, providers, callbacks: { - async jwt({ token, user }: { token: any; user: any }) { + async jwt({ token, user }: { token: JWT; user?: User }) { if (user) { token.id = user.id; } return token; }, - async session({ session, token }: { session: any; token: any }) { + async session({ session, token }: { session: Session; token: JWT }) { if (token && session.user) { session.user.id = token.id as string; } return session; }, - async signIn({ account, profile }: { account: any; profile?: any }) { + async signIn({ + account, + profile, + }: { + account: Account | null; + profile?: Profile; + }) { if (account?.provider === "google" && profile) { - return (profile as { email_verified?: boolean })?.email_verified === true; + return ( + (profile as { email_verified?: boolean })?.email_verified === true + ); } if (account?.provider === "github") { return true; diff --git a/apps/web/middleware.ts b/apps/web/middleware.ts index c60954b..ee212fd 100644 --- a/apps/web/middleware.ts +++ b/apps/web/middleware.ts @@ -10,7 +10,7 @@ const PROTECTED_ROUTES = ["/"]; // Protect all routes except those in PUBLIC_ROU export async function middleware(req: NextRequest) { const { nextUrl } = req; - + // Get the token using next-auth/jwt which works with Edge Runtime const token = await getToken({ req, secret: process.env.NEXTAUTH_SECRET }); const isLoggedIn = !!token; From 5c5bf8f4bd80d19cd96757e8bfb7dab6c867698f Mon Sep 17 00:00:00 2001 From: VAIBHAVSING Date: Wed, 27 Aug 2025 17:38:40 +0530 Subject: [PATCH 3/4] feat: refractor ci --- .github/workflows/ci.yml | 259 +++-------------------------- .github/workflows/dependencies.yml | 50 ++---- CONTRIBUTING.md | 18 +- README.md | 23 +-- apps/agent/bin/agent | Bin 8488653 -> 8488653 bytes 5 files changed, 63 insertions(+), 287 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0222686..1326ade 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,63 +5,15 @@ on: branches: [main, develop] pull_request: branches: [main, develop] - schedule: - # Run security scans daily at 3 AM UTC - - cron: '0 3 * * *' concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: - # Job for detecting changes to optimize CI runs - changes: + # Test TypeScript projects + typescript: runs-on: ubuntu-latest - outputs: - go: ${{ steps.changes.outputs.go }} - typescript: ${{ steps.changes.outputs.typescript }} - web: ${{ steps.changes.outputs.web }} - docs: ${{ steps.changes.outputs.docs }} - agent: ${{ steps.changes.outputs.agent }} - steps: - - uses: actions/checkout@v4 - - uses: dorny/paths-filter@v3 - id: changes - with: - filters: | - go: - - 'apps/agent/**' - - 'go.mod' - - 'go.sum' - typescript: - - 'apps/web/**' - - 'apps/docs/**' - - 'packages/**' - - 'package.json' - - 'pnpm-lock.yaml' - - 'turbo.json' - web: - - 'apps/web/**' - - 'packages/**' - - 'package.json' - - 'pnpm-lock.yaml' - docs: - - 'apps/docs/**' - - 'packages/**' - - 'package.json' - - 'pnpm-lock.yaml' - agent: - - 'apps/agent/**' - - # TypeScript/Node.js Complete Pipeline - typescript-pipeline: - needs: changes - if: ${{ needs.changes.outputs.typescript == 'true' }} - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write steps: - uses: actions/checkout@v4 @@ -75,70 +27,28 @@ jobs: with: version: 9.0.0 - - name: Get pnpm store directory - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - - name: Setup pnpm cache - uses: actions/cache@v4 - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - name: Install dependencies run: pnpm install --frozen-lockfile - - name: Lint TypeScript + - name: Lint run: pnpm lint - - name: Check TypeScript formatting - run: | - pnpm format - if [ -n "$(git status --porcelain)" ]; then - echo "Code is not properly formatted. Please run 'pnpm format' and commit the changes." - git diff - exit 1 - fi - - name: Type check run: pnpm check-types - - name: Run tests + - name: Test run: pnpm test - - name: Build applications + - name: Build run: pnpm build env: - # Provide dummy values for build-time environment variables DATABASE_URL: "postgresql://dummy:dummy@localhost:5432/dummy" AUTH_SECRET: "dummy-secret-for-build" NEXTAUTH_URL: "http://localhost:3000" - - - name: Run npm audit - run: pnpm audit --audit-level high - - - name: Initialize CodeQL (JavaScript) - uses: github/codeql-action/init@v3 - with: - languages: 'javascript' - - - name: Perform CodeQL Analysis (JavaScript) - uses: github/codeql-action/analyze@v3 - with: - category: "/language:javascript" - # Go Complete Pipeline - go-pipeline: - needs: changes - if: ${{ needs.changes.outputs.go == 'true' }} + # Test Go project + go: runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write defaults: run: working-directory: ./apps/agent @@ -150,96 +60,44 @@ jobs: with: go-version: '1.24' - - name: Cache Go modules - uses: actions/cache@v4 - with: - path: | - ~/.cache/go-build - ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - - name: Download dependencies - run: go mod download - - - name: Install Go tools + - name: Install tools run: | go install honnef.co/go/tools/cmd/staticcheck@latest go install golang.org/x/tools/cmd/goimports@latest - go install github.com/securecodewarrior/gosec/v2/cmd/gosec@latest - - name: Run go vet - run: go vet ./... - - - name: Run staticcheck - run: staticcheck ./... + - name: Lint + run: | + go vet ./... + staticcheck ./... - - name: Check Go formatting + - name: Format check run: | - gofmt -s -d . if [ -n "$(gofmt -s -l .)" ]; then - echo "Go code is not properly formatted. Please run 'go fmt ./...' and commit the changes." + echo "Go code is not properly formatted" + gofmt -s -d . exit 1 fi - - - name: Check goimports - run: | - goimports -d . if [ -n "$(goimports -l .)" ]; then - echo "Go imports are not properly formatted. Please run 'goimports -w .' and commit the changes." + echo "Go imports are not properly formatted" + goimports -d . exit 1 fi - - name: Run tests with coverage - run: go test -v -race -coverprofile=coverage.out ./... + - name: Test + run: go test -v -race ./... - - name: Build application - run: go build -v -o bin/agent . - - - name: Run gosec Security Scanner - run: gosec -fmt sarif -out gosec-results.sarif ./... - - - name: Upload gosec scan results to GitHub Security tab - uses: github/codeql-action/upload-sarif@v3 - if: always() - with: - sarif_file: apps/agent/gosec-results.sarif - - - name: Initialize CodeQL (Go) - uses: github/codeql-action/init@v3 - with: - languages: 'go' - - - name: Perform CodeQL Analysis (Go) - uses: github/codeql-action/analyze@v3 - with: - category: "/language:go" - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 - with: - file: ./apps/agent/coverage.out - flags: go - name: go-coverage - - - name: Upload build artifact - uses: actions/upload-artifact@v4 - with: - name: agent-binary - path: apps/agent/bin/agent + - name: Build + run: go build -o bin/agent . - # General Security Scanning - security-scan: + # Security scanning + security: runs-on: ubuntu-latest permissions: - actions: read - contents: read security-events: write steps: - uses: actions/checkout@v4 - - name: Run Trivy vulnerability scanner + - name: Run Trivy scanner uses: aquasecurity/trivy-action@master with: scan-type: 'fs' @@ -247,75 +105,8 @@ jobs: format: 'sarif' output: 'trivy-results.sarif' - - name: Upload Trivy scan results to GitHub Security tab + - name: Upload scan results uses: github/codeql-action/upload-sarif@v3 if: always() with: sarif_file: 'trivy-results.sarif' - - # Database migration test (for web app) - test-db-migrations: - needs: changes - if: ${{ needs.changes.outputs.web == 'true' }} - runs-on: ubuntu-latest - services: - postgres: - image: postgres:15 - env: - POSTGRES_PASSWORD: postgres - POSTGRES_DB: test_db - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - 5432:5432 - defaults: - run: - working-directory: ./apps/web - 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: Test database migrations - run: | - pnpm db:generate - pnpm db:deploy - env: - DATABASE_URL: "postgresql://postgres:postgres@localhost:5432/test_db" - - # Final status check - ci-success: - runs-on: ubuntu-latest - needs: [ - changes, - typescript-pipeline, - go-pipeline, - security-scan, - test-db-migrations - ] - if: always() - steps: - - name: Check CI success - run: | - if [[ "${{ needs.typescript-pipeline.result }}" == "failure" || \ - "${{ needs.go-pipeline.result }}" == "failure" || \ - "${{ needs.security-scan.result }}" == "failure" || \ - "${{ needs.test-db-migrations.result }}" == "failure" ]]; then - echo "One or more CI jobs failed" - exit 1 - fi - echo "All CI jobs completed successfully" diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml index fb0433a..4116d8f 100644 --- a/.github/workflows/dependencies.yml +++ b/.github/workflows/dependencies.yml @@ -1,21 +1,18 @@ -name: Dependency Updates +name: Dependencies on: schedule: - # Run weekly on Monday at 9 AM UTC - - cron: '0 9 * * 1' + - cron: '0 9 * * 1' # Weekly on Monday workflow_dispatch: jobs: - update-dependencies: + update: runs-on: ubuntu-latest permissions: contents: write pull-requests: write steps: - uses: actions/checkout@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - name: Setup Node.js uses: actions/setup-node@v4 @@ -32,40 +29,25 @@ jobs: with: go-version: '1.24' - - name: Update Node.js dependencies - run: pnpm update --latest - - - name: Update Go dependencies + - name: Update dependencies run: | - cd apps/agent - go get -u ./... - go mod tidy + pnpm update --latest + cd apps/agent && go get -u ./... && go mod tidy - - name: Run basic checks after updates + - name: Test updates run: | pnpm install pnpm lint - pnpm check-types - cd apps/agent && go vet ./... && go build . + pnpm build + env: + DATABASE_URL: "postgresql://dummy:dummy@localhost:5432/dummy" + AUTH_SECRET: "dummy-secret" + NEXTAUTH_URL: "http://localhost:3000" - - name: Create Pull Request + - name: Create PR uses: peter-evans/create-pull-request@v5 with: - token: ${{ secrets.GITHUB_TOKEN }} - commit-message: 'chore: update dependencies' - title: 'chore: automated dependency updates' - body: | - This PR contains automated dependency updates. - - ## Changes - - Updated Node.js dependencies to latest versions - - Updated Go modules to latest versions - - ## Testing - - โœ… Linting passed - - โœ… Type checking passed - - โœ… Basic build successful - - Please review the changes and run full tests before merging. - branch: automated-dependency-updates + title: 'chore: update dependencies' + body: 'Automated dependency updates' + branch: deps-update delete-branch: true diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9e4759a..1a2d16b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -77,11 +77,21 @@ This ensures your changes will pass our CI pipeline. ## ๐Ÿค– CI/CD Pipeline -Our GitHub Actions CI pipeline automatically runs on every pull request and push to main: +Our simple GitHub Actions CI pipeline runs on every pull request and push: -### Consolidated Pipeline Structure +### Three Simple Jobs -We use a single CI workflow with two main language-specific pipelines: +- **๐ŸŸฆ 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** @@ -125,7 +135,7 @@ make format make check-types make test make build -``` +```` ### Status Checks diff --git a/README.md b/README.md index 4bad7e6..c389643 100644 --- a/README.md +++ b/README.md @@ -121,13 +121,13 @@ pnpm dev ## ๐Ÿค– CI/CD Pipeline -This project uses a consolidated GitHub Actions CI pipeline organized by language: +Simple and efficient GitHub Actions pipeline: -### Single CI Workflow +### Three Jobs, One Workflow -Every pull request and push triggers a comprehensive pipeline with two main tracks: - -#### **๐ŸŸฆ TypeScript Pipeline** +- **๐ŸŸฆ TypeScript**: Lint โ†’ Type Check โ†’ Test โ†’ Build +- **๐ŸŸฉ Go**: Lint โ†’ Format Check โ†’ Test โ†’ Build +- **๏ฟฝ๏ธ Security**: Trivy vulnerability scanning - **๐Ÿงน Linting**: ESLint with strict rules - **๐ŸŽจ Code Formatting**: Prettier validation @@ -157,20 +157,13 @@ Every pull request and push triggers a comprehensive pipeline with two main trac ### Local Development -Simulate the CI pipeline locally: +Run the same checks locally: ```bash -# Install the development tools -make install - -# Run all CI checks locally -make ci - -# Individual checks +make ci # Run full pipeline make lint # Lint all code -make format # Format all code make test # Run all tests -make build # Build all applications +make build # Build everything ``` ## ๐Ÿ“ Project Structure diff --git a/apps/agent/bin/agent b/apps/agent/bin/agent index 1e04bc78c784fb720a5553ce7d4fad5cdcaeafb3..70db8b5dc420acf9117bd28dddd8d71fb9701924 100755 GIT binary patch delta 827 zcmb`?Ia3pH0EY1Z!7FM+@m9PAkGSlAkL=<_B!*~!kZ6#^BWAN%2nKUN!r_6}m>FlR zEK)em@Dc1XmevlnV`XWP8CqK(J3oNMuX$(Q;#qtD*1d+$1@B5RZ!A@7LJb6q2}LXE zBgMEX#iQZrP-Jp>Ay^94V#%x{Y+FiBMPqulTu5d{;v%gN3AL7#Ce(DbvRIl;2Z}Ql zf2y1^!!?)N<#KhS1H)qp*T=}X`09L5{ceBr>YX{-JLmiKMJnViU6o$9y!Dp14ejWF z8=csIjo5_E*a8o>VjH&O?{^2fuoJt`josLTz1WBSIDmsVgv02;5gf%a9LEWq#3`Ic zFZyr>XK@ba;ll+;=!Xme1u8V?@HbmtL$kY7QxiVFrYM@F*s^I@4SC-9)%Wj`6OPbi zVP$f6=0Zla41GmJ7A8nrcYSn;=0bIl-T*eh##UKK> zh9LxT9U%-Oj2pO#2u3i9F+?$rSaY=+_k8=01$7E=8wpI{4knRA3U_f2_wfK}JVXW- zvapeZgDFfSj~P5d0ke3FB1$Nuf;r5iiW(NMh$SrJ37+B^o?`_sn(Kj=KZAb&ZfZ{4 delta 827 zcmb`?NpBKy0ETgDsT(R*t97lr;zEZR82X>Ol|^YQP`XeAm&z=3n_6f~tF?;8L{6SO z5O4heCVJx=cp*)UCp~#IhNR!X#K)T-z{BtIChy_dc>Bh=fls!(GQKbq8VIK%fwW!f z7lmBW&RLQnrn0k{R3=}fq1kX|?4)uy`z zThIz8+OQSdupK+F6E5t+ZtTI|?_RWHANHdI2XGLbIE2GEf}=Qwh)AVYy40jLO~r`~i6)ok~xir;GmOwE_~>AEhgn!F@_dj4Gu zSv7Ro6k0&GELmtlwWpvcLTILG)cVSztIeWB8cJ^ZX16wJj4VZ zArBn}Ojsyj5>uGQ3}#_t4v#U9B1%}mB9>6bGFI>ePqB(;Si^I?Km{-Bo1s@fqJID( CU{g^5 From c9812ad6123cf88d3e706f37d40c5e34197ad0a4 Mon Sep 17 00:00:00 2001 From: VAIBHAVSING Date: Wed, 27 Aug 2025 17:44:28 +0530 Subject: [PATCH 4/4] feat: fix lint error typescript --- .github/workflows/ci.yml | 3 +++ .github/workflows/dependencies.yml | 1 + 2 files changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1326ade..baf191f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,6 +39,9 @@ jobs: - name: Test run: pnpm test + - name: Generate Prisma Client + run: pnpm --filter=web db:generate + - name: Build run: pnpm build env: diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml index 4116d8f..3ae494e 100644 --- a/.github/workflows/dependencies.yml +++ b/.github/workflows/dependencies.yml @@ -37,6 +37,7 @@ jobs: - name: Test updates run: | pnpm install + pnpm --filter=web db:generate pnpm lint pnpm build env: