Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SDK-PR-guide.md to include branch lockdown label #46337

Merged
merged 22 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
97ee262
Update SDK-PR-guide.md
marcpopMSFT Jan 27, 2025
e416b3f
Create add-lockdown-label.yml
marcpopMSFT Jan 30, 2025
1be0fe8
add a PR trigger so I can test this
marcpopMSFT Jan 30, 2025
c53738d
Fix date calculation for first and third Tuesdays
marcpopMSFT Jan 30, 2025
e18f6ef
Add debug logs and filter PRs
marcpopMSFT Jan 30, 2025
9c7aee9
Add debug logs for PR filtering process
marcpopMSFT Jan 30, 2025
98b49a6
Fix PR filtering by baseRefName instead of headRefName
marcpopMSFT Jan 30, 2025
d9c204a
Update title and permissions
marcpopMSFT Jan 30, 2025
3ac24ae
Increase PR list query limit to 200
marcpopMSFT Jan 30, 2025
806cf97
Update PR filtering and labeling logic
marcpopMSFT Jan 30, 2025
a07c8a7
Update cron schedule and permissions in workflow
marcpopMSFT Jan 31, 2025
e95584d
Remove pull_request_target and pull-requests permissions
marcpopMSFT Jan 31, 2025
81dea14
Modify the logic to run on the PR creation and apply to all PRs to th…
marcpopMSFT Jan 31, 2025
1b9ef97
Update branch lockdown label workflow
marcpopMSFT Jan 31, 2025
eea957e
Improve branch matching and logging in workflow
marcpopMSFT Jan 31, 2025
e97abbd
Change event trigger to pull_request_target
marcpopMSFT Jan 31, 2025
6853c57
Remove jq installation from workflow
marcpopMSFT Jan 31, 2025
e70b0e8
Update workflow to add jq installation and PR filtering
marcpopMSFT Feb 3, 2025
34eb88c
Remove debug echo statements from workflow
marcpopMSFT Feb 3, 2025
850d7ab
Update workflow to use pull_request_target
marcpopMSFT Feb 3, 2025
beea8d6
Update workflow to add permissions and increase PR limit
marcpopMSFT Feb 13, 2025
3927b24
Remove author filter from PR query
marcpopMSFT Feb 13, 2025
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
78 changes: 78 additions & 0 deletions .github/workflows/add-lockdown-label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Add Branch Lockdown Label to PRs

on:
schedule:
# Run daily at 00:00 UTC
- cron: '0 23 * * *'
workflow_dispatch: # Allows manual triggering of the workflow

permissions:
actions: write # For managing the operation state cache
issues: write

jobs:
add-label:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install jq
run: sudo apt-get install -y jq

- name: Add label to PRs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Determine the third Tuesday of the current month
third_tuesday=$(date -d "$(date +%Y-%m-01) +14 days" +%Y-%m-%d)
while [ $(date -d "$third_tuesday" +%u) -ne 2 ]; do
third_tuesday=$(date -d "$third_tuesday + 1 day" +%Y-%m-%d)
done

# Determine the first Tuesday of the current month
first_tuesday=$(date -d "$(date +%Y-%m-01)" +%Y-%m-%d)
while [ $(date -d "$first_tuesday" +%u) -ne 2 ]; do
first_tuesday=$(date -d "$first_tuesday + 1 day" +%Y-%m-%d)
done

# Get current date
current_date=$(date +%Y-%m-%d)

echo "Current Date: $current_date"
echo "Third Tuesday of the month: $third_tuesday"
echo "First Tuesday of the month: $first_tuesday"

# Check if the current date is after the third Tuesday of this month or before the first Tuesday of this month
if [[ "$current_date" > "$third_tuesday" || "$current_date" < "$first_tuesday" ]]; then
echo "Within the label period. Adding labels to PRs..."

# Get all open PRs created by app/dotnet-maestro and targeting branches release/8* and release/9* excluding release/9.0.3xx
echo "Running gh pr list query..."
prs=$(gh pr list --state open --limit 100 --json number,baseRefName,author,labels)
echo "Total PRs Count: $(echo "$prs" | jq length)"
echo "PRs JSON: $prs"

