forked from tokamak-network/tokamak-sybil-resistance
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
380 additions
and
430 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"id": 2539891, | ||
"name": "syb_develop_ruleset", | ||
"target": "branch", | ||
"source_type": "Repository", | ||
"source": "tokamak-network/tokamak-sybil-resistance-mvp", | ||
"enforcement": "active", | ||
"conditions": { | ||
"ref_name": { | ||
"exclude": [], | ||
"include": [ | ||
"refs/heads/develop" | ||
] | ||
} | ||
}, | ||
"rules": [ | ||
{ | ||
"type": "deletion" | ||
}, | ||
{ | ||
"type": "non_fast_forward" | ||
}, | ||
{ | ||
"type": "pull_request", | ||
"parameters": { | ||
"required_approving_review_count": 1, | ||
"dismiss_stale_reviews_on_push": true, | ||
"require_code_owner_review": true, | ||
"require_last_push_approval": false, | ||
"required_review_thread_resolution": true, | ||
"automatic_copilot_code_review_enabled": false | ||
} | ||
} | ||
], | ||
"bypass_actors": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"id": 2539902, | ||
"name": "syb_main_ruleset", | ||
"target": "branch", | ||
"source_type": "Repository", | ||
"source": "tokamak-network/tokamak-sybil-resistance-mvp", | ||
"enforcement": "active", | ||
"conditions": { | ||
"ref_name": { | ||
"exclude": [], | ||
"include": [ | ||
"refs/heads/main" | ||
] | ||
} | ||
}, | ||
"rules": [ | ||
{ | ||
"type": "deletion" | ||
}, | ||
{ | ||
"type": "non_fast_forward" | ||
}, | ||
{ | ||
"type": "required_linear_history" | ||
}, | ||
{ | ||
"type": "pull_request", | ||
"parameters": { | ||
"required_approving_review_count": 2, | ||
"dismiss_stale_reviews_on_push": true, | ||
"require_code_owner_review": true, | ||
"require_last_push_approval": false, | ||
"required_review_thread_resolution": true, | ||
"automatic_copilot_code_review_enabled": false | ||
} | ||
} | ||
], | ||
"bypass_actors": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"id": 3085803, | ||
"name": "syb_refactor_ruleset", | ||
"target": "branch", | ||
"source_type": "Repository", | ||
"source": "tokamak-network/tokamak-sybil-resistance-mvp", | ||
"enforcement": "active", | ||
"conditions": { | ||
"ref_name": { | ||
"exclude": [], | ||
"include": [ | ||
"refs/heads/refactor" | ||
] | ||
} | ||
}, | ||
"rules": [ | ||
{ | ||
"type": "deletion" | ||
}, | ||
{ | ||
"type": "non_fast_forward" | ||
}, | ||
{ | ||
"type": "pull_request", | ||
"parameters": { | ||
"required_approving_review_count": 1, | ||
"dismiss_stale_reviews_on_push": true, | ||
"require_code_owner_review": false, | ||
"require_last_push_approval": false, | ||
"required_review_thread_resolution": true, | ||
"automatic_copilot_code_review_enabled": true, | ||
"allowed_merge_methods": [ | ||
"merge", | ||
"squash", | ||
"rebase" | ||
] | ||
} | ||
} | ||
], | ||
"bypass_actors": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import os | ||
import subprocess | ||
import requests # will be installed during the github action run | ||
|
||
# Environment variables | ||
GIT_TOKEN = os.getenv('GIT_TOKEN') | ||
SLACK_WEBHOOK_URL = os.getenv('SLACK_WEBHOOK_URL') | ||
|
||
# Git commands | ||
remote_branches_command = "git branch -r --merged origin/develop" | ||
delete_branch_command = "git push origin --delete {}" | ||
|
||
# Execute git command to get merged branches | ||
result = subprocess.run(remote_branches_command.split(), capture_output=True, text=True) | ||
merged_branches = result.stdout.splitlines() | ||
|
||
# Filter out specific branches | ||
branches_to_delete = [branch.strip() for branch in merged_branches if branch.strip() not in ['origin/develop', 'origin/main', 'origin/refactor']] | ||
|
||
# Delete branches and collect deleted branch names | ||
deleted_branches = [] | ||
for branch in branches_to_delete: | ||
branch_name = branch.replace('origin/', '') | ||
delete_result = subprocess.run(delete_branch_command.format(branch_name).split(), capture_output=True, text=True) | ||
if delete_result.returncode == 0: | ||
deleted_branches.append(branch_name) | ||
|
||
# Send Slack message | ||
if deleted_branches: | ||
message = f"The following branches have been deleted:\n" + "\n".join(deleted_branches) | ||
payload = {"text": message} | ||
response = requests.post(SLACK_WEBHOOK_URL, json=payload) | ||
if response.status_code != 200: | ||
raise ValueError(f"Request to Slack returned an error {response.status_code}, the response is:\n{response.text}") | ||
else: | ||
message = "No branches to delete." | ||
payload = {"text": message} | ||
response = requests.post(SLACK_WEBHOOK_URL, json=payload) | ||
if response.status_code != 200: | ||
raise ValueError(f"Request to Slack returned an error {response.status_code}, the response is:\n{response.text}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Cleanup Merged Branches | ||
|
||
on: | ||
schedule: | ||
- cron: '0 0 * * 0' # Runs every Sunday at midnight | ||
workflow_dispatch: | ||
|
||
jobs: | ||
cleanup: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install dependencies | ||
run: pip install requests | ||
|
||
- name: Run cleanup script | ||
env: | ||
GIT_TOKEN: ${{ secrets.GIT_TOKEN }} | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
run: python .github/scripts/cleanup_merged_branches.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Launch Package", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "auto", | ||
"program": "${fileDirname}" | ||
}, | ||
{ | ||
"name": "Run Synchronizer Tests", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "test", | ||
"program": "${workspaceFolder}/sequencer/synchronizer", | ||
"envFile": "${workspaceFolder}/sequencer/.env", | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"solidity.compileUsingRemoteVersion": "v0.8.23+commit.f704f362" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.