8000 feat(inkless:sync): label upstream sync PRs with `upstream` by jeqo · Pull Request #829 · aiven/inkless · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/inkless-pr-labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Labels pull requests that bring apache/kafka commits into Inkless with `upstream`.
#
# pull_request_target runs with write access to the base repository, so this workflow
# never checks out or executes anything from the pull request. It fetches commit
# objects only (no trees, no blobs) to walk the merge parents.
name: Inkless PR labels

on:
pull_request_target:
types: [opened, reopened]
branches:
- 'main'
- 'inkless-4.*'

permissions:
contents: read
pull-requests: write

jobs:
upstream-label:
name: Label upstream sync PRs
runs-on: ubuntu-latest
steps:
- name: Detect apache/kafka commits in the pull request
id: detect
env:
REPO: ${{ github.repository }}
HEAD_REF: ${{ github.event.pull_request.head.ref }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
set -euo pipefail
upstream=false
# Sync branches follow inkless-sync/ naming; detect them without any fetch.
case "$HEAD_REF" in
sync/upstream-*|inkless-*-sync-*) upstream=true ;;
esac

if [ "$upstream" = false ]; then
git init -q repo
cd repo
# tree:0 fetches commit objects only. Enough to walk parents, and no PR
# content lands on disk.
git fetch -q --filter=tree:0 --no-tags "https://github.com/${REPO}.git" \
"$BASE_SHA" "$HEAD_SHA"
merges=$(git rev-list --merges --first-parent "${BASE_SHA}..${HEAD_SHA}")
# Most PRs have no merge commit, so skip the apache/kafka fetch for them.
if [ -n "$merges" ]; then
git fetch -q --filter=tree:0 --no-tags https://github.com/apache/ka 8000 fka.git \
'+refs/heads/*:refs/remotes/apache/*'
# A sync merges an apache/kafka commit as the second parent. A merge of
# origin/main into a feature branch has an Inkless commit there instead.
for merge in $merges; do
if [ -n "$(git for-each-ref refs/remotes/apache --contains "${merge}^2")" ]; then
echo "Merge ${merge} brings apache/kafka commit $(git rev-parse --short "${merge}^2")"
upstream=true
break
fi
done
fi
fi
echo "upstream=${upstream}" >> "$GITHUB_OUTPUT"

- name: Add the upstream label
if: steps.detect.outputs.upstream == 'true'
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
PR: ${{ github.event.number }}
run: gh pr edit "$PR" --repo "$REPO" --add-label upstream
14 changes: 13 additions & 1 deletion inkless-sync/MAIN-SYNC-ACTION-PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,19 @@ git commit -m "sync(test): [description]"
- Complete session file
- Note any learnings

#### Step 10: Merge the sync PR (10 min)
#### Step 10: open and merge the sync PR (10 min)

Open the PR against `main` with the `upstream` label:

```bash
git push -u origin sync/upstream-YYYYMMDD
gh pr create --base main --label upstream --title "chore(inkless:sync): upstream Apache Kafka YYYY-MM-DD"
```

The `upstream` label marks every PR that brings `apache/kafka` commits. The `Inkless PR labels`
workflow (`.github/workflows/inkless-pr-labels.yml`) adds it on its own when the branch is named
`sync/upstream-*` or a merge commit in the PR has an `apache/kafka` parent; passing `--label` keeps
the PR correct if that workflow doesn't run.

**A repository admin has to merge a sync PR.** Both settings this step changes, the `main` ruleset
and the repository's merge options, are admin-only. The `maintain` role can't reach them. If you
Expand Down
3 changes: 2 additions & 1 deletion inkless-sync/MAIN-SYNC-PROMPT.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ Complete verification and generate report.
4. Archive the session file:
mv .inkless-sync/SESSION-*.md inkless-sync/sessions/

5. If successful, provide PR description draft.
5. If successful, provide PR description draft. The PR carries the `upstream` label
(`gh pr create --label upstream ...`).
```

## Error Recovery Prompts
Expand Down
4 changes: 3 additions & 1 deletion inkless-sync/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@ This script is designed to be run by an automated agent (e.g., Claude):
2. If manual conflicts: Agent reports to human via PR/issue
3. If compilation errors: Agent attempts fixes, commits separately
4. If test failures: Agent analyzes and fixes or reports
5. Agent creates PR with sync report
5. Agent creates PR with sync report and the `upstream` label (`gh pr create --label upstream`);
`.github/workflows/inkless-pr-labels.yml` also adds the label when it detects `apache/kafka`
commits in the PR

The structured commit approach makes it easy to:
- Review what changed and why
Expand Down
5 changes: 4 additions & 1 deletion inkless-sync/RELEASE-SYNC-ACTION-PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,12 @@ make test

```bash
git push -u origin inkless-4.0-sync-4.0.1
gh pr create --base inkless-4.0 --title "Sync inkless-4.0 to upstream 4.0.1"
gh pr create --base inkless-4.0 --label upstream --title "chore(inkless): sync inkless-4.0 with upstream Apache Kafka 4.0.1"
```

Label sync PRs `upstream`. The `Inkless PR labels` workflow adds it for
`inkless-*-sync-*` branches and for PRs whose merge commit has an `apache/kafka` parent.

## Conflict Resolution Playbook

### Version Files
Expand Down
7 changes: 5 additions & 2 deletions inkless-sync/RELEASE-SYNC-GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,14 @@ git fetch apache --tags
mv .inkless-sync/RELEASE-SESSION-*.md inkless-sync/sessions/
```

9. **Push for review**:
9. **Push for review**, with the `upstream` label on the PR:
```bash
git push origin inkless-4.0-sync-4.0.1
# Create PR to merge into inkless-4.0
gh pr create --base inkless-4.0 --label upstream --title "chore(inkless): sync inkless-4.0 with upstream Apache Kafka 4.0.1"
```
The `Inkless PR labels` workflow adds the label on its own for `inkless-*-sync-*` branches
and for PRs whose merge commit has an `apache/kafka` parent, as long as the workflow file
exists on the release branch.

## Handling Conflicts

Expand Down
Loading
0