mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
actions: introduce handle_potential_conflicts.py to only warn on true conflicts. Fail CI when there is a conflict (#4655)
* introduce handle_potential_conflicts.py to only warn on true conflicts. Fail CI when there is a conflict Signed-off-by: Pasta <pasta@dashboost.org> * remove unneeded input assign Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com> * use dashpay instead of PastaPastaPasta Signed-off-by: Pasta <pasta@dashboost.org> * Update .github/workflows/handle_potential_conflicts.py Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com> * more linter fixes Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
This commit is contained in:
parent
22f335e268
commit
f3cd4046c9
58
.github/workflows/handle_potential_conflicts.py
vendored
Normal file
58
.github/workflows/handle_potential_conflicts.py
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
import sys
|
||||
import requests
|
||||
|
||||
# need to install via pip
|
||||
import hjson
|
||||
|
||||
'''Looks like'''
|
||||
'''{ pull_number: 26,
|
||||
conflictPrs:
|
||||
[ { number: 25,
|
||||
files: [ '.github/workflows/testfile' ],
|
||||
conflicts: [ '.github/workflows/testfile' ] }
|
||||
{ number: 24,
|
||||
files: [ '.github/workflows/testfile' ],
|
||||
conflicts: [ '.github/workflows/testfile' ] } ] }'''
|
||||
|
||||
def main():
|
||||
input = sys.argv[1]
|
||||
print(input)
|
||||
j_input = hjson.loads(input)
|
||||
print(j_input)
|
||||
|
||||
|
||||
our_pr_num = j_input['pull_number']
|
||||
our_pr_label = get_label(our_pr_num)
|
||||
conflictPrs = j_input['conflictPrs']
|
||||
|
||||
good = []
|
||||
bad = []
|
||||
|
||||
for conflict in conflictPrs:
|
||||
this_pr_num = conflict['number']
|
||||
print(this_pr_num)
|
||||
|
||||
r = requests.get(f'https://api.github.com/repos/dashpay/dash/pulls/{conflict["number"]}')
|
||||
print(r.json()['head']['label'])
|
||||
r = requests.get(f'https://github.com/dashpay/dash/branches/pre_mergeable/{our_pr_label}...{get_label(this_pr_num)}')
|
||||
if "These branches can be automatically merged." in r.text:
|
||||
good.append(this_pr_num)
|
||||
elif "Can’t automatically merge" in r.text:
|
||||
bad.append(this_pr_num)
|
||||
else:
|
||||
raise Exception("not mergeable or unmergable!")
|
||||
|
||||
print("Not conflicting PRs: ", good)
|
||||
|
||||
print("Conflicting PRs: ", bad)
|
||||
if len(bad) > 0:
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
|
||||
def get_label(pr_num):
|
||||
return requests.get(f'https://api.github.com/repos/dashpay/dash/pulls/{pr_num}').json()['head']['label']
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
10
.github/workflows/predict-conflicts.yml
vendored
10
.github/workflows/predict-conflicts.yml
vendored
@ -1,5 +1,7 @@
|
||||
name: "Check Potential Conflicts"
|
||||
on: pull_request_target
|
||||
on:
|
||||
- pull_request_target
|
||||
- pull_request_review
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
@ -18,7 +20,9 @@ jobs:
|
||||
main:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: check potential conflicts
|
||||
uses: PastaPastaPasta/potential-conflicts-checker-action@0.1.1
|
||||
- name: check for potential conflicts
|
||||
uses: PastaPastaPasta/potential-conflicts-checker-action@0.1.9
|
||||
with:
|
||||
ghToken: "${{ secrets.GITHUB_TOKEN }}"
|
||||
- name: validate potential conflicts
|
||||
run: wget https://raw.githubusercontent.com/dashpay/dash/develop/.github/workflows/handle_potential_conflicts.py && pip3 install hjson && python3 handle_potential_conflicts.py "$conflicts"
|
||||
|
Loading…
Reference in New Issue
Block a user