Skip to content

Commit 8cf3eb6

Browse files
chore: update branch protection rules (#1425)
* add matrix build check * All dev and main branches must have policy * Require status checks to pass before merging * Require code owner approvals of all changes in main/master and dev branches * Require re-approval after new commits * add CodeQL check --------- Co-authored-by: Michael Mainer <[email protected]>
1 parent 82b23fc commit 8cf3eb6

File tree

2 files changed

+45
-37
lines changed

2 files changed

+45
-37
lines changed

.github/policies/msgraph-sdk-javascript-branch-protection.yml

+29-35
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ configuration:
1010
branchProtectionRules:
1111

1212
- branchNamePattern: dev
13-
# This branch pattern applies to the following branches as of 06/12/2023 10:31:16:
13+
# This branch pattern applies to the following branches as of 08/30/2023:
1414
# dev
1515

1616
# Specifies whether this branch can be deleted. boolean
@@ -30,14 +30,13 @@ configuration:
3030
# Are commits required to be signed. boolean. TODO: all contributors must have commit signing on local machines.
3131
requiresCommitSignatures: false
3232
# Are conversations required to be resolved before merging? boolean
33-
requiresConversationResolution: false
33+
requiresConversationResolution: true
3434
# Are merge commits prohibited from being pushed to this branch. boolean
3535
requiresLinearHistory: false
3636
# Required status checks to pass before merging. Values can be any string, but if the value does not correspond to any existing status check, the status check will be stuck on pending for status since nothing exists to push an actual status
3737
requiredStatusChecks:
38-
- build (16.x)
39-
- build (18.x)
40-
- build (20.x)
38+
- check-build-matrix
39+
- CodeQL
4140
# Require branches to be up to date before merging. Requires requiredStatusChecks. boolean
4241
requiresStrictStatusChecks: true
4342
# Indicates whether there are restrictions on who can push. boolean. Should be set with whoCanPush.
@@ -46,7 +45,7 @@ configuration:
4645
restrictsReviewDismissals: false
4746

4847
- branchNamePattern: master
49-
# This branch pattern applies to the following branches as of 06/12/2023 10:31:16:
48+
# This branch pattern applies to the following branches as of 08/30/2023:
5049
# master
5150

5251
# Specifies whether this branch can be deleted. boolean
@@ -66,14 +65,13 @@ configuration:
6665
# Are commits required to be signed. boolean. TODO: all contributors must have commit signing on local machines.
6766
requiresCommitSignatures: false
6867
# Are conversations required to be resolved before merging? boolean
69-
requiresConversationResolution: false
68+
requiresConversationResolution: true
7069
# Are merge commits prohibited from being pushed to this branch. boolean
7170
requiresLinearHistory: false
7271
# Required status checks to pass before merging. Values can be any string, but if the value does not correspond to any existing status check, the status check will be stuck on pending for status since nothing exists to push an actual status
7372
requiredStatusChecks:
74-
- build (16.x)
75-
- build (18.x)
76-
- build (20.x)
73+
- check-build-matrix
74+
- CodeQL
7775
# Require branches to be up to date before merging. Requires requiredStatusChecks. boolean
7876
requiresStrictStatusChecks: true
7977
# Indicates whether there are restrictions on who can push. boolean. Should be set with whoCanPush.
@@ -82,30 +80,29 @@ configuration:
8280
restrictsReviewDismissals: false
8381

8482
- branchNamePattern: 3.0.0
85-
# This branch pattern applies to the following branches as of 06/12/2023 10:31:16:
83+
# This branch pattern applies to the following branches as of 08/30/2023:
8684
# 3.0.0
8785

8886
# Specifies whether this branch can be deleted. boolean
8987
allowsDeletions: false
9088
# Specifies whether forced pushes are allowed on this branch. boolean
9189
allowsForcePushes: false
9290
# Specifies whether new commits pushed to the matching branches dismiss pull request review approvals. boolean
93-
dismissStaleReviews: false
91+
dismissStaleReviews: true
9492
# Specifies whether admins can overwrite branch protection. boolean
9593
isAdminEnforced: false
9694
# Require review from Code Owners. Requires requiredApprovingReviewsCount. boolean
97-
requireCodeOwnersReview: false
95+
requireCodeOwnersReview: true
9896
# Are commits required to be signed. boolean. TODO: all contributors must have commit signing on local machines.
9997
requiresCommitSignatures: false
10098
# Are conversations required to be resolved before merging? boolean
101-
requiresConversationResolution: false
99+
requiresConversationResolution: true
102100
# Are merge commits prohibited from being pushed to this branch. boolean
103101
requiresLinearHistory: false
104102
# Required status checks to pass before merging. Values can be any string, but if the value does not correspond to any existing status check, the status check will be stuck on pending for status since nothing exists to push an actual status
105103
requiredStatusChecks:
106-
- build (16.x)
107-
- build (18.x)
108-
- build (20.x)
104+
- check-build-matrix
105+
- CodeQL
109106
# Require branches to be up to date before merging. Requires requiredStatusChecks. boolean
110107
requiresStrictStatusChecks: true
111108
# Indicates whether there are restrictions on who can push. boolean. Should be set with whoCanPush.
@@ -114,34 +111,33 @@ configuration:
114111
restrictsReviewDismissals: false
115112

116113
- branchNamePattern: support/v2
117-
# This branch pattern applies to the following branches as of 06/12/2023 10:31:16:
114+
# This branch pattern applies to the following branches as of 08/30/2023:
118115
# support/v2
119116

120117
# Specifies whether this branch can be deleted. boolean
121118
allowsDeletions: false
122119
# Specifies whether forced pushes are allowed on this branch. boolean
123120
allowsForcePushes: false
124121
# Specifies whether new commits pushed to the matching branches dismiss pull request review approvals. boolean
125-
dismissStaleReviews: false
122+
dismissStaleReviews: true
126123
# Specifies whether admins can overwrite branch protection. boolean
127124
isAdminEnforced: false
128125
# Indicates whether "Require a pull request before merging" is enabled. boolean
129126
requiresPullRequestBeforeMerging: true
130127
# Specifies the number of pull request reviews before merging. int (0-6). Should be null/empty if PRs are not required
131128
requiredApprovingReviewsCount: 1
132129
# Require review from Code Owners. Requires requiredApprovingReviewsCount. boolean
133-
requireCodeOwnersReview: false
130+
requireCodeOwnersReview: true
134131
# Are commits required to be signed. boolean. TODO: all contributors must have commit signing on local machines.
135132
requiresCommitSignatures: false
136133
# Are conversations required to be resolved before merging? boolean
137-
requiresConversationResolution: false
134+
requiresConversationResolution: true
138135
# Are merge commits prohibited from being pushed to this branch. boolean
139136
requiresLinearHistory: false
140137
# Required status checks to pass before merging. Values can be any string, but if the value does not correspond to any existing status check, the status check will be stuck on pending for status since nothing exists to push an actual status
141138
requiredStatusChecks:
142-
- build (16.x)
143-
- build (18.x)
144-
- build (20.x)
139+
- check-build-matrix
140+
- CodeQL
145141
# Require branches to be up to date before merging. Requires requiredStatusChecks. boolean
146142
requiresStrictStatusChecks: true
147143
# Indicates whether there are restrictions on who can push. boolean. Should be set with whoCanPush.
@@ -150,7 +146,7 @@ configuration:
150146
restrictsReviewDismissals: false
151147

152148
- branchNamePattern: v2/dev
153-
# This branch pattern applies to the following branches as of 06/12/2023 10:31:16:
149+
# This branch pattern applies to the following branches as of 08/30/2023:
154150
# v2/dev
155151

156152
# Specifies whether this branch can be deleted. boolean
@@ -175,9 +171,8 @@ configuration:
175171
requiresLinearHistory: false
176172
# Required status checks to pass before merging. Values can be any string, but if the value does not correspond to any existing status check, the status check will be stuck on pending for status since nothing exists to push an actual status
177173
requiredStatusChecks:
178-
- build (16.x)
179-
- build (18.x)
180-
- build (20.x)
174+
- check-build-matrix
175+
- CodeQL
181176
# Require branches to be up to date before merging. Requires requiredStatusChecks. boolean
182177
requiresStrictStatusChecks: false
183178
# Indicates whether there are restrictions on who can push. boolean. Should be set with whoCanPush.
@@ -186,34 +181,33 @@ configuration:
186181
restrictsReviewDismissals: false
187182

188183
- branchNamePattern: main
189-
# This branch pattern applies to the following branches as of 06/12/2023 10:31:16:
184+
# This branch pattern applies to the following branches as of 08/30/2023:
190185
# main
191186

192187
# Specifies whether this branch can be deleted. boolean
193188
allowsDeletions: false
194189
# Specifies whether forced pushes are allowed on this branch. boolean
195190
allowsForcePushes: false
196191
# Specifies whether new commits pushed to the matching branches dismiss pull request review approvals. boolean
197-
dismissStaleReviews: false
192+
dismissStaleReviews: true
198193
# Specifies whether admins can overwrite branch protection. boolean
199194
isAdminEnforced: false
200195
# Indicates whether "Require a pull request before merging" is enabled. boolean
201196
requiresPullRequestBeforeMerging: true
202197
# Specifies the number of pull request reviews before merging. int (0-6). Should be null/empty if PRs are not required
203198
requiredApprovingReviewsCount: 1
204199
# Require review from Code Owners. Requires requiredApprovingReviewsCount. boolean
205-
requireCodeOwnersReview: false
200+
requireCodeOwnersReview: true
206201
# Are commits required to be signed. boolean. TODO: all contributors must have commit signing on local machines.
207202
requiresCommitSignatures: false
208203
# Are conversations required to be resolved before merging? boolean
209-
requiresConversationResolution: false
204+
requiresConversationResolution: true
210205
# Are merge commits prohibited from being pushed to this branch. boolean
211206
requiresLinearHistory: false
212207
# Required status checks to pass before merging. Values can be any string, but if the value does not correspond to any existing status check, the status check will be stuck on pending for status since nothing exists to push an actual status
213208
requiredStatusChecks:
214-
- build (16.x)
215-
- build (18.x)
216-
- build (20.x)
209+
- check-build-matrix
210+
- CodeQL
217211
# Require branches to be up to date before merging. Requires requiredStatusChecks. boolean
218212
requiresStrictStatusChecks: true
219213
# Indicates whether there are restrictions on who can push. boolean. Should be set with whoCanPush.

.github/workflows/ci_validation.yml

+16-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ jobs:
2121
node-version: ${{ matrix.node-version }}
2222
- name: Install dependencies
2323
run: npm ci
24-
24+
2525
- name: Build for node 16, 18 & 20
2626
run: npm run build
27-
27+
2828
- name: Run unit tests
2929
run: npm test
3030

@@ -33,3 +33,17 @@ jobs:
3333
run: |
3434
npm ci
3535
npm test
36+
37+
# The check-build-matrix returns success if all matrix jobs in build are successful; otherwise, it returns a failure.
38+
# Use this as a PR status check for GitHub Policy Service instead of individual matrix entry checks.
39+
check-build-matrix:
40+
runs-on: ubuntu-latest
41+
needs: build
42+
if: always()
43+
steps:
44+
- name: All build matrix options are successful
45+
if: ${{ !(contains(needs.*.result, 'failure')) }}
46+
run: exit 0
47+
- name: One or more build matrix options failed
48+
if: ${{ contains(needs.*.result, 'failure') }}
49+
run: exit 1

0 commit comments

Comments
 (0)