From 0c14c7c1be571e930e588b750846762a6219a609 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 13 Jan 2025 15:13:45 -0500 Subject: [PATCH] ci: adds branch policy definition Signed-off-by: Vincent Biret --- .../policies/kiota-dart-branch-protection.yml | 37 +++++++++++++++++++ .github/workflows/dart.yml | 27 ++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 .github/policies/kiota-dart-branch-protection.yml diff --git a/.github/policies/kiota-dart-branch-protection.yml b/.github/policies/kiota-dart-branch-protection.yml new file mode 100644 index 0000000..46209e3 --- /dev/null +++ b/.github/policies/kiota-dart-branch-protection.yml @@ -0,0 +1,37 @@ +name: kiota-dart-branch-protection +description: Branch protection policy for the kiota-dart repository +resource: repository +configuration: + branchProtectionRules: + - branchNamePattern: main + # Specifies whether this branch can be deleted. boolean + allowsDeletions: false + # Specifies whether forced pushes are allowed on this branch. boolean + allowsForcePushes: false + # Specifies whether new commits pushed to the matching branches dismiss pull request review approvals. boolean + dismissStaleReviews: true + # Specifies whether admins can overwrite branch protection. boolean + isAdminEnforced: false + # Indicates whether "Require a pull request before merging" is enabled. boolean + requiresPullRequestBeforeMerging: true + # Specifies the number of pull request reviews before merging. int (0-6). Should be null/empty if PRs are not required + requiredApprovingReviewsCount: 1 + # Require review from Code Owners. Requires requiredApprovingReviewsCount. boolean + requireCodeOwnersReview: true + # Are commits required to be signed. boolean. + requiresCommitSignatures: true + # Are conversations required to be resolved before merging? boolean + requiresConversationResolution: true + # Are merge commits prohibited from being pushed to this branch. boolean + requiresLinearHistory: false + # 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 + requiredStatusChecks: + - license/cla + - check-test + - check-static-analysis + # Require branches to be up to date before merging + requiresStrictStatusChecks: true + # Indicates whether there are restrictions on who can push. boolean. Should be set with whoCanPush. + restrictsPushes: false + # Restrict who can dismiss pull request reviews. boolean + restrictsReviewDismissals: false \ No newline at end of file diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 6160ab7..b4f85ed 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -70,6 +70,19 @@ jobs: run: dart analyze --fatal-infos working-directory: packages/${{ matrix.package }} + # Aggregates result of the static-analysis tests for use in branch policy + check-static-analysis: + runs-on: ubuntu-latest + needs: static-analysis + if: always() + steps: + - name: All build matrix options are successful + if: ${{ !(contains(needs.*.result, 'failure')) }} + run: exit 0 + - name: One or more build matrix options failed + if: ${{ contains(needs.*.result, 'failure') }} + run: exit 1 + test: runs-on: ubuntu-latest needs: define-matrix @@ -105,3 +118,17 @@ jobs: - name: Run tests run: dart test working-directory: packages/${{ matrix.package }} + + + # Aggregates result of the test tests for use in branch policy + check-test: + runs-on: ubuntu-latest + needs: test + if: always() + steps: + - name: All build matrix options are successful + if: ${{ !(contains(needs.*.result, 'failure')) }} + run: exit 0 + - name: One or more build matrix options failed + if: ${{ contains(needs.*.result, 'failure') }} + run: exit 1 \ No newline at end of file