feat(web): add upload code file from local feature #98
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 | ||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - ".config/**" | ||
| - "!.github/workflows/cd.yml" | ||
| - "bun.lockb" | ||
| - "package.json" | ||
| - "package/**" | ||
| - "api/**" | ||
| - "web/**" | ||
| - "cli/**" | ||
| - "src-tauri/**" | ||
| pull_request: | ||
| branches: [main] | ||
| paths: | ||
| - ".config/**" | ||
| - "!.github/workflows/cd.yml" | ||
| - "bun.lockb" | ||
| - "package.json" | ||
| - "package/**" | ||
| - "api/**" | ||
| - "web/**" | ||
| - "cli/**" | ||
| - "src-tauri/**" | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
| jobs: | ||
| test-package: | ||
| name: 📦 Test Package | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| package-changed: ${{ steps.changes.outputs.package }} | ||
| api-changed: ${{ steps.changes.outputs.api }} | ||
| web-changed: ${{ steps.changes.outputs.web }} | ||
| cli-changed: ${{ steps.changes.outputs.cli }} | ||
| tauri-changed: ${{ steps.changes.outputs.tauri }} | ||
| steps: | ||
| - name: 📥 Checkout | ||
| uses: actions/checkout@v4 | ||
| - name: 🔍 Detect changes | ||
| uses: dorny/paths-filter@v3 | ||
| id: changes | ||
| with: | ||
| filters: | | ||
| package: | ||
| - 'package/**' | ||
| api: | ||
| - 'api/**' | ||
| web: | ||
| - 'web/**' | ||
| cli: | ||
| - 'cli/**' | ||
| tauri: | ||
| - 'src-tauri/**' | ||
| - name: ⚡ Setup Bun | ||
| uses: oven-sh/setup-bun@v1 | ||
| with: | ||
| bun-version: latest | ||
| - name: 💾 Cache Bun dependencies | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| .bun | ||
| node_modules | ||
| key: ${{ runner.os }}-bun-${{ hashFiles('bun.lockb') }} | ||
| - name: 📦 Install dependencies | ||
| working-directory: package | ||
| run: bun install | ||
| - name: 🧹 Lint and Format | ||
| run: bun check | ||
| - name: 🧪 Run package tests | ||
| working-directory: package | ||
| run: bun test | ||
| - name: 📊 Generate test coverage | ||
| working-directory: package | ||
| run: bun test --coverage | ||
| - name: 📤 Upload coverage to Codecov | ||
| uses: codecov/codecov-action@v4 | ||
| if: always() | ||
| with: | ||
| file: ./package/coverage/lcov.info | ||
| flags: package | ||
| name: package-coverage | ||
| fail_ci_if_error: false | ||
| - name: 🏗️ Build package | ||
| working-directory: package | ||
| run: bun run build | ||
| test-api: | ||
| name: 🚀 Test API | ||
| runs-on: ubuntu-latest | ||
| needs: test-package | ||
| if: needs.test-package.outputs.api-changed == 'true' || needs.test-package.outputs.package-changed == 'true' || contains(github.event.head_commit.message, '[test-api]') | ||
| steps: | ||
| - name: 📥 Checkout | ||
| uses: actions/checkout@v4 | ||
| - name: ⚡ Setup Bun | ||
| uses: oven-sh/setup-bun@v1 | ||
| with: | ||
| bun-version: latest | ||
| - name: 💾 Cache dependencies | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| .bun | ||
| node_modules | ||
| key: ${{ runner.os }}-bun-${{ hashFiles('bun.lockb') }} | ||
| - name: 📦 Install package dependencies | ||
| working-directory: package | ||
| run: bun install | ||
| - name: 🏗️ Build package | ||
| working-directory: package | ||
| run: bun run build | ||
| - name: 📦 Install API dependencies | ||
| working-directory: api | ||
| run: bun install | ||
| - name: 🔧 Lint API | ||
| working-directory: api | ||
| run: bun run lint | ||
| continue-on-error: true | ||
| - name: 🏗️ Build API | ||
| working-directory: api | ||
| run: bun run build | ||
| - name: 🧪 Test API endpoints | ||
| working-directory: api | ||
| run: | | ||
| # Start API in background | ||
| bun run start & | ||
| API_PID=$! | ||
| # Wait for API to start | ||
| sleep 5 | ||
| # Test health endpoint | ||
| curl -f http://localhost:8080/health || exit 1 | ||
| # Kill API process | ||
| kill $API_PID | ||
| continue-on-error: true | ||
| test-web: | ||
| name: 🌐 Test Web | ||
| runs-on: ubuntu-latest | ||
| needs: test-package | ||
| if: needs.test-package.outputs.web-changed == 'true' || needs.test-package.outputs.package-changed == 'true' || contains(github.event.head_commit.message, '[test-web]') || github.event_name == 'pull_request' | ||
| steps: | ||
| - name: 📥 Checkout | ||
| uses: actions/checkout@v4 | ||
| - name: ⚡ Setup Bun | ||
| uses: oven-sh/setup-bun@v1 | ||
| with: | ||
| bun-version: latest | ||
| - name: 💾 Cache dependencies | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| .bun | ||
| node_modules | ||
| web/.next | ||
| key: ${{ runner.os }}-web-${{ hashFiles('bun.lockb') }} | ||
| - name: 📦 Install package dependencies | ||
| working-directory: package | ||
| run: bun install | ||
| - name: 🏗️ Build package | ||
| working-directory: package | ||
| run: bun run build | ||
| - name: 📦 Install web dependencies | ||
| working-directory: web | ||
| run: bun install | ||
| - name: 🔧 Lint web | ||
| working-directory: web | ||
| run: bun run lint | ||
| continue-on-error: true | ||
| - name: 🏗️ Build web | ||
| working-directory: web | ||
| run: bun run build | ||
| test-cli: | ||
| name: 🖥️ Test CLI | ||
| runs-on: ubuntu-latest | ||
| needs: test-package | ||
| if: needs.test-package.outputs.cli-changed == 'true' || needs.test-package.outputs.package-changed == 'true' || contains(github.event.head_commit.message, '[test-cli]') || github.event_name == 'pull_request' | ||
| steps: | ||
| - name: 📥 Checkout | ||
| uses: actions/checkout@v4 | ||
| - name: ⚡ Setup Bun | ||
| uses: oven-sh/setup-bun@v1 | ||
| with: | ||
| bun-version: latest | ||
| - name: 💾 Cache dependencies | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| .bun | ||
| node_modules | ||
| key: ${{ runner.os }}-cli-${{ hashFiles('bun.lockb') }} | ||
| - name: 📦 Install package dependencies | ||
| working-directory: package | ||
| run: bun install | ||
| - name: 🏗️ Build package | ||
| working-directory: package | ||
| run: bun run build | ||
| - name: 📦 Install CLI dependencies | ||
| working-directory: cli | ||
| run: bun install | ||
| # - name: 🏗️ Build CLI | ||
| # working-directory: cli | ||
| # run: bun run build | ||
| - name: 🧪 Test CLI commands | ||
| working-directory: cli | ||
| run: | | ||
| bun link flashot | ||
| flashot --help || exit 1 | ||
| flashot --version || exit 1 | ||
| continue-on-error: true | ||
| build-app: | ||
| name: 🖥️ Build App | ||
| runs-on: ${{ matrix.os }} | ||
| needs: test-package | ||
| if: needs.test-package.outputs.tauri-changed == 'true' || needs.test-package.outputs.package-changed == 'true' || needs.test-package.outputs.web-changed == 'true' || contains(github.event.head_commit.message, '[build-tauri]') || github.event_name == 'pull_request' | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - os: windows-latest | ||
| target: x86_64-pc-windows-msvc | ||
| - os: ubuntu-latest | ||
| target: x86_64-unknown-linux-gnu | ||
| - os: macos-latest | ||
| target: x86_64-apple-darwin | ||
| steps: | ||
| - name: 📥 Checkout | ||
| uses: actions/checkout@v4 | ||
| - name: ⚡ Setup Bun | ||
| uses: oven-sh/setup-bun@v1 | ||
| with: | ||
| bun-version: latest | ||
| - name: 🦀 Setup Rust | ||
| uses: dtolnay/rust-toolchain@stable | ||
| with: | ||
| targets: ${{ matrix.target }} | ||
| - name: 📦 Cache Rust dependencies | ||
| uses: Swatinem/rust-cache@v2 | ||
| with: | ||
| workspaces: "./src-tauri -> target" | ||
| - name: 📦 Install package dependencies | ||
| working-directory: package | ||
| run: bun install | ||
| - name: 🏗️ Build package | ||
| working-directory: package | ||
| run: bun run build | ||
| - name: 📦 Install web dependencies | ||
| working-directory: web | ||
| run: bun install | ||
| - name: 🏗️ Build web | ||
| working-directory: web | ||
| run: bun run build | ||
| - name: 🏗️ Build Tauri app | ||
| uses: tauri-apps/tauri-action@v0 | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| with: | ||
| projectPath: src-tauri | ||
| tauriScript: tauri | ||
| security-scan: | ||
| name: 🔒 Security Scan | ||
| runs-on: ubuntu-latest | ||
| if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main' | ||
| permissions: | ||
| actions: read | ||
| contents: read | ||
| security-events: write | ||
| steps: | ||
| - name: 📥 Checkout | ||
| uses: actions/checkout@v4 | ||
| - name: ⚡ Setup Bun | ||
| uses: oven-sh/setup-bun@v1 | ||
| with: | ||
| bun-version: latest | ||
| - name: 📦 Install workspace dependencies | ||
| working-directory: package | ||
| run: bun install | ||
| - name: 🔍 Run dependency audit | ||
| run: | | ||
| bun audit || true | ||
| - name: 🛡️ Run CodeQL Analysis | ||
| uses: github/codeql-action/init@v3 | ||
| with: | ||
| languages: javascript | ||
| - name: 🔍 Perform CodeQL Analysis | ||
| uses: github/codeql-action/analyze@v3 | ||
| with: | ||
| category: "/language:javascript" | ||
| summary: | ||
| name: 📋 CI Summary | ||
| runs-on: ubuntu-latest | ||
| needs: | ||
| [test-package, test-api, test-web, test-cli, build-tauri, security-scan] | ||
| if: always() | ||
| steps: | ||
| - name: 📊 Check CI Results | ||
| run: | | ||
| echo "## 📋 CI Summary" >> $GITHUB_STEP_SUMMARY | ||
| echo "| Component | Status |" >> $GITHUB_STEP_SUMMARY | ||
| echo "|-----------|--------|" >> $GITHUB_STEP_SUMMARY | ||
| echo "| 📦 Package | ${{ needs.test-package.result == 'success' && '✅ Passed' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY | ||
| echo "| 🚀 API | ${{ needs.test-api.result == 'success' && '✅ Passed' || needs.test-api.result == 'skipped' && '⏭️ Skipped' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY | ||
| echo "| 🌐 Web | ${{ needs.test-web.result == 'success' && '✅ Passed' || needs.test-web.result == 'skipped' && '⏭️ Skipped' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY | ||
| echo "| 🖥️ CLI | ${{ needs.test-cli.result == 'success' && '✅ Passed' || needs.test-cli.result == 'skipped' && '⏭️ Skipped' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY | ||
| echo "| 🖥️ Tauri App | ${{ needs.build-tauri.result == 'success' && '✅ Passed' || needs.build-tauri.result == 'skipped' && '⏭️ Skipped' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY | ||
| echo "| 🔒 Security | ${{ needs.security-scan.result == 'success' && '✅ Passed' || needs.security-scan.result == 'skipped' && '⏭️ Skipped' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY | ||
| # Check if any required job failed | ||
| if [[ "${{ needs.test-package.result }}" == "failure" ]]; then | ||
| echo "❌ CI failed due to package test failures" | ||
| exit 1 | ||
| fi | ||
| echo "✅ CI completed successfully!" | ||