From 9e92afb24b43747bf7aed3c403be015e97c99f87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=84=AD=E6=B2=9B=E8=BB=92?= Date: Fri, 5 Sep 2025 21:51:47 +0800 Subject: [PATCH] feat: add GitHub Actions CI/CD pipeline and PR templates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add comprehensive CI/CD workflow for Flutter and .NET Core - Include security scanning with Trivy - Add automated testing for both frontend and backend - Setup staging and production deployment pipelines - Create detailed PR template with checklists - Add bug report and feature request issue templates ๐Ÿค– Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .github/ISSUE_TEMPLATE/bug_report.md | 58 +++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 66 +++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 88 ++++++++++++++ .github/workflows/ci.yml | 137 ++++++++++++++++++++++ 4 files changed, 349 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/ci.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..31938c0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,58 @@ +--- +name: ๐Ÿ› Bug Report +about: Create a report to help us improve +title: '[BUG] ' +labels: ['bug', 'needs-triage'] +assignees: '' +--- + +## ๐Ÿ› Bug Description + + +## ๐Ÿ”„ Steps to Reproduce +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +## โœ… Expected Behavior + + +## โŒ Actual Behavior + + +## ๐Ÿ“ฑ Environment +### Mobile App (Flutter) +- **Platform**: iOS / Android +- **Device**: [e.g. iPhone 12, Samsung Galaxy S21] +- **OS Version**: [e.g. iOS 15.0, Android 12] +- **App Version**: [e.g. 1.2.0] + +### Backend (.NET Core) +- **Environment**: Development / Staging / Production +- **Server OS**: [if known] +- **Database**: [PostgreSQL version] + +## ๐Ÿ“ธ Screenshots + + +## ๐Ÿ“‹ Additional Context + + +## ๐Ÿ” Error Logs + + +``` +Paste error logs here +``` + +## ๐ŸŽฏ Priority + +- [ ] ๐Ÿ”ด Critical (System down, data loss) +- [ ] ๐ŸŸ  High (Major feature broken) +- [ ] ๐ŸŸก Medium (Minor feature issue) +- [ ] ๐ŸŸข Low (Cosmetic issue) + +## ๐Ÿท๏ธ Labels + + \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..044330e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,66 @@ +--- +name: โœจ Feature Request +about: Suggest an idea for this project +title: '[FEATURE] ' +labels: ['enhancement', 'needs-triage'] +assignees: '' +--- + +## ๐Ÿ’ก Feature Description + + +## ๐ŸŽฏ Problem Statement + +**Is your feature request related to a problem?** +A clear description of what the problem is. Ex. I'm always frustrated when [...] + +## ๐Ÿ›  Proposed Solution + + +## ๐Ÿ”„ User Stories + +- As a [user type], I want [goal] so that [benefit] +- As a [user type], I want [goal] so that [benefit] + +## ๐Ÿ“ฑ Platform + +- [ ] ๐Ÿ“ฑ Mobile App (Flutter) +- [ ] ๐Ÿ”ง Backend API (.NET Core) +- [ ] ๐Ÿ—„๏ธ Database Schema +- [ ] ๐ŸŽฎ Gamification System +- [ ] ๐Ÿค– AI Analysis Engine +- [ ] ๐Ÿ“Š Analytics/Reporting +- [ ] ๐Ÿ” Authentication/Security + +## ๐ŸŽจ UI/UX Considerations + + +## ๐Ÿ”ง Technical Considerations + + +## ๐Ÿ“ˆ Success Metrics + + +## ๐Ÿšง Alternative Solutions + + +## ๐Ÿ“‹ Additional Context + + +## ๐ŸŽฏ Priority + +- [ ] ๐Ÿ”ด Critical (Essential for launch) +- [ ] ๐ŸŸ  High (Important for user experience) +- [ ] ๐ŸŸก Medium (Nice to have) +- [ ] ๐ŸŸข Low (Future consideration) + +## ๐Ÿ“… Timeline + +- [ ] Next release +- [ ] Within 3 months +- [ ] Within 6 months +- [ ] Future roadmap + +## ๐Ÿท๏ธ Labels + + \ No newline at end of file diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..c54d72b --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,88 @@ +# Pull Request + +## ๐Ÿ“‹ Summary + + +## ๐ŸŽฏ Type of Change + +- [ ] ๐Ÿ› Bug fix (non-breaking change which fixes an issue) +- [ ] โœจ New feature (non-breaking change which adds functionality) +- [ ] ๐Ÿ’ฅ Breaking change (fix or feature that would cause existing functionality to not work as expected) +- [ ] ๐Ÿ“š Documentation update +- [ ] ๐Ÿ—๏ธ Infrastructure/build changes +- [ ] ๐Ÿงน Code cleanup/refactoring +- [ ] ๐Ÿงช Tests only + +## ๐Ÿ”— Related Issues + + +## ๐Ÿ›  Changes Made + + +### Frontend (Flutter) +- [ ] UI components updated +- [ ] State management changes +- [ ] Navigation changes +- [ ] New screens/widgets added + +### Backend (.NET Core) +- [ ] API endpoints added/modified +- [ ] Database schema changes +- [ ] Business logic updates +- [ ] Authentication/authorization changes + +## ๐Ÿงช Testing + + +### Flutter Testing +- [ ] Unit tests added/updated +- [ ] Widget tests added/updated +- [ ] Integration tests added/updated +- [ ] Manual testing completed on iOS +- [ ] Manual testing completed on Android + +### .NET Testing +- [ ] Unit tests added/updated +- [ ] Integration tests added/updated +- [ ] API testing completed +- [ ] Database migration tested + +## ๐Ÿ“ฑ Screenshots/Videos + + +## ๐Ÿ“ Additional Notes + + +## โœ… Checklist + + +### Code Quality +- [ ] Code follows the established coding standards +- [ ] Self-review of the code completed +- [ ] Code is properly commented (especially complex logic) +- [ ] No debugging code or console logs left in +- [ ] Error handling is appropriate + +### Documentation +- [ ] Documentation updated (if needed) +- [ ] API documentation updated (if applicable) +- [ ] README updated (if needed) + +### Security & Performance +- [ ] No sensitive data exposed in code +- [ ] Performance impact considered +- [ ] Security implications reviewed +- [ ] Accessibility guidelines followed (for UI changes) + +### Testing & Deployment +- [ ] All tests pass locally +- [ ] CI/CD pipeline passes +- [ ] Database migrations work (if applicable) +- [ ] Feature works in staging environment + +## ๐Ÿ‘ฅ Reviewers + +@team-leads @senior-developers + +--- +**Note**: Please ensure all checkboxes are marked before requesting review. \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..3e87c91 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,137 @@ +name: CI/CD Pipeline + +on: + push: + branches: [ main, develop ] + pull_request: + branches: [ main, develop ] + +jobs: + # Flutter Mobile App CI + flutter-test: + name: Flutter Tests + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./mobile + + steps: + - uses: actions/checkout@v4 + + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: '3.16.0' + channel: 'stable' + + - name: Get dependencies + run: flutter pub get + + - name: Analyze code + run: flutter analyze + + - name: Run tests + run: flutter test + + - name: Generate coverage + run: flutter test --coverage + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + file: ./mobile/coverage/lcov.info + + # .NET Backend API CI + dotnet-test: + name: .NET Tests + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./backend + + steps: + - uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '8.0.x' + + - name: Restore dependencies + run: dotnet restore + + - name: Build + run: dotnet build --no-restore --configuration Release + + - name: Test + run: dotnet test --no-build --configuration Release --verbosity normal --collect:"XPlat Code Coverage" + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + file: ./backend/TestResults/*/coverage.cobertura.xml + + # Security and Quality Checks + security-scan: + name: Security Scan + runs-on: ubuntu-latest + 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@v2 + with: + sarif_file: 'trivy-results.sarif' + + # Build and Deploy to Staging (develop branch only) + deploy-staging: + name: Deploy to Staging + needs: [flutter-test, dotnet-test] + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/develop' && github.event_name == 'push' + + steps: + - uses: actions/checkout@v4 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-west-2 + + - name: Deploy to staging + run: | + echo "Deploying to staging environment" + # Add actual deployment commands here + + # Build and Deploy to Production (main branch only) + deploy-production: + name: Deploy to Production + needs: [flutter-test, dotnet-test, security-scan] + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' && github.event_name == 'push' + environment: production + + steps: + - uses: actions/checkout@v4 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-west-2 + + - name: Deploy to production + run: | + echo "Deploying to production environment" + # Add actual deployment commands here \ No newline at end of file