Merge pull request #3 from hakutakuAi/development #15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: [main, development] | |
| paths: | |
| - 'src/**' | |
| - 'tests/**' | |
| - 'examples/**' | |
| - 'package.json' | |
| - 'bun.lock' | |
| - 'tsconfig.json' | |
| - '*.ts' | |
| - '.github/**' | |
| pull_request: | |
| branches: [main, development] | |
| paths: | |
| - 'src/**' | |
| - 'tests/**' | |
| - 'examples/**' | |
| - 'package.json' | |
| - 'bun.lock' | |
| - 'tsconfig.json' | |
| - '*.ts' | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| BUN_VERSION: '1.2.21' | |
| jobs: | |
| setup: | |
| name: π§ Setup & Dependencies | |
| runs-on: ubuntu-latest | |
| outputs: | |
| cache-key: ${{ steps.cache-key.outputs.key }} | |
| steps: | |
| - name: π₯ Checkout code | |
| uses: actions/checkout@v4 | |
| - name: π° Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: ${{ env.BUN_VERSION }} | |
| - name: π Generate cache key | |
| id: cache-key | |
| run: echo "key=bun-${{ hashFiles('**/bun.lock', '**/package.json') }}" >> $GITHUB_OUTPUT | |
| - name: πΎ Cache dependencies | |
| uses: actions/cache@v4 | |
| id: cache-deps | |
| with: | |
| path: | | |
| ~/.bun/install/cache | |
| node_modules | |
| examples/*/node_modules | |
| key: ${{ steps.cache-key.outputs.key }} | |
| restore-keys: | | |
| bun- | |
| - name: π¦ Install dependencies | |
| if: steps.cache-deps.outputs.cache-hit != 'true' | |
| run: bun install --frozen-lockfile | |
| - name: π¦ Install example dependencies | |
| if: steps.cache-deps.outputs.cache-hit != 'true' | |
| run: | | |
| cd examples/graphql-server && bun install --frozen-lockfile | |
| cd ../type-graphql && bun install --frozen-lockfile | |
| cd ../advanced-graphql && bun install --frozen-lockfile | |
| typecheck: | |
| name: π Type Check & Lint | |
| runs-on: ubuntu-latest | |
| needs: setup | |
| steps: | |
| - name: π₯ Checkout code | |
| uses: actions/checkout@v4 | |
| - name: π° Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: ${{ env.BUN_VERSION }} | |
| - name: πΎ Restore dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.bun/install/cache | |
| node_modules | |
| examples/*/node_modules | |
| key: ${{ needs.setup.outputs.cache-key }} | |
| - name: π Type check | |
| run: bunx tsc --noEmit | |
| - name: π§Ή Lint check | |
| run: | | |
| if [ -f "eslint.config.js" ] || [ -f ".eslintrc.json" ] || [ -f ".eslintrc.js" ]; then | |
| bunx eslint src/ tests/ --ext .ts --max-warnings 0 | |
| else | |
| echo "No ESLint configuration found, skipping lint check" | |
| fi | |
| unit-tests: | |
| name: π§ͺ Unit & Integration Tests | |
| runs-on: ubuntu-latest | |
| needs: setup | |
| steps: | |
| - name: π₯ Checkout code | |
| uses: actions/checkout@v4 | |
| - name: π° Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: ${{ env.BUN_VERSION }} | |
| - name: πΎ Restore dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.bun/install/cache | |
| node_modules | |
| examples/*/node_modules | |
| key: ${{ needs.setup.outputs.cache-key }} | |
| - name: π§ͺ Run unit tests with coverage | |
| run: bun run test:coverage | |
| - name: π Generate coverage summary | |
| run: | | |
| echo "## π§ͺ Test Coverage Report" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| bun run test:coverage | grep -A 20 "File.*% Funcs.*% Lines" || echo "Coverage report format changed" | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| - name: π Upload coverage (if available) | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| fail_ci_if_error: false | |
| continue-on-error: true | |
| - name: πΎ Archive test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: unit-test-results | |
| path: | | |
| coverage/ | |
| test-results.xml | |
| .coverage | |
| retention-days: 7 | |
| continue-on-error: true | |
| e2e-tests: | |
| name: π End-to-End Tests | |
| runs-on: ubuntu-latest | |
| needs: [setup, typecheck] | |
| timeout-minutes: 15 | |
| steps: | |
| - name: π₯ Checkout code | |
| uses: actions/checkout@v4 | |
| - name: π° Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: ${{ env.BUN_VERSION }} | |
| - name: πΎ Restore dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.bun/install/cache | |
| node_modules | |
| examples/*/node_modules | |
| key: ${{ needs.setup.outputs.cache-key }} | |
| - name: ποΈ Build project | |
| run: bun run build | |
| - name: π Cache build artifacts | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| dist/ | |
| examples/*/dist/ | |
| examples/*/prisma/ | |
| key: build-${{ github.sha }} | |
| - name: β‘ Generate examples | |
| run: bun run generate:all | |
| - name: π§ͺ Run E2E tests | |
| run: bun run test:examples | |
| - name: πΎ Archive E2E results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: e2e-test-results | |
| path: | | |
| examples/*/tests/ | |
| examples/*/*.test.ts | |
| examples/*/schema.graphql | |
| retention-days: 7 | |
| performance-tests: | |
| name: β‘ Performance Tests | |
| runs-on: ubuntu-latest | |
| needs: [setup, unit-tests] | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| steps: | |
| - name: π₯ Checkout code | |
| uses: actions/checkout@v4 | |
| - name: π° Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: ${{ env.BUN_VERSION }} | |
| - name: πΎ Restore dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.bun/install/cache | |
| node_modules | |
| examples/*/node_modules | |
| key: ${{ needs.setup.outputs.cache-key }} | |
| - name: β‘ Run performance tests | |
| run: bun test tests/performance/ | |
| security-scan: | |
| name: π Security Scan | |
| runs-on: ubuntu-latest | |
| needs: setup | |
| steps: | |
| - name: π₯ Checkout code | |
| uses: actions/checkout@v4 | |
| - name: π Run security audit | |
| run: | | |
| bun audit --audit-level moderate || true | |
| build-validation: | |
| name: π¦ Build Validation | |
| runs-on: ubuntu-latest | |
| needs: [setup, typecheck] | |
| steps: | |
| - name: π₯ Checkout code | |
| uses: actions/checkout@v4 | |
| - name: π° Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: ${{ env.BUN_VERSION }} | |
| - name: πΎ Restore dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.bun/install/cache | |
| node_modules | |
| examples/*/node_modules | |
| key: ${{ needs.setup.outputs.cache-key }} | |
| - name: ποΈ Test build process | |
| run: | | |
| bun run build | |
| - name: β Verify build output | |
| run: | | |
| [ -d "dist" ] || (echo "dist directory not found!" && exit 1) | |
| [ -f "dist/index.js" ] || (echo "Main entry file not found!" && exit 1) | |
| [ -f "dist/package.json" ] || (echo "Package.json not found in dist!" && exit 1) | |
| echo "β Build validation successful" | |
| - name: πΎ Archive build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-artifacts | |
| path: dist/ | |
| retention-days: 7 | |
| test-summary: | |
| name: π Test Summary | |
| runs-on: ubuntu-latest | |
| needs: [typecheck, unit-tests, e2e-tests, build-validation] | |
| if: always() | |
| steps: | |
| - name: π Generate summary | |
| run: | | |
| echo "## π§ͺ Test Results Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "| Job | Status |" >> $GITHUB_STEP_SUMMARY | |
| echo "|-----|--------|" >> $GITHUB_STEP_SUMMARY | |
| echo "| Type Check & Lint | ${{ needs.typecheck.result == 'success' && 'β ' || 'β' }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| Unit Tests | ${{ needs.unit-tests.result == 'success' && 'β ' || 'β' }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| E2E Tests | ${{ needs.e2e-tests.result == 'success' && 'β ' || 'β' }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| Build Validation | ${{ needs.build-validation.result == 'success' && 'β ' || 'β' }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### π Coverage & Artifacts" >> $GITHUB_STEP_SUMMARY | |
| echo "- Coverage reports available in artifacts" >> $GITHUB_STEP_SUMMARY | |
| echo "- Test results archived for 7 days" >> $GITHUB_STEP_SUMMARY | |
| - name: β Fail if critical jobs failed | |
| if: | | |
| needs.typecheck.result == 'failure' || | |
| needs.unit-tests.result == 'failure' || | |
| needs.e2e-tests.result == 'failure' || | |
| needs.build-validation.result == 'failure' | |
| run: | | |
| echo "β Critical jobs failed. Please check the logs above." | |
| exit 1 |