Skip to content

๐Ÿ› fix: ไฟฎๅค GitHub Actions ๅทฅไฝœๆต YAML ่ฏญๆณ•้”™่ฏฏ #3

๐Ÿ› fix: ไฟฎๅค GitHub Actions ๅทฅไฝœๆต YAML ่ฏญๆณ•้”™่ฏฏ

๐Ÿ› fix: ไฟฎๅค GitHub Actions ๅทฅไฝœๆต YAML ่ฏญๆณ•้”™่ฏฏ #3

Workflow file for this run

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