chore(deps): bump actions/checkout from 4 to 7 #280
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: Bilingual Coverage Impact | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| coverage-impact: | |
| name: Report coverage impact | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| - name: Analyze changed files | |
| id: analyze | |
| run: | | |
| CHANGED=$(git diff --name-only origin/main...HEAD -- '*.md' | grep -v '.es.md' | grep -v node_modules) | |
| echo "Changed EN files: $CHANGED" | |
| PAIRS_COUNT=0 | |
| NEW_NEED_ES=0 | |
| for file in $CHANGED; do | |
| if [ -f "$file" ]; then | |
| ES_FILE="${file%.md}.es.md" | |
| if [ -f "$ES_FILE" ]; then | |
| PAIRS_COUNT=$((PAIRS_COUNT + 1)) | |
| else | |
| NEW_NEED_ES=$((NEW_NEED_ES + 1)) | |
| fi | |
| fi | |
| done | |
| echo "Paired files modified: $PAIRS_COUNT" | |
| echo "New EN files needing ES: $NEW_NEED_ES" | |
| TOTAL_EN=$(find reference -name '*.md' ! -name '*.es.md' | wc -l) | |
| TOTAL_ES=$(find reference -name '*.es.md' | wc -l) | |
| PAIRS=$(find reference -name '*.md' ! -name '*.es.md' -exec test -f '{}.es.md' \; -print | wc -l) | |
| COVERAGE=$(echo "scale=1; $PAIRS * 100 / $TOTAL_EN" | bc) | |
| echo "Total EN: $TOTAL_EN" | |
| echo "Total ES: $TOTAL_ES" | |
| echo "Paired: $PAIRS" | |
| echo "Coverage: $COVERAGE%" | |
| echo "pairs_modified=$PAIRS_COUNT" >> $GITHUB_OUTPUT | |
| echo "new_need_es=$NEW_NEED_ES" >> $GITHUB_OUTPUT | |
| echo "total_en=$TOTAL_EN" >> $GITHUB_OUTPUT | |
| echo "total_es=$TOTAL_ES" >> $GITHUB_OUTPUT | |
| echo "paired=$PAIRS" >> $GITHUB_OUTPUT | |
| echo "coverage=$COVERAGE" >> $GITHUB_OUTPUT | |
| - name: Post coverage comment | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const { pairs_modified, new_need_es, total_en, total_es, paired, coverage } = ${{ toJSON(steps.analyze.outputs) }}; | |
| const body = ` | |
| ## 📊 Bilingual Coverage Impact | |
| ### PR Changes | |
| - Paired EN/ES files modified: **${pairs_modified}** | |
| - New EN files needing ES translation: **${new_need_es}** | |
| ### Repository Coverage | |
| | Metric | Value | | |
| |--------|-------| | |
| | Total EN files | ${total_en} | | |
| | Total ES files | ${total_es} | | |
| | Paired files | ${paired} | | |
| | **Coverage** | **${coverage}%** | | |
| ${new_need_es > 0 ? `⚠️ **Action required:** ${new_need_es} new EN file(s) added without ES counterparts.\n\nTo create skeletons:\n\`\`\`bash\nnode .harness/scripts/generate-es-skeleton.mjs <file.md>\n\`\`\`` : '✅ **Good:** All EN changes have ES counterparts.'} | |
| --- | |
| *Generated by GitHub Actions* | |
| `; | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number | |
| }); | |
| const existing = comments.find(c => c.user.login === 'github-actions[bot]' && c.body.includes('Bilingual Coverage Impact')); | |
| if (existing) { | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: existing.id, | |
| body | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body | |
| }); | |
| } |