fix: remove redundant role="img" when lazyLoad is enabled #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: Coverage Tests | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| test-and-badge: | |
| name: Run Tests & Update Badge | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| - name: Setup Node 22 | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run tests with JSON reporter | |
| id: test | |
| run: | | |
| # Run tests and capture output | |
| npm run test -- --reporter=json --reporter=default --outputFile=test-results.json || true | |
| # Check if test results file exists | |
| if [ ! -f test-results.json ]; then | |
| echo "Test results file not found, creating fallback" | |
| echo '{"numTotalTests": 0, "numPassedTests": 0}' > test-results.json | |
| fi | |
| # Parse test results | |
| TOTAL=$(node -p "try { const r = require('./test-results.json'); r.numTotalTests || 0 } catch(e) { 0 }") | |
| PASSED=$(node -p "try { const r = require('./test-results.json'); r.numPassedTests || 0 } catch(e) { 0 }") | |
| echo "total=$TOTAL" >> $GITHUB_OUTPUT | |
| echo "passed=$PASSED" >> $GITHUB_OUTPUT | |
| # Determine color based on pass rate | |
| if [ "$TOTAL" -eq 0 ]; then | |
| COLOR="lightgrey" | |
| elif [ "$PASSED" -eq "$TOTAL" ]; then | |
| COLOR="brightgreen" | |
| elif [ "$PASSED" -ge $((TOTAL * 80 / 100)) ]; then | |
| COLOR="green" | |
| elif [ "$PASSED" -ge $((TOTAL * 60 / 100)) ]; then | |
| COLOR="yellow" | |
| else | |
| COLOR="red" | |
| fi | |
| echo "color=$COLOR" >> $GITHUB_OUTPUT | |
| echo "### π§ͺ Test Results" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Passed:** $PASSED / $TOTAL" >> $GITHUB_STEP_SUMMARY | |
| echo "**Status:** $COLOR" >> $GITHUB_STEP_SUMMARY | |
| - name: Generate badge data | |
| run: | | |
| mkdir -p .github/badges | |
| cat > .github/badges/coverage-tests.json << EOF | |
| { | |
| "schemaVersion": 1, | |
| "label": "Coverage", | |
| "message": "${{ steps.test.outputs.passed }} / ${{ steps.test.outputs.total }} tests", | |
| "color": "${{ steps.test.outputs.color }}" | |
| } | |
| EOF | |
| - name: Commit badge data | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git add .github/badges/coverage-tests.json | |
| git diff --staged --quiet || git commit -m "Update test badge [skip ci]" | |
| git push | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: test-results | |
| path: | | |
| test-results.json | |
| .github/badges/coverage-tests.json | |
| retention-days: 30 |