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

Create default branch protection and start using it #7

Merged
merged 2 commits into from
Oct 25, 2023

Conversation

erikbosch
Copy link
Contributor

@erikbosch erikbosch commented Oct 25, 2023

This PR intends to align KUKSA branch protection, following the same principles that have been discussed in the team:

  • In general have branch protection for all "stable" repositories.
  • A repository is considered "stable" after initial setup/migration is finished, i.e. continuous integration is in place and works as expected. We believe it could be useful to be able to rewrite history in the early days of the lifetime of a repository while it is still in an "experimental phase"

Fixes #4

Not to be merged until approved by either @SebastianSchildt or @lukasmittag

@erikbosch erikbosch requested review from a team as code owners October 25, 2023 07:37
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@netomi
Copy link
Contributor

netomi commented Oct 25, 2023

LGTM, ty for picking this up and your rationale wrt stable repos is absolutely reasonable.

Only applies it to "stable" repos
Copy link
Contributor

@SebastianSchildt SebastianSchildt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@github-actions

This comment has been minimized.

Signed-off-by: Thomas Neidhart <thomas.neidhart@eclipse-foundation.org>
@github-actions
Copy link

Diff for f8ea7f1:
Printing local diff for configuration at '/home/runner/work/.eclipsefdn/.eclipsefdn/otterdog-configs/otterdog.json'

Actions are indicated with the following symbols:
+   create
!   modify
!   forced update
-   delete

Organization eclipse-kuksa[id=eclipse-kuksa]

+   add branch_protection_rule[pattern="main", repository="kuksa-actions"] {
+     allows_deletions                                         = false
+     allows_force_pushes                                      = false
+     blocks_creations                                         = false
+     bypass_force_push_allowances                             = []
+     bypass_pull_request_allowances                           = []
+     dismisses_stale_reviews                                  = true
+     is_admin_enforced                                        = false
+     lock_allows_fetch_and_merge                              = false
+     lock_branch                                              = false
+     pattern                                                  = "main"
+     require_last_push_approval                               = true
+     required_approving_review_count                          = "1"
+     required_status_checks                                   = [
+       "eclipse-eca-validation:eclipsefdn/eca"
+     ],
+     requires_code_owner_reviews                              = false
+     requires_commit_signatures                               = false
+     requires_conversation_resolution                         = false
+     requires_deployments                                     = false
+     requires_linear_history                                  = false
+     requires_pull_request                                    = true
+     requires_status_checks                                   = true
+     requires_strict_status_checks                            = true
+     restricts_pushes                                         = false
+     restricts_review_dismissals                              = false
+   }

  
!   branch_protection_rule[pattern="main", repository="kuksa-hardware"] {
!     dismisses_stale_reviews                                  = false -> true
!     require_last_push_approval                               = false -> true
!     required_approving_review_count                          = "0" -> "1"
!     requires_linear_history                                  = true -> false
!     requires_status_checks                                   = false -> true
!   }

+   add branch_protection_rule[pattern="main", repository="kuksa-viss"] {
+     allows_deletions                                         = false
+     allows_force_pushes                                      = false
+     blocks_creations                                         = false
+     bypass_force_push_allowances                             = []
+     bypass_pull_request_allowances                           = []
+     dismisses_stale_reviews                                  = true
+     is_admin_enforced                                        = false
+     lock_allows_fetch_and_merge                              = false
+     lock_branch                                              = false
+     pattern                                                  = "main"
+     require_last_push_approval                               = true
+     required_approving_review_count                          = "1"
+     required_status_checks                                   = [
+       "eclipse-eca-validation:eclipsefdn/eca"
+     ],
+     requires_code_owner_reviews                              = false
+     requires_commit_signatures                               = false
+     requires_conversation_resolution                         = false
+     requires_deployments                                     = false
+     requires_linear_history                                  = false
+     requires_pull_request                                    = true
+     requires_status_checks                                   = true
+     requires_strict_status_checks                            = true
+     restricts_pushes                                         = false
+     restricts_review_dismissals                              = false
+   }

