Skip to content

Commit baaccf2

Browse files
169 - Add feature branching strategy for projects.
1 parent 82004ac commit baaccf2

File tree

6 files changed

+167
-11
lines changed

6 files changed

+167
-11
lines changed

.github/workflows/docs-deploy.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ name: Docs Deployment
2020
on:
2121
# Runs on pushes targeting the main branch
2222
push:
23-
branches:
24-
- main
23+
branches: [ main, 'feature/**' ]
2524
paths:
2625
- 'docs/**'
2726
- 'workflows/**'

.github/workflows/helm-chart-lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ on:
2020
workflow_dispatch:
2121
pull_request:
2222
types: [opened, synchronize, reopened]
23-
branches: [main]
23+
branches: [ main, 'feature/**' ]
2424
paths:
2525
- 'deployments/charts/**'
2626
- '.github/workflows/helm-chart-lint.yaml'

.github/workflows/pr-checks.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ on:
2020
workflow_dispatch:
2121
pull_request:
2222
types: [opened, synchronize, reopened, closed]
23-
branches: [ main ]
23+
branches: [ main, 'feature/**' ]
2424

2525
concurrency:
2626
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}

.github/workflows/pr-description-check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ name: PR Description Check
1919
on:
2020
pull_request:
2121
types: [opened, synchronize, reopened, edited]
22-
branches: [main]
22+
branches: [ main, 'feature/**' ]
2323

