Repository navigation
Add skills for upstreaming and downstreaming commits / PRs #648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
edolstra
wants to merge
6
commits into
main
Choose a base branch
from
upstream-skill
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
60a50bd
Add a skill for upstreaming commits / PRs
edolstra 1290d25
upstream skill: Follow skill authoring best practices
edolstra 583b49e
Add a skill for downstreaming commits / PRs
edolstra c247490
upstream skill: Don't let the new branch track the base branch
edolstra f0ca1c4
upstream skill: Simplify
edolstra 82dc741
upstream/downstream skills: Condense
edolstra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| --- | ||
| name: downstream | ||
| description: Downstreams an upstream Nix change (a commit rev or a NixOS/nix PR number) to Determinate Nix (DeterminateSystems/nix-src). Creates a branch and worktree from detsys/main, cherry-picks the commits, proposes upstream prerequisites if the change turns out to need them, builds and tests, pushes the branch and opens a PR against main. Use when the user asks to downstream, backport or cherry-pick an upstream Nix commit or PR into Determinate Nix. | ||
| argument-hint: <commit-rev | NixOS/nix PR number> [more revs/PRs...] [branch-name] | ||
| user-invocable: true | ||
| --- | ||
|
|
||
| # Downstreaming an upstream Nix change to DeterminateSystems/nix-src | ||
|
|
||
| Arguments: `$ARGUMENTS` | ||
|
|
||
| Each argument is either a commit rev in upstream Nix, or a pull request number of https://github.com/NixOS/nix. Several may be given; they are cherry-picked in the order given. An argument that is neither a rev nor a number is used as the branch name. | ||
|
|
||
| Copy this checklist and check off items as you complete them: | ||
|
|
||
| ``` | ||
| - [ ] Verify and fetch the remotes | ||
| - [ ] Step 1: Determine the commits to cherry-pick | ||
| - [ ] Step 2: Create the branch and worktree | ||
| - [ ] Step 3: Cherry-pick, building and testing along the way | ||
| - [ ] Step 4: Format and run the full tests | ||
| - [ ] Step 5: Push and create the PR | ||
| ``` | ||
|
|
||
| ## Remotes | ||
|
|
||
| * `origin` is upstream Nix, `git@github.com:NixOS/nix.git`, main branch `master`. | ||
| * `detsys` is Determinate Nix, `git@github.com:DeterminateSystems/nix-src.git`. The new branch is pushed there and the PR is opened against its `main` branch. | ||
|
|
||
| Verify both before doing anything. Add `detsys` if it is missing; stop and tell the user if `origin` is not NixOS/nix. Then fetch `origin master` and `detsys main`. | ||
|
|
||
| ## Step 1: Determine the commits to cherry-pick | ||
|
edolstra marked this conversation as resolved.
|
||
|
|
||
| For a commit rev, that commit. For a PR, the PR's own commits (`gh pr view N --repo NixOS/nix`), without merge commits. Leave out commits that Determinate Nix already has. | ||
|
|
||
| ## Step 2: Create the branch and worktree | ||
|
|
||
| Create the branch from `detsys/main` without tracking it, in a new worktree that is a sibling of the main checkout named `nix-<branch>`. Use the branch name the user supplied, if any. If the directory or branch already exists, pick a different name rather than reusing or deleting anything. Do all further work in that worktree; never touch the one the skill was started from. | ||
|
edolstra marked this conversation as resolved.
|
||
|
|
||
| ## Step 3: Cherry-pick, building and testing along the way | ||
|
|
||
| Cherry-pick with `-x`. Keep the original author, message and trailers; do not add trailers of your own. | ||
|
|
||
| After each non-trivial cherry-pick (one that needed conflict resolution, or that is large or touches code Determinate Nix has changed), build and run the relevant tests before continuing, so that a problem is found at the commit that causes it. `AGENTS.md` in the worktree describes how; the `debug-fast` variant is enough here. | ||
|
|
||
| Resolve simple conflicts yourself, such as context drift, renamed files, or trivial API differences whose adaptation is obviously correct. Fix small build or test failures caused by a cherry-picked commit by amending that commit. Mention every such intervention in the final report. | ||
|
|
||
| For a bigger conflict or failure, first investigate whether the change depends on upstream commits that Determinate Nix does not have yet. If so, propose cherry-picking those prerequisites as well: tell the user which commits (and upstream PRs) they are and why the change needs them, and wait for the answer. If the problem is something else, for example Determinate Nix redesigned the same area, or you are unsure that a resolution preserves the intended behaviour, do not guess: explain the problem and the options you see, and ask how to proceed. | ||
|
|
||
| ## Step 4: Format and run the full tests | ||
|
|
||
| Run `nix develop -c ./maintainers/format.sh` and fold any changes into the commits that introduced them. Then do the release build and run the full functional tests as described in `AGENTS.md`; this takes a long time, so run it in the background. | ||
|
|
||
| Handle failures as in Step 3. A failure that also occurs on `detsys/main` is not caused by the change; mention it in the final report and carry on. Do not create the PR while the build or tests fail because of the change. | ||
|
|
||
| ## Step 5: Push and create the PR | ||
|
|
||
| Write the PR description starting from `.github/PULL_REQUEST_TEMPLATE.md` in the worktree: | ||
|
|
||
| * Title: the upstream PR's title, or the commit's subject line. | ||
| * Motivation: reuse the upstream PR's own description, or summarise the commit messages if there is no PR. End with a link to the source, for example `Cherry-picked from https://github.com/NixOS/nix/pull/N.` | ||
| * Context: list any prerequisites that were included and why, and any adaptation that was needed for Determinate Nix. Leave the template's placeholder comments in place if there is nothing to say. | ||
|
|
||
| Push the branch to `detsys` and open the PR with `gh pr create --repo DeterminateSystems/nix-src --base main`. | ||
|
|
||
| Finish with the final report: the PR URL, the branch name and worktree path, the cherry-picked commits (marking which were prerequisites), commits that were left out and why, conflicts and failures you fixed by hand, and the build and test outcome. Mention that the worktree can be removed later with `git worktree remove`. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| --- | ||
| name: upstream | ||
| description: Upstreams a Determinate Nix change (a commit rev or a DeterminateSystems/nix-src PR number) to upstream Nix (NixOS/nix). Creates a branch and worktree from origin/master, cherry-picks the commits, builds and tests, drafts a PR description for the user to review, and only after approval pushes the branch and opens the PR. Use when the user asks to upstream, cherry-pick to upstream, or open an upstream PR for a Determinate Nix change. | ||
| argument-hint: <commit-rev | nix-src PR number> [more revs/PRs...] [branch-name] | ||
| user-invocable: true | ||
| --- | ||
|
|
||
| # Upstreaming a Determinate Nix change to NixOS/nix | ||
|
|
||
| Arguments: `$ARGUMENTS` | ||
|
|
||
| Each argument is either a commit rev in Determinate Nix, or a pull request number of https://github.com/DeterminateSystems/nix-src. Several may be given; they are cherry-picked in the order given. An argument that is neither a rev nor a number is used as the branch name. | ||
|
|
||
| Copy this checklist and check off items as you complete them: | ||
|
|
||
| ``` | ||
| - [ ] Verify and fetch the remotes | ||
| - [ ] Step 1: Determine the commits to cherry-pick | ||
| - [ ] Step 2: Create the branch and worktree | ||
| - [ ] Step 3: Cherry-pick, building and testing along the way | ||
| - [ ] Step 4: Format and run the full tests | ||
| - [ ] Step 5: Draft the PR description and report | ||
| - [ ] STOP: wait for the user to approve the draft | ||
| - [ ] Step 6: Push and create the PR | ||
| ``` | ||
|
|
||
| ## Remotes | ||
|
|
||
| * `origin` is upstream Nix, `git@github.com:NixOS/nix.git`. The new branch is pushed there and the PR is opened against its `master` branch. | ||
| * `detsys` is Determinate Nix, `git@github.com:DeterminateSystems/nix-src.git`, main branch `main`. | ||
|
|
||
| Verify both before doing anything. Add `detsys` if it is missing; stop and tell the user if `origin` is not NixOS/nix. Then fetch `origin master` and `detsys main`. | ||
|
|
||
| ## Step 1: Determine the commits to cherry-pick | ||
|
|
||
| For a commit rev, that commit. For a PR, the PR's own commits (`gh pr view N --repo DeterminateSystems/nix-src`), without merge commits. Leave out commits that make no sense upstream, such as Determinate version bumps and Determinate release notes, and commits that upstream already has. | ||
|
edolstra marked this conversation as resolved.
|
||
|
|
||
| ## Step 2: Create the branch and worktree | ||
|
|
||
| Create the branch from `origin/master` without tracking it, in a new worktree that is a sibling of the main checkout named `nix-<branch>`. Use the branch name the user supplied, if any. If the directory or branch already exists, pick a different name rather than reusing or deleting anything. Do all further work in that worktree; never touch the one the skill was started from. | ||
|
edolstra marked this conversation as resolved.
|
||
|
|
||
| ## Step 3: Cherry-pick, building and testing along the way | ||
|
|
||
| Cherry-pick without `-x`: Determinate commit hashes mean nothing in the upstream repository. Keep the original author, message and trailers, in particular any `Assisted-by:` trailers, which upstream requires for AI-assisted commits. Do not add trailers of your own. | ||
|
|
||
| After each non-trivial cherry-pick (one that needed conflict resolution, or that is large or touches code that differs upstream), build and run the relevant tests before continuing, so that a problem is found at the commit that causes it. | ||
|
|
||
| Resolve simple conflicts yourself, such as context drift, renamed files, or trivial API differences whose adaptation is obviously correct. Drop hunks that touch Determinate-only files (`.version-determinate`, `doc/manual/source/release-notes-determinate/`); if the change deserves a release note upstream, add one under `doc/manual/rl-next/` instead. Fix small build or test failures caused by a cherry-picked commit by amending that commit. Mention every such intervention in the Step 5 report. | ||
|
|
||
| For a bigger conflict or failure, first investigate whether the change depends on Determinate Nix commits that were never upstreamed. If so, tell the user which commits (and nix-src PRs) they are and why the change needs them, propose upstreaming them as well or first, and wait for the answer. If the problem is something else, for example upstream redesigned the same area, or you are unsure that a resolution preserves the intended behaviour, do not guess: explain the problem and the options you see, and ask how to proceed. | ||
|
|
||
| When done, check that nothing Determinate-specific is left in the diff against `origin/master`. | ||
|
|
||
| ## Step 4: Format and run the full tests | ||
|
|
||
| Run `nix develop -c ./maintainers/format.sh` and fold any changes into the commits that introduced them. Then run `nix build -L .`, which also runs the unit and functional tests; this takes a long time, so run it in the background. | ||
|
edolstra marked this conversation as resolved.
|
||
|
|
||
| Handle failures as in Step 3. A failure that also occurs on `origin/master` is not caused by the change; mention it in the Step 5 report and carry on. | ||
|
|
||
| ## Step 5: Draft the PR description, then stop for review | ||
|
|
||
| Write the PR description to a file, starting from upstream's `.github/PULL_REQUEST_TEMPLATE.md` in the worktree: | ||
|
|
||
| * Put the proposed title on the first line as `Title: ...` so the user can edit it too: the Determinate PR's title, or the commit's subject line. | ||
| * Motivation: reuse the Determinate PR's own description, or summarise the commit messages if there is no PR. Drop anything that only applies to Determinate Nix or that upstream readers cannot see, such as internal ticket references. End with a link to the source, for example `Taken from https://github.com/DeterminateSystems/nix-src/pull/N.` | ||
| * Context: only fill it in when there is something to say. Leave the template's placeholder comments in place otherwise. | ||
| * Do not add any line attributing the PR to an agent or tool ("Generated with", "Co-Authored-By", "Assisted-by"). Upstream requires PR descriptions to be human-authored, which is why the user reviews and edits this draft before it is submitted. | ||
|
edolstra marked this conversation as resolved.
|
||
|
|
||
| Now report to the user and stop. The report must contain: the branch name and worktree path, the cherry-picked commits and any that were left out, conflicts and failures you fixed by hand, the build and test outcome, the path of the draft file, and the draft's contents. Ask the user to review or edit the file and to confirm that the PR may be created. Do not push and do not create the PR until they confirm. | ||
|
|
||
| ## Step 6: After approval, push and create the PR | ||
|
|
||
| Re-read the draft file first, since the user may have edited it, and strip the `Title:` line from the body. Push the branch to `origin` and open the PR with `gh pr create --repo NixOS/nix --base master`. | ||
|
|
||
| Report the PR URL. Mention that the worktree can be removed later with `git worktree remove`. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.