Skip to content

Commit b3020ea

Browse files
feat: add manual dispatch trigger with optional PR number input
The workflow can now be triggered manually via workflow_dispatch with: - An optional pr_number input to specify a specific PR - If pr_number is not provided, uses the most recent merged PR - Falls back to HEAD if no PR is found This allows re-running the CLI coverage analysis for past PRs or triggering it manually without requiring a new push to main. Co-authored-by: mason <mason@onkernel.com>
1 parent 23d4b9b commit b3020ea

1 file changed

Lines changed: 59 additions & 6 deletions

File tree

.github/workflows/update-cli-coverage.yml

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ name: Update CLI Coverage
33
on:
44
push:
55
branches: [main]
6+
workflow_dispatch:
7+
inputs:
8+
pr_number:
9+
description: 'PR number to use for context (leave empty to use most recent merged PR)'
10+
required: false
11+
type: string
612
# Or trigger on releases:
713
# release:
814
# types: [published]
@@ -14,11 +20,49 @@ jobs:
1420
update-cli-coverage:
1521
runs-on: ubuntu-latest
1622
steps:
23+
- name: Get PR info for manual dispatch
24+
id: pr-info
25+
if: github.event_name == 'workflow_dispatch'
26+
env:
27+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
28+
run: |
29+
if [ -n "${{ inputs.pr_number }}" ]; then
30+
# Use provided PR number
31+
PR_NUMBER="${{ inputs.pr_number }}"
32+
echo "Using provided PR number: $PR_NUMBER"
33+
else
34+
# Get most recent merged PR
35+
PR_NUMBER=$(gh pr list --repo ${{ github.repository }} --state merged --limit 1 --json number --jq '.[0].number')
36+
echo "Using most recent merged PR: $PR_NUMBER"
37+
fi
38+
39+
if [ -z "$PR_NUMBER" ]; then
40+
echo "No PR found, will use HEAD commit"
41+
echo "has_pr=false" >> $GITHUB_OUTPUT
42+
else
43+
# Get PR details
44+
PR_DATA=$(gh pr view "$PR_NUMBER" --repo ${{ github.repository }} --json mergeCommit,author,title)
45+
MERGE_SHA=$(echo "$PR_DATA" | jq -r '.mergeCommit.oid // empty')
46+
PR_AUTHOR=$(echo "$PR_DATA" | jq -r '.author.login // empty')
47+
PR_TITLE=$(echo "$PR_DATA" | jq -r '.title // empty')
48+
49+
echo "PR #$PR_NUMBER: $PR_TITLE"
50+
echo "Merge commit: $MERGE_SHA"
51+
echo "Author: $PR_AUTHOR"
52+
53+
echo "has_pr=true" >> $GITHUB_OUTPUT
54+
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
55+
echo "merge_sha=$MERGE_SHA" >> $GITHUB_OUTPUT
56+
echo "pr_author=$PR_AUTHOR" >> $GITHUB_OUTPUT
57+
fi
58+
1759
- name: Checkout SDK repo
1860
uses: actions/checkout@v4
1961
with:
2062
fetch-depth: 2
2163
fetch-tags: true
64+
# For manual dispatch with a specific PR, checkout the merge commit
65+
ref: ${{ steps.pr-info.outputs.merge_sha || github.sha }}
2266

2367
- name: Install Cursor CLI
2468
run: |
@@ -56,14 +100,22 @@ jobs:
56100
echo "version=$LATEST_TAG" >> $GITHUB_OUTPUT
57101
echo "SDK version: $LATEST_TAG"
58102
else
59-
echo "version=${{ github.sha }}" >> $GITHUB_OUTPUT
60-
echo "SDK version: ${{ github.sha }} (no tag)"
103+
CURRENT_SHA="${{ steps.pr-info.outputs.merge_sha || github.sha }}"
104+
echo "version=$CURRENT_SHA" >> $GITHUB_OUTPUT
105+
echo "SDK version: $CURRENT_SHA (no tag)"
61106
fi
62107
63108
# Get the module path from go.mod
64109
MODULE_PATH=$(head -1 go.mod | awk '{print $2}')
65110
echo "module=$MODULE_PATH" >> $GITHUB_OUTPUT
66111
echo "SDK module: $MODULE_PATH"
112+
113+
# Determine the commit author (from PR info for manual dispatch, or from push event)
114+
if [ -n "${{ steps.pr-info.outputs.pr_author }}" ]; then
115+
echo "author=${{ steps.pr-info.outputs.pr_author }}" >> $GITHUB_OUTPUT
116+
else
117+
echo "author=${{ github.event.head_commit.author.username || github.actor }}" >> $GITHUB_OUTPUT
118+
fi
67119
68120
- name: Update CLI coverage
69121
env:
@@ -79,8 +131,9 @@ jobs:
79131
- SDK Repo: ${{ github.repository }} (current directory)
80132
- SDK Module: ${{ steps.sdk-version.outputs.module }}
81133
- SDK Version: ${{ steps.sdk-version.outputs.version }}
82-
- Commit SHA: ${{ github.sha }}
83-
- Commit Author: ${{ github.event.head_commit.author.username || github.actor }}
134+
- Commit SHA: ${{ steps.pr-info.outputs.merge_sha || github.sha }}
135+
- Commit Author: ${{ steps.sdk-version.outputs.author }}
136+
- Trigger: ${{ github.event_name }} ${{ inputs.pr_number && format('(PR #{0})', inputs.pr_number) || '' }}
84137
- API Repo Location: /tmp/kernel-api
85138
- CLI Repo Location: /tmp/kernel-cli
86139
- Update Branch Prefix: cli-coverage-update
@@ -214,7 +267,7 @@ jobs:
214267
## New Flags
215268
- \`--flag-name\` for \`ResourceParams.FieldName\`
216269
217-
Triggered by: kernel/kernel-go-sdk@${{ github.sha }}
270+
Triggered by: kernel/kernel-go-sdk@${{ steps.pr-info.outputs.merge_sha || github.sha }}
218271
Reviewer: @<commit_author>'
219272
220273
If only SDK version update (no coverage gaps found):
@@ -228,7 +281,7 @@ jobs:
228281
## Coverage Analysis
229282
A full enumeration of SDK methods and CLI commands was performed. No coverage gaps were found.
230283
231-
Triggered by: kernel/kernel-go-sdk@${{ github.sha }}
284+
Triggered by: kernel/kernel-go-sdk@${{ steps.pr-info.outputs.merge_sha || github.sha }}
232285
Reviewer: @<commit_author>'
233286
234287
# Constraints

0 commit comments

Comments
 (0)