Skip to content

Commit 94152fd

Browse files
Vishal Vaibhavclaude
authored andcommitted
feat: move-diff-logic-within-the-plugin
Drop the Vela start.sh entrypoint and run the plugin binary directly (ENTRYPOINT ["/plugin"]); the diff is now produced in-plugin (PARAMETER_DIFF_SOURCE=github) or piped on stdin. Also run the coverage job on fork PRs, tolerating the read-only-token comment 403 via continue-on-error. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 64a5439 commit 94152fd

3 files changed

Lines changed: 13 additions & 36 deletions

File tree

.github/workflows/pr-coverage.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ permissions:
1414
jobs:
1515
coverage:
1616
runs-on: ubuntu-latest
17-
# Fork PRs only get a read-only GITHUB_TOKEN (can't comment) and no secrets,
18-
# so restrict to same-repo PRs to avoid a guaranteed failure on forks.
19-
if: github.event.pull_request.head.repo.full_name == github.repository
17+
# Runs on fork PRs too. Fork PRs only get a read-only GITHUB_TOKEN and no
18+
# secrets, so the plugin can't post the PR comment there — it just prints
19+
# coverage to the job log (the reporter no-ops the comment when the token /
20+
# PR context is missing).
2021
steps:
2122
- name: Check out the repo
2223
uses: actions/checkout@v4
@@ -45,6 +46,11 @@ jobs:
4546
run: docker build -t pr-code-coverage:ci .
4647

4748
- name: Report coverage on changed lines
49+
# On fork PRs the GITHUB_TOKEN is read-only: the plugin can read the diff
50+
# but the PR-comment POST gets a 403 and errors. Tolerate that on forks so
51+
# the run still goes green with coverage printed to the log; same-repo PRs
52+
# keep failing loudly on real errors.
53+
continue-on-error: ${{ github.event.pull_request.head.repo.full_name != github.repository }}
4854
env:
4955
# Fetch the PR diff straight from the GitHub API instead of piping in a
5056
# local `git diff`. Note the API diff covers ALL changed files, not just
@@ -73,5 +79,4 @@ jobs:
7379
-e REPOSITORY_NAME \
7480
-v "${{ github.workspace }}:${{ github.workspace }}" \
7581
-w "${{ github.workspace }}" \
76-
--entrypoint /plugin \
7782
pr-code-coverage:ci

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,7 @@ FROM alpine:latest
1313
COPY --from=builder /go/src/github.com/target/pull-request-code-coverage/bin/plugin /
1414
RUN apk --no-cache add ca-certificates git bash openssh-client
1515
WORKDIR /root/
16-
COPY scripts/start.sh /
17-
CMD ["/start.sh"]
16+
# Run the plugin directly. With PARAMETER_DIFF_SOURCE=github it fetches the PR
17+
# diff from the GitHub API; for the stdin path, pipe a `git diff` into the
18+
# container (docker run -i ... | git diff ...).
19+
ENTRYPOINT ["/plugin"]

scripts/start.sh

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)