2424
concurrency:
2525
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# SPDX-License-Identifier: Apache-2.0
16+
17+
name: Sync Feature Branches
18+
19+
on:
20+
workflow_dispatch:
21+
schedule:
22+
# Run every Monday at 9am PT (5pm UTC)
23+
- cron: '0 17 * * 1'
24+
25+
jobs:
26+
sync-feature-branches:
27+
runs-on: ubuntu-latest
28+
permissions:
29+
contents: write
30+
pull-requests: write
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@v4
34+
with:
35+
fetch-depth: 0 # Fetch all branches and history
36+
37+
- name: Configure Git
38+
run: |
39+
git config user.name "github-actions[bot]"
40+
git config user.email "github-actions[bot]@users.noreply.github.com"
41+
42+
- name: Find and sync feature branches
43+
env:
44+
GH_TOKEN: ${{ github.token }}
45+
run: |
46+
set -e
47+
48+
echo "🔍 Finding feature branches..."
49+
50+
# Get all remote feature branches
51+
feature_branches=$(git branch -r | grep 'origin/feature/' | sed 's|origin/||' | grep -v HEAD || true)
52+
53+
if [ -z "$feature_branches" ]; then
54+
echo "ℹ️ No feature branches found matching pattern 'feature/*'"
55+
exit 0
56+
fi
57+
58+
echo "Found feature branches:"
59+
echo "$feature_branches"
60+
echo ""
61+
62+
# Process each feature branch
63+
for branch in $feature_branches; do
64+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
65+
echo "📋 Processing branch: $branch"
66+
67+
# Check if main has commits not in the feature branch
68+
git fetch origin main
69+
git fetch origin "$branch"
70+
71+
commits_behind=$(git rev-list --count origin/$branch..origin/main)
72+
73+
if [ "$commits_behind" -eq 0 ]; then
74+
echo "✅ Branch $branch is already up to date with main"
75+
continue
76+
fi
77+
78+
echo "📊 Branch $branch is $commits_behind commit(s) behind main"
79+
80+
# Extract issue number from branch name (format: feature/PROJ-NNN-short-slug)
81+
# If no PROJ-NNN pattern is found, use "Issue - None"
82+
issue_number=$(echo "$branch" | grep -oE 'PROJ-[0-9]+' || echo "")
83+
if [ -z "$issue_number" ]; then
84+
issue_ref="Issue - None"
85+
else
86+
issue_ref="Issue #$issue_number"
87+
fi
88+
89+
# Create a temporary branch for the merge
90+
temp_branch="sync/$branch/$(date +%Y%m%d-%H%M)"
91+
92+
echo "🌿 Creating temporary branch: $temp_branch"
93+
git checkout -b "$temp_branch" "origin/$branch"
94+
95+
# Attempt to merge main
96+
echo "🔀 Merging main into $temp_branch..."
97+
if git merge origin/main --no-commit --no-ff; then
98+
echo "✅ Merge successful (no conflicts)"
99+
else
100+
echo "⚠️ Merge has conflicts - will create PR for manual resolution"
101+
git add -A
102+
git commit -m "Merge main into $branch"
103+
fi
104+
105+
# Push the temporary branch
106+
echo "⬆️ Pushing $temp_branch to remote..."
107+
git push origin "$temp_branch"
108+
109+
# Create PR
110+
echo "📝 Creating pull request..."
111+
112+
gh pr create \
113+
--base "$branch" \
114+
--head "$temp_branch" \
115+
--title "Sync main into $branch" \
116+
--body "$(cat <<EOF
117+
## Description
118+
119+
This automated PR merges the latest changes from \`main\` into \`$branch\`.
120+
121+
**What to do:**
122+
Review the changes and merge this PR to keep your feature branch up to date with main. If there are merge conflicts, resolve them before merging.
123+
124+
**Branch Info:**
125+
- **Target**: \`$branch\`
126+
- **Source**: \`main\`
127+
- **Commits behind**: $commits_behind
128+
129+
$issue_ref
130+
131+
## Checklist
132+
- [ ] I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/OSMO/blob/main/CONTRIBUTING.md).
133+
- [ ] New or existing tests cover these changes.
134+
- [ ] The documentation is up to date with these changes.
135+
136+
---
137+
*This PR was automatically created by the [Sync Feature Branches workflow](.github/workflows/sync-feature-branches.yaml) as part of the [Projects Process](../projects/README.md#stage-in-development).*
138+
EOF
139+
)"
140+
141+
echo "✅ Created PR to sync main into $branch"
142+
143+
# Switch back to main for next iteration
144+
git checkout main
145+
146+
done
147+
148+
echo ""
149+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
150+
echo "✨ Sync process complete!"

projects/README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,21 @@ For proposals that are significant or complex, a project design document provide
125125
1. **Create sub-issues** – Break the project into concrete tasks and open sub-issues for each.
126126
- Use the implementation plan from the project design to organize work.
127127

128-
2. **Submit pull requests** – Implement the project in PRs, linking back to the relevant issues.
129-
- Reference the project proposal in PR descriptions for context.
128+
2. **Track progress** – OSMO team updates the **Stage** field to **Stage: In Development** in the Projects project board.
130129

131-
3. **Update the project design** – As implementation progresses, update the project design document if decisions change or new details emerge.
132-
- Submit PRs to update the design document as needed.
130+
3. **Create a feature branch** - Work in a feature branch to keep `main` clean during feature development.
131+
- Create the feature branch with the naming `feature/PROJ-NNN-short-slug`. Use the same name as your [Design (Markdown)](#stage-design-markdown).
132+
- If your feature can be completed in a single, reasonably-sized PR, this project process may be unecessary. Use your discretion about whether a feature branch is necessary, and feel free to ask the OSMO team in your proposal issue.
133+
134+
4. **Submit pull requests** – Implement the project in PRs against your feature branch.
135+
- Reference the sub-issues in PR descriptions for context.
133136

134-
4. **Track progress** – OSMO team updates the **Stage** field to **Stage: In Development** in the Projects project board.
135-
- Create sub-issues and link them to PRs for visibility.
137+
5. **Merge `main`** - Keep your feature branch compatible with `main` by merging `main` into your feature branch with a PR.
138+
- PRs will be opened weekly on Monday by automation to merge the latest `main` into the feature branch.
139+
- Resolve any merge conflicts you encounter and merge into your feature branch.
140+
141+
5. **Update the project design** – As implementation progresses, update the project design document if decisions change or new details emerge.
142+
- Submit PRs to update the design document as needed.
136143

137144
### Stage: Shipped
138145

0 commit comments

Comments
 (0)