Skip to content

Commit bd7a7c1

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

File tree

6 files changed

+174
-11
lines changed

6 files changed

+174
-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: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
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+
echo "🔍 Finding feature branches..."
47+
48+
# Get all remote feature branches
49+
feature_branches=$(git branch -r | grep 'origin/feature/' | sed 's|origin/||' | grep -v HEAD || true)
50+
51+
if [ -z "$feature_branches" ]; then
52+
echo "ℹ️ No feature branches found matching pattern 'feature/*'"
53+
exit 0
54+
fi
55+
56+
echo "Found feature branches:"
57+
echo "$feature_branches"
58+
echo ""
59+
60+
# Process each feature branch
61+
for branch in $feature_branches; do
62+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
63+
echo "📋 Processing branch: $branch"
64+
65+
# Check if main has commits not in the feature branch
66+
git fetch origin main
67+
git fetch origin "$branch"
68+
69+
commits_behind=$(git rev-list --count origin/$branch..origin/main)
70+
71+
if [ "$commits_behind" -eq 0 ]; then
72+
echo "✅ Branch $branch is already up to date with main"
73+
continue
74+
fi
75+
76+
echo "📊 Branch $branch is $commits_behind commit(s) behind main"
77+
78+
# Extract issue number from branch name (format: feature/PROJ-NNN-short-slug)
79+
# If no PROJ-NNN pattern is found, use "Issue - None"
80+
issue_number=$(echo "$branch" | grep -oE 'PROJ-[0-9]+' || echo "")
81+
if [ -z "$issue_number" ]; then
82+
issue_ref="Issue - None"
83+
else
84+
issue_ref="Issue #$issue_number"
85+
fi
86+
87+
# Create a temporary branch for the merge
88+
temp_branch="sync-main-to-${branch//\//-}-$(date +%Y%m%d)"
89+
90+
echo "🌿 Creating temporary branch: $temp_branch"
91+
git checkout -b "$temp_branch" "origin/$branch"
92+
93+
# Attempt to merge main
94+
echo "🔀 Merging main into $temp_branch..."
95+
if git merge origin/main --no-edit -m "Merge main into $branch"; then
96+
echo "✅ Merge successful (no conflicts)"
97+
else
98+
echo "⚠️ Merge has conflicts - will create PR for manual resolution"
99+
# Abort the merge but keep the branch
100+
git merge --abort
101+
# Create a merge commit that preserves conflict markers
102+
git merge origin/main --no-commit --no-ff || true
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+
)" || echo "⚠️ Failed to create PR for $branch"
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!"
151+
152+
- name: Summary
153+
if: always()
154+
run: |
155+
echo "### Sync Feature Branches Summary" >> $GITHUB_STEP_SUMMARY
156+
echo "" >> $GITHUB_STEP_SUMMARY
157+
echo "Workflow completed. Check the logs above for details on each feature branch." >> $GITHUB_STEP_SUMMARY

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)