๐ fix: ไฟฎๅค GitHub Actions ๅทฅไฝๆต YAML ่ฏญๆณ้่ฏฏ #3
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: ๐งช Tests | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main, develop] | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| # ============================================================================ | |
| # ไปฃ็ ่ดจ้ๆฃๆฅ | |
| # ============================================================================ | |
| lint: | |
| name: ๐ Code Quality | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: ๐ฅ Checkout code | |
| uses: actions/checkout@v4 | |
| - name: ๐ฆ Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: ๐ฅ Install dependencies | |
| run: npm ci | |
| - name: ๐ Run linter | |
| run: npm run lint | |
| - name: ๐ Type check | |
| run: npm run type-check | |
| # ============================================================================ | |
| # ๅๅ ๆต่ฏ | |
| # ============================================================================ | |
| unit-tests: | |
| name: ๐งช Unit Tests | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| needs: lint | |
| strategy: | |
| matrix: | |
| node-version: [18, 20] | |
| steps: | |
| - name: ๐ฅ Checkout code | |
| uses: actions/checkout@v4 | |
| - name: ๐ฆ Setup Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: 'npm' | |
| - name: ๐ฅ Install dependencies | |
| run: | | |
| npm ci | |
| npm install --save-dev vitest jsdom @vitest/ui c8 | |
| - name: ๐งช Run unit tests | |
| run: npx vitest run tests/utils/config-helpers.test.ts --reporter=verbose | |
| - name: ๐ Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: unit-test-results-node-${{ matrix.node-version }} | |
| path: | | |
| coverage/ | |
| test-results.xml | |
| retention-days: 7 | |
| # ============================================================================ | |
| # ้ๆๆต่ฏ | |
| # ============================================================================ | |
| integration-tests: | |
| name: ๐ Integration Tests | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| needs: lint | |
| steps: | |
| - name: ๐ฅ Checkout code | |
| uses: actions/checkout@v4 | |
| - name: ๐ฆ Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: ๐ฅ Install dependencies | |
| run: | | |
| npm ci | |
| npm install --save-dev vitest jsdom @vitest/ui c8 | |
| - name: ๐ Run integration tests | |
| run: npx vitest run tests/utils/config-helpers.integration.test.ts --reporter=verbose | |
| - name: ๐ Upload integration test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: integration-test-results | |
| path: | | |
| coverage/ | |
| test-results.xml | |
| retention-days: 7 | |
| # ============================================================================ | |
| # ๆง่ฝๆต่ฏ | |
| # ============================================================================ | |
| performance-tests: | |
| name: โก Performance Tests | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 25 | |
| needs: [unit-tests, integration-tests] | |
| steps: | |
| - name: ๐ฅ Checkout code | |
| uses: actions/checkout@v4 | |
| - name: ๐ฆ Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: ๐ฅ Install dependencies | |
| run: | | |
| npm ci | |
| npm install --save-dev vitest jsdom @vitest/ui c8 | |
| - name: โก Run performance tests | |
| run: npx vitest run tests/utils/config-helpers.performance.test.ts --reporter=verbose | |
| - name: ๐ Upload performance test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: performance-test-results | |
| path: | | |
| coverage/ | |
| performance-report.json | |
| retention-days: 7 | |
| # ============================================================================ | |
| # ไปฃ็ ่ฆ็็ | |
| # ============================================================================ | |
| coverage: | |
| name: ๐ Code Coverage | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| needs: lint | |
| steps: | |
| - name: ๐ฅ Checkout code | |
| uses: actions/checkout@v4 | |
| - name: ๐ฆ Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: ๐ฅ Install dependencies | |
| run: | | |
| npm ci | |
| npm install --save-dev vitest jsdom @vitest/ui c8 | |
| - name: ๐ Run tests with coverage | |
| run: npx vitest run tests/utils/config-helpers*.test.ts --coverage --reporter=verbose | |
| - name: ๐ค Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: ./coverage/lcov.info | |
| flags: config-helpers | |
| name: config-helpers-coverage | |
| fail_ci_if_error: false | |
| - name: ๐ Coverage Summary | |
| run: | | |
| echo "## ๐ Coverage Report" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| if [ -f coverage/coverage-summary.json ]; then | |
| node -e " | |
| const fs = require('fs'); | |
| const coverage = JSON.parse(fs.readFileSync('coverage/coverage-summary.json', 'utf8')); | |
| const total = coverage.total; | |
| console.log('| Metric | Percentage | Covered/Total |'); | |
| console.log('|--------|------------|---------------|'); | |
| console.log('| Lines | ' + total.lines.pct + '% | ' + total.lines.covered + '/' + total.lines.total + ' |'); | |
| console.log('| Functions | ' + total.functions.pct + '% | ' + total.functions.covered + '/' + total.functions.total + ' |'); | |
| console.log('| Branches | ' + total.branches.pct + '% | ' + total.branches.covered + '/' + total.branches.total + ' |'); | |
| console.log('| Statements | ' + total.statements.pct + '% | ' + total.statements.covered + '/' + total.statements.total + ' |'); | |
| " >> $GITHUB_STEP_SUMMARY | |
| fi | |
| - name: ๐ Upload coverage artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: coverage/ | |
| retention-days: 30 | |
| # ============================================================================ | |
| # ๆต่งๅจๅ ผๅฎนๆงๆต่ฏ | |
| # ============================================================================ | |
| browser-tests: | |
| name: ๐ Browser Compatibility | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| needs: [unit-tests, integration-tests] | |
| strategy: | |
| matrix: | |
| browser: [chromium, firefox, webkit] | |
| steps: | |
| - name: ๐ฅ Checkout code | |
| uses: actions/checkout@v4 | |
| - name: ๐ฆ Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: ๐ฅ Install dependencies | |
| run: | | |
| npm ci | |
| npm install --save-dev vitest jsdom @vitest/ui c8 playwright | |
| - name: ๐ญ Install Playwright browsers | |
| run: npx playwright install ${{ matrix.browser }} | |
| - name: ๐ Run browser tests | |
| run: | | |
| # ไฝฟ็จ Playwright ่ฟ่กๆต่งๅจ็ฏๅขๆต่ฏ | |
| npx vitest run tests/utils/config-helpers.test.ts --environment=happy-dom --reporter=verbose | |
| env: | |
| BROWSER: ${{ matrix.browser }} | |
| - name: ๐ Upload browser test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: browser-test-results-${{ matrix.browser }} | |
| path: | | |
| test-results/ | |
| screenshots/ | |
| retention-days: 7 | |
| # ============================================================================ | |
| # ๅฎๅ จๆซๆ | |
| # ============================================================================ | |
| security: | |
| name: ๐ Security Scan | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| needs: lint | |
| steps: | |
| - name: ๐ฅ Checkout code | |
| uses: actions/checkout@v4 | |
| - name: ๐ฆ Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: ๐ฅ Install dependencies | |
| run: npm ci | |
| - name: ๐ Run security audit | |
| run: npm audit --audit-level=moderate | |
| - name: ๐ Run CodeQL Analysis | |
| uses: github/codeql-action/init@v3 | |
| with: | |
| languages: javascript | |
| - name: ๐ Perform CodeQL Analysis | |
| uses: github/codeql-action/analyze@v3 | |
| # ============================================================================ | |
| # ๆๅปบๆต่ฏ | |
| # ============================================================================ | |
| build-test: | |
| name: ๐๏ธ Build Test | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| needs: [coverage, security] | |
| steps: | |
| - name: ๐ฅ Checkout code | |
| uses: actions/checkout@v4 | |
| - name: ๐ฆ Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: ๐ฅ Install dependencies | |
| run: npm ci | |
| - name: ๐๏ธ Build project | |
| run: npm run build | |
| - name: ๐ฆ Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-output | |
| path: | | |
| .output/ | |
| dist/ | |
| retention-days: 7 | |
| # ============================================================================ | |
| # ๆต่ฏๆป็ป | |
| # ============================================================================ | |
| test-summary: | |
| name: ๐ Test Summary | |
| runs-on: ubuntu-latest | |
| needs: [unit-tests, integration-tests, performance-tests, coverage, browser-tests, build-test] | |
| if: always() | |
| steps: | |
| - name: ๐ฅ Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts/ | |
| - name: ๐ Generate test summary | |
| run: | | |
| echo "# ๐งช Test Results Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "## ๐ Test Status" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "| Test Type | Status |" >> $GITHUB_STEP_SUMMARY | |
| echo "|-----------|--------|" >> $GITHUB_STEP_SUMMARY | |
| echo "| Unit Tests | ${{ needs.unit-tests.result == 'success' && 'โ Passed' || 'โ Failed' }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| Integration Tests | ${{ needs.integration-tests.result == 'success' && 'โ Passed' || 'โ Failed' }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| Performance Tests | ${{ needs.performance-tests.result == 'success' && 'โ Passed' || 'โ Failed' }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| Coverage | ${{ needs.coverage.result == 'success' && 'โ Passed' || 'โ Failed' }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| Browser Tests | ${{ needs.browser-tests.result == 'success' && 'โ Passed' || 'โ Failed' }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| Build Test | ${{ needs.build-test.result == 'success' && 'โ Passed' || 'โ Failed' }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "## ๐ Metrics" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Commit**: \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Branch**: \`${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Workflow**: [\#${{ github.run_number }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" >> $GITHUB_STEP_SUMMARY | |
| - name: ๐ Success notification | |
| if: needs.unit-tests.result == 'success' && needs.integration-tests.result == 'success' && needs.coverage.result == 'success' | |
| run: | | |
| echo "๐ All tests passed successfully!" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "The config-helpers module is ready for deployment! ๐" >> $GITHUB_STEP_SUMMARY |