-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (77 loc) · 3.33 KB
/
Copy pathcoverage-report.yml
File metadata and controls
87 lines (77 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: coverage-report
# Daily: 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 * * *" # Daily 06:23 UTC (reads curated data/, so safe to run every day)
workflow_dispatch:
permissions:
contents: read
issues: write
# Guard against a slow run overlapping the next day's scheduled run.
concurrency:
group: coverage-report
cancel-in-progress: false
jobs:
report:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: GetTechAPI/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 and TechAPI.
#
# Authorship: a GitHub issue's author is the account behind the *token*
# (unlike a commit, it cannot be set via git config). To attribute the
# auto-generated issues to TechEngineBot, set a TechEngineBot PAT with
# Issues:write on both repos as the TECHENGINEBOT_TOKEN secret; the steps
# below prefer it. Without it they fall back to the default GITHUB_TOKEN
# (TechEngine, authored by github-actions) and TECHAPI_TOKEN (TechAPI).
- name: Sync sticky coverage issue (TechEngine + TechAPI)
env:
BOT_TOKEN: ${{ secrets.TECHENGINEBOT_TOKEN }}
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
}
# Prefer the TechEngineBot PAT (so the issue is authored by the bot);
# fall back to the per-repo defaults when it is not configured.
sync_issue "${{ github.repository }}" "${BOT_TOKEN:-$SELF_TOKEN}" \
|| echo "::warning::TechEngine coverage issue sync failed"
# TechAPI: best-effort — requires Issues:write on the chosen token.
sync_issue "GetTechAPI/TechAPI" "${BOT_TOKEN:-$TECHAPI_TOKEN}" \
|| echo "::warning::TechAPI coverage issue sync failed — token likely lacks Issues:write"