Skip to content

feat(observability-map): static observability scorer for webapp route entry points #3

feat(observability-map): static observability scorer for webapp route entry points

feat(observability-map): static observability scorer for webapp route entry points #3

name: 🗺️ Observability Map
on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- "apps/webapp/app/routes/**"
- "internal-packages/observability-map/**"
concurrency:
group: observability-map-${{ github.event.pull_request.number }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
jobs:
report:
runs-on: warp-ubuntu-latest-x64-4x
# Fork PRs get a read-only token, so the comment cannot post. Skipping the job beats a red x.
if: github.event.pull_request.head.repo.full_name == github.repository
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
persist-credentials: false
- name: ⎔ Setup pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0
with:
version: 10.33.2
- name: ⎔ Setup node
uses: WarpBuilds/setup-node@bc639b444d583175926b588962199c247d23e8d3 # v6
with:
node-version: 24.18.0
cache: "pnpm"
- name: 📥 Download deps
run: pnpm install --frozen-lockfile
- name: 🔎 Scan head
run: |
pnpm --filter @internal/observability-map exec tsx src/cli.ts --json --no-write > /tmp/head.json
- name: 🔎 Scan base with the head's scanner
run: |
if git worktree add /tmp/base-tree ${{ github.event.pull_request.base.sha }} \
&& pnpm --filter @internal/observability-map exec tsx src/cli.ts --json --no-write \
--routes=/tmp/base-tree/apps/webapp/app/routes > /tmp/base.json; then
:
else
echo "-" > /tmp/base.json || true
echo "base scan failed or the worktree could not be added; falling back to no base" >&2
fi
# continue-on-error: this job must never block a PR. A malformed head.json or a rendering
# bug would otherwise turn the job red the same way a base-scan failure would not, since that
# step already falls back to "-" instead of failing.
- name: 📝 Render comment
continue-on-error: true
run: |
if [ "$(cat /tmp/base.json)" = "-" ]; then
pnpm --filter @internal/observability-map exec tsx src/report/prCommentCli.ts /tmp/head.json - > /tmp/comment.md
else
pnpm --filter @internal/observability-map exec tsx src/report/prCommentCli.ts /tmp/head.json /tmp/base.json > /tmp/comment.md
fi
# continue-on-error for the same reason: a transient gh api failure (rate limit, network)
# must not fail the job either. Worst case, the PR gets no comment this run.
- name: 💬 Upsert PR comment
continue-on-error: true
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
existing=$(gh api "repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/comments" --paginate \
--jq '[.[] | select(.body | startswith("<!-- observability-map-report -->"))][0].id // empty')
if [ -n "$existing" ]; then
gh api -X PATCH "repos/${GITHUB_REPOSITORY}/issues/comments/${existing}" -F body=@/tmp/comment.md
else
gh api "repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/comments" -F body=@/tmp/comment.md
fi