echo "Filtering PRs created by app/dotnet-maestro..."
prs_by_author=$(echo "$prs" | jq '[.[] | select(.author.login == "app/dotnet-maestro")]')
echo "PRs by app/dotnet-maestro JSON: $prs_by_author"
echo "Count of PRs by app/dotnet-maestro: $(echo "$prs_by_author" | jq length)"

echo "Filtering PRs targeting release/8* and release/9* excluding release/9.0.3xx..."
prs_targeting_branches=$(echo "$prs_by_author" | jq '[.[] | select(.baseRefName | test("^release/[89].*")) | select(.baseRefName | test("^release/9.0.3xx") | not)]')
echo "Filtered PRs targeting specific branches JSON: $prs_targeting_branches"
echo "Count of PRs targeting specific branches: $(echo "$prs_targeting_branches" | jq length)"

echo "Filtering PRs without Branch Lockdown label..."
filtered_prs=$(echo "$prs_targeting_branches" | jq '[.[] | select(.labels | map(.name) | index("Branch Lockdown") | not) | .number]')
echo "Filtered PRs without Branch Lockdown label JSON: $filtered_prs"
echo "Count of Filtered PRs without Branch Lockdown label: $(echo "$filtered_prs" | jq length)"

# Loop through filtered PRs and add label
for pr in $(echo "$filtered_prs" | jq -r '.[]'); do
echo "Adding label to PR #$pr"
gh pr edit $pr --add-label "Branch Lockdown"
done
else
echo "Outside the label period. No labels added."
fi
4 changes: 2 additions & 2 deletions documentation/project-docs/SDK-PR-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ After the minor release locks down, it transitions into servicing / "QB" (Quarte
### Servicing releases
The .NET SDK has monthly servicing releases (e.g.`7.0.100` VS `7.0.101`) aligning with the .NET Runtime servicing releases. These are for top fixes and security updates only to limit risk.
Any servicing release is open for check-ins from the day the [branding PRs](https://github.com/dotnet/sdk/pulls?q=is%3Apr+branding) are merged (~1st of each month) and when code complete is (typically two weeks later).
The servicing branches are locked from the time of code complete to the next branding in case we need to respin any monthly release. Final signoffs are typically in the last week of each month.
The servicing branches are locked from the time of code complete to the next branding in case we need to respin any monthly release. We use the `Branch Lockdown` label to mark PRs that should go into the next servicing release but the branch is currently not open. Final signoffs are typically in the last week of each month.

### Schedule
| Release Type | Frequency | Lockdown Release | Branch Open | Lockdown Date (estimate) |
Expand All @@ -36,7 +36,7 @@ The servicing branches are locked from the time of code complete to the next bra
| Servicing | Monthly | N/A | After branding, ~1st of the month | Third Tuesday of prior month (signoff is ~28th of each month) |

### Tactics approval
Even releases that are in lockdown can still take changes as long as they are approved and the final build isn't complete. To bring a change through tactics, mark it with the label servicing-consider and update the description to include 5 sections (Description, Customer Impact, Regression?, Risk, Testing). See previously approved bugs for examples by looking for the [servicing-approved](https://github.com/dotnet/sdk/pulls?q=is%3Apr+label%3AServicing-approved+is%3Aclosed) label.
Even releases that are in lockdown can still take changes as long as they are approved and the final build isn't complete. To bring a change through tactics, mark it with the label `servicing-consider` and update the description to include 5 sections (Description, Customer Impact, Regression?, Risk, Testing). See previously approved bugs for examples by looking for the [servicing-approved](https://github.com/dotnet/sdk/pulls?q=is%3Apr+label%3AServicing-approved+is%3Aclosed) label.

## External contributions
External contributions are encouraged and welcome. There are so many teams working in this repo that it can be hard to track. Contributors looking to learn more about how to contribute should check out the [Developer Guide](https://github.com/dotnet/sdk/blob/main/documentation/project-docs/developer-guide.md).
Expand Down
Loading