|
| 1 | +# Standard Development Workflow |
| 2 | +This document describes how to contribute to repositories under the Neon AI |
| 3 | +GitHub organization. These best practices help to ensure contributions can be |
| 4 | +efficiently reviewed and accepted by project maintainers while maintaining a |
| 5 | +clear commit history and high standard of quality. |
| 6 | + |
| 7 | +## Branch Naming |
| 8 | +When creating a new branch to work on changes, it is recommended to use the |
| 9 | +format `<type>_<description>`, where <type> is `feat`, `fix`, `doc`, or a |
| 10 | +similar descriptor of the nature of changes being contributed and <description> |
| 11 | +is a brief description in kebab-case. For example, the branch that adds this |
| 12 | +page to documentation is labeled `doc_developer-workflow`. |
| 13 | +> This is similar to [Conventional Branch](https://conventionalbranch.org/), |
| 14 | + though there are cases where `/` in a branch name can cause issues with |
| 15 | + git ref parsing that naively assumes it can segment the complete ref on `/`. |
| 16 | + |
| 17 | +This naming convention is not a hard requirement for submitting changes, but |
| 18 | +it is recommended to help quickly organize and manage branches. Note that |
| 19 | +branch names are case-sensitive, but it is recommended to use lowercase strings |
| 20 | +for consistency and to avoid potential conflicts on file systems that are not |
| 21 | +case-sensitive (i.e. APFS on macOS). |
| 22 | + |
| 23 | +## Committing Changes |
| 24 | +Since PRs will squash the commit history into a single commit on the base branch, |
| 25 | +the feature branch commit history is unimportant. Developers are encouraged to |
| 26 | +commit changes in whatever manner is most efficient for their workflow. |
| 27 | +> [git-scm](https://git-scm.com/docs/git-commit) has a good description of how |
| 28 | + the `git commit` command works and its application. |
| 29 | + |
| 30 | +## Pull Requests |
| 31 | +PRs should always be opened with the repository default branch as the base |
| 32 | +(`dev` in most cases). PR titles should be a short description of changes |
| 33 | +in plain English; for clarity, they should not contain any reference to other |
| 34 | +PR or Issue numbers. |
| 35 | +> More information about Pull Requests can be found in the |
| 36 | + [GitHub Docs](https://docs.github.com/en/pull-requests). |
| 37 | + |
| 38 | +### PR Description |
| 39 | +PR descriptions should use the configured template if present so that changelogs |
| 40 | +and release notes are consistent. Following the template, the Description section should |
| 41 | +include a detailed description of changes; the organization is not specified, so |
| 42 | +this may be a list of changes or a free-form description of the changes. The |
| 43 | +description may include rationale for the changes and design decisions, though |
| 44 | +this is not strictly required; the description should remain focused on the |
| 45 | +changes contained in the PR. |
| 46 | + |
| 47 | +The Issues section should contain a bulleted list of related issues and PRs, |
| 48 | +both in the current repository and other repositories. Any issues that are |
| 49 | +closed by the PR should use the "Closes" keyword so that they are automatically |
| 50 | +closed when the PR is merged. There may be related issues that are not closed, |
| 51 | +but they should still be included here for reference; this helps when reviewing |
| 52 | +issues since related changes will be clearly visible in the issue history. |
| 53 | +> A bulleted list is specified here because GitHub will render more detailed |
| 54 | + links in a bulleted list than it does in a regular text block. |
| 55 | + |
| 56 | +The Other Notes section is available to include any additional information or |
| 57 | +context that is relevant to the PR. This is a good place to include links to |
| 58 | +references, justification of design decisions, edge cases that are handled, or |
| 59 | +any other background information. |
| 60 | + |
| 61 | +This format is not a hard requirement, but it is recommended to help PR |
| 62 | +reviewers quickly understand the changes and to maintain a consistent format |
| 63 | +when reviewing previous changes/releases. |
| 64 | + |
| 65 | +### PR Reviews |
| 66 | +All PRs must receive an approving review before they may be merged with very |
| 67 | +few exceptions. The review process is the most important control that ensures |
| 68 | +we maintain a high standard of quality and that every change properly implements |
| 69 | +its intent. The process for completing a review is described in [Reviewing a Pull Request](./review_pr.md). |
| 70 | + |
| 71 | +When a PR is complete, it should not be marked as a draft and one or more |
| 72 | +reviewers should be requested. If the PR is not complete but a review is still |
| 73 | +desired for feedback on WIP changes, or to discuss design decisions, it is best |
| 74 | +to leave a comment with those specific questions, tagging the reviewer. |
| 75 | + |
| 76 | +### GitHub Actions |
| 77 | +Many repositories have configured automation that runs when a PR is opened or |
| 78 | +commits are added to an open PR. Some of these will not run until the PR is |
| 79 | +marked ready for review, while others will run even on draft PRs. In either |
| 80 | +case, a PR may not be merged until all checks have passed with no exceptions. |
| 81 | + |
| 82 | +### Merging PRs |
| 83 | +A PR is ready to be merged when at least one approving review has been left and |
| 84 | +all checks have passed. If there are any reviews left requesting changes, those |
| 85 | +changes must be addressed and that reviewer must leave an approving review. For |
| 86 | +example, if there are two reviews requesting changes, then both reviewers must |
| 87 | +approve the PR before it may be merged. |
| 88 | + |
| 89 | +Once the PR is ready to be merged, it should be merged using the |
| 90 | +"Squash and Merge" option. This ensures that the commit history of the base |
| 91 | +branch remains clean and that the changes in the PR are represented as a |
| 92 | +single commit with the PT title and description in the commit history. |
| 93 | +> A PR should never be merged with a "Merge Commit" or "Rebase and Merge" as |
| 94 | + this will create a complex commit history on the base branch. With more |
| 95 | + commits, it becomes difficult to parse the commit history and rebasing other |
| 96 | + feature branches is much more difficult. |
| 97 | + |
| 98 | +## Rebasing Branches |
| 99 | +Since multiple PRs may be open at the same time, and merge order is generally |
| 100 | +unknown, it is likely that a PR will need to be rebased on the base branch at |
| 101 | +some point. If a single author has multiple open PRs, they may choose to |
| 102 | +define the merge order by marking PRs as Drafts, or leaving comments in open |
| 103 | +PRs to indicate an intended merge order. |
| 104 | +> The [git-scm Cheat Sheet](https://git-scm.com/cheat-sheet#combine-diverged-branches) |
| 105 | + has a good visual representation of what rebasing does. |
| 106 | + |
| 107 | +### Resolving Conflicts |
| 108 | +When rebasing a branch, it is possible that merge conflicts will arise due to |
| 109 | +changes in the base branch overlapping changes in the feature branch. When this |
| 110 | +happens, the developer performing the rebase must make decisions about how to |
| 111 | +resolve the conflicts. |
| 112 | +> Since these conflicts can be complicated to resolve, it may be best to defer |
| 113 | + to or collaborate with the developer(s) who are responsible for the |
| 114 | + conflicting changes. |
| 115 | + |
| 116 | +Since resolving conflicts is a potentially destructive operation, it is |
| 117 | +recommended to create a backup of the feature branch being rebased; this may |
| 118 | +be done locally or by creating a new branch on GitHub, based on the |
| 119 | +feature branch. With a safe backup in place, resolve the conflicts and complete |
| 120 | +the rebase. |
| 121 | +> Note that because rebasing is basically re-playing each commit on the feature |
| 122 | + branch, there may be changes that need to be resolved where the result does |
| 123 | + not match either the base branch or the feature branch. |
| 124 | + |
| 125 | +Once the rebase is complete, the local feature branch should be force pushed to |
| 126 | +the remote (overwriting the previous branch that lacked recent commits on the |
| 127 | +base branch). In nearly all cases, the PR diff should look identical to what it |
| 128 | +was before the rebase. |
| 129 | + |
| 130 | +### Rebase Tips |
| 131 | +- If rebasing a complex feature branch, it may be easier to squash commits on |
| 132 | + the feature branch before rebasing. This reduces the number of commits that |
| 133 | + need to be rebased and avoids tricky merge conflicts that come up when the |
| 134 | + feature branch has multiple changes to the same chunk of code. |
| 135 | +- If during a rebase you find something has gone wrong, you can always abort |
| 136 | + and try again using `git rebase --abort`. This will return the local branch |
| 137 | + to the state it was before the rebase started. |
| 138 | +- If you find the PR diff has changed in a way you didn't expect after force |
| 139 | + pushing changes, you can look at the backup branch to compare the changes. |
| 140 | + To resolve, you can either start over by using `git reset --hard <backup-branch>` |
| 141 | + to return to the pre-rebase state, or you can create an additional commit to |
| 142 | + manually correct the rebase errors. |
0 commit comments