coverage-report #5
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-report | |
| # Weekly: pull upstream catalogs, diff vs the curated TechAPI dataset, post | |
| # the gap list as a sticky issue (auto-updates the existing one each run). | |
| on: | |
| schedule: | |
| - cron: "23 6 * * 1" # Mondays 06:23 UTC, after refresh-data (06:17) | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| issues: write | |
| jobs: | |
| report: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/checkout@v4 | |
| with: | |
| repository: Seungpyo1007/TechAPI | |
| path: TechAPI | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| cache: pip | |
| - name: Install | |
| run: pip install -e . | |
| - name: Build coverage report | |
| env: | |
| TECHAPI_DATA_DIR: ${{ github.workspace }}/TechAPI/data | |
| run: python -m app.coverage --output coverage-report.md | |
| - name: Upload report artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: coverage-report.md | |
| # Sticky issue: keep one open issue with the well-known title per repo, | |
| # updating it in place. Posts to BOTH TechEngine (default GITHUB_TOKEN) and | |
| # TechAPI (TECHAPI_TOKEN). The TechAPI post is best-effort: it needs the PAT | |
| # to carry Issues:write, so a missing permission warns instead of failing. | |
| - name: Sync sticky coverage issue (TechEngine + TechAPI) | |
| env: | |
| SELF_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| TECHAPI_TOKEN: ${{ secrets.TECHAPI_TOKEN }} | |
| run: | | |
| set -uo pipefail | |
| TITLE="Coverage gaps (auto-generated)" | |
| BODY="$(cat coverage-report.md)" | |
| sync_issue() { | |
| repo="$1"; token="$2" | |
| if [ -z "$token" ]; then | |
| echo "::warning::no token for $repo; skipping coverage issue" | |
| return 0 | |
| fi | |
| NUMBER=$(GH_TOKEN="$token" gh issue list --repo "$repo" --state open \ | |
| --search "in:title \"$TITLE\"" --json number --jq '.[0].number // empty') || return 1 | |
| if [ -z "${NUMBER:-}" ]; then | |
| GH_TOKEN="$token" gh issue create --repo "$repo" --title "$TITLE" --body "$BODY" | |
| else | |
| GH_TOKEN="$token" gh issue edit "$NUMBER" --repo "$repo" --body "$BODY" | |
| fi | |
| } | |
| # TechEngine: default token has issues:write on this repo. | |
| sync_issue "${{ github.repository }}" "$SELF_TOKEN" \ | |
| || echo "::warning::TechEngine coverage issue sync failed" | |
| # TechAPI: best-effort — requires Issues:write on TECHAPI_TOKEN. | |
| sync_issue "Seungpyo1007/TechAPI" "$TECHAPI_TOKEN" \ | |
| || echo "::warning::TechAPI coverage issue sync failed — TECHAPI_TOKEN likely lacks Issues:write" |