-   remove branch_protection_rule[pattern="main", repository="kuksa-website"] {
-     allows_deletions                                         = false
-     allows_force_pushes                                      = false
-     blocks_creations                                         = false
-     bypass_force_push_allowances                             = []
-     bypass_pull_request_allowances                           = []
-     dismisses_stale_reviews                                  = false
-     is_admin_enforced                                        = false
-     lock_allows_fetch_and_merge                              = false
-     lock_branch                                              = false
-     pattern                                                  = "main"
-     require_last_push_approval                               = false
-     required_approving_review_count                          = "0"
-     requires_code_owner_reviews                              = false
-     requires_commit_signatures                               = false
-     requires_conversation_resolution                         = false
-     requires_deployments                                     = false
-     requires_linear_history                                  = true
-     requires_pull_request                                    = true
-     requires_status_checks                                   = false
-     restricts_pushes                                         = false
-     restricts_review_dismissals                              = false
-   }

  
!   branch_protection_rule[pattern="master", repository="kuksa-website"] {
!     dismisses_stale_reviews                                  = false -> true
!     require_last_push_approval                               = false -> true
!     required_approving_review_count                          = "0" -> "1"
!     requires_linear_history                                  = true -> false
!     requires_status_checks                                   = false -> true
!   }
  
  Plan: 2 to add, 10 to change, 1 to delete.
Showing diff to a canonical version of the configuration at '/home/runner/work/.eclipsefdn/.eclipsefdn/otterdog-configs/otterdog.json'

Organization eclipse-kuksa[id=eclipse-kuksa]
--- original
+++ canonical
@@ -1,17 +1,22 @@
 local orgs = import 'vendor/otterdog-defaults/otterdog-defaults.libsonnet';
 
+
+local kuksa_default_branch_protection_rule(pattern) =
+  orgs.newBranchProtectionRule(pattern) {
+
+
+        dismisses_stale_reviews: true
+        require_last_push_approval: true
+        required_approving_review_count: 1
+        requires_strict_status_checks: true
+  };
 orgs.newOrg('eclipse-kuksa') {
   _repositories+:: [
     orgs.newRepo('kuksa-actions') {
       allow_merge_commit: true
       allow_update_branch: false
       branch_protection_rules: [
-        orgs.newBranchProtectionRule('main') {
-          dismisses_stale_reviews: true
-          require_last_push_approval: true
-          required_approving_review_count: 1
-          requires_strict_status_checks: true
-        }
+        kuksa_default_branch_protection_rule('main')
       ]
       delete_branch_on_merge: false
       dependabot_security_updates_enabled: true
@@ -26,12 +31,7 @@
       allow_squash_merge: false
       allow_update_branch: false
       branch_protection_rules: [
-        orgs.newBranchProtectionRule('main') {
-          dismisses_stale_reviews: true
-          require_last_push_approval: true
-          required_approving_review_count: 1
-          requires_strict_status_checks: true
-        }
+        kuksa_default_branch_protection_rule('main')
       ]
       dependabot_security_updates_enabled: true
       web_commit_signoff_required: false
@@ -53,12 +53,7 @@
       allow_merge_commit: true
       allow_update_branch: false
       branch_protection_rules: [
-        orgs.newBranchProtectionRule('main') {
-          dismisses_stale_reviews: true
-          require_last_push_approval: true
-          required_approving_review_count: 1
-          requires_strict_status_checks: true
-        }
+        kuksa_default_branch_protection_rule('main')
       ]
       delete_branch_on_merge: false
       dependabot_alerts_enabled: false
@@ -73,12 +68,7 @@
       allow_merge_commit: true
       allow_update_branch: false
       branch_protection_rules: [
-        orgs.newBranchProtectionRule('main') {
-          dismisses_stale_reviews: true
-          require_last_push_approval: true
-          required_approving_review_count: 1
-          requires_strict_status_checks: true
-        }
+        kuksa_default_branch_protection_rule('main')
       ]
       delete_branch_on_merge: false
       dependabot_security_updates_enabled: true
@@ -91,12 +81,7 @@
       allow_merge_commit: true
       allow_update_branch: false
       branch_protection_rules: [
-        orgs.newBranchProtectionRule('master') {
-          dismisses_stale_reviews: true
-          require_last_push_approval: true
-          required_approving_review_count: 1
-          requires_strict_status_checks: true
-        }
+        kuksa_default_branch_protection_rule('master')
       ]
       default_branch: "master"
       delete_branch_on_merge: false

@netomi netomi merged commit 98059a3 into eclipse-kuksa:main Oct 25, 2023
1 check passed
@netomi
Copy link
Contributor

netomi commented Oct 25, 2023

changes are live.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding branch protection rules
3 participants