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

Chore conflicts py #14

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 24 additions & 15 deletions .github/workflows/handle_potential_conflicts.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,23 +1,37 @@
# Copyright (c) 2022 The Dash Core developers
#!/usr/bin/env python3
# Copyright (c) 2022-2023 The Dash Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

"""

Usage:
$ ./handle_potential_conflicts.py <conflicts>

Where <conflicts> is a json string which looks like
{ pull_number: 26,
conflictPrs:
[ { number: 15,
files: [ 'testfile1', `testfile2` ],
conflicts: [ 'testfile1' ] },
...
]}
"""

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 get_label(pr_num):
return requests.get(f'https://api.github.com/repos/dashpay/dash/pulls/{pr_num}').json()['head']['label']

def main():
if len(sys.argv) != 2:
print(f'Usage: {sys.argv[0]} <conflicts>', file=sys.stderr)
sys.exit(1)

input = sys.argv[1]
print(input)
j_input = hjson.loads(input)
Expand Down Expand Up @@ -58,10 +72,5 @@ def main():
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()
4 changes: 3 additions & 1 deletion .github/workflows/predict-conflicts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ jobs:
uses: PastaPastaPasta/[email protected]
with:
ghToken: "${{ secrets.GITHUB_TOKEN }}"
- name: Checkout
uses: actions/checkout@v2
- 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"
run: pip3 install hjson && .github/workflows/handle_potential_conflicts.py "$conflicts"