From 302813ad10e20fc20ecced3693ab14f00ac615d7 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Mon, 17 Apr 2023 00:51:52 +0300 Subject: [PATCH 1/4] chore: update copyright and usage example, move get_label up --- .../workflows/handle_potential_conflicts.py | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/.github/workflows/handle_potential_conflicts.py b/.github/workflows/handle_potential_conflicts.py index bd4232752f7ee..cafabf6a2261b 100644 --- a/.github/workflows/handle_potential_conflicts.py +++ b/.github/workflows/handle_potential_conflicts.py @@ -1,21 +1,30 @@ -# Copyright (c) 2022 The Dash Core developers +# 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 + +Where 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(): input = sys.argv[1] @@ -58,10 +67,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() From d308d5ab69d2210c995c316c713e784489aa1fdb Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Mon, 17 Apr 2023 00:53:58 +0300 Subject: [PATCH 2/4] feat: make handle_potential_conflicts.py executable --- .github/workflows/handle_potential_conflicts.py | 1 + 1 file changed, 1 insertion(+) mode change 100644 => 100755 .github/workflows/handle_potential_conflicts.py diff --git a/.github/workflows/handle_potential_conflicts.py b/.github/workflows/handle_potential_conflicts.py old mode 100644 new mode 100755 index cafabf6a2261b..b1245b549f4b9 --- a/.github/workflows/handle_potential_conflicts.py +++ b/.github/workflows/handle_potential_conflicts.py @@ -1,3 +1,4 @@ +#!/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. From bfe61d3b2121caa63c1fc473f5af6b9ca794cdf1 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Mon, 17 Apr 2023 00:54:37 +0300 Subject: [PATCH 3/4] feat: add "Usage:..." response --- .github/workflows/handle_potential_conflicts.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/handle_potential_conflicts.py b/.github/workflows/handle_potential_conflicts.py index b1245b549f4b9..c669685ac640a 100755 --- a/.github/workflows/handle_potential_conflicts.py +++ b/.github/workflows/handle_potential_conflicts.py @@ -28,6 +28,10 @@ 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]} ', file=sys.stderr) + sys.exit(1) + input = sys.argv[1] print(input) j_input = hjson.loads(input) From bd2cc57c0c6db550412012fc62945ede7ae25440 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Mon, 17 Apr 2023 01:06:06 +0300 Subject: [PATCH 4/4] chore: use checkout action instead of wget in predict-conflicts.yml --- .github/workflows/predict-conflicts.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/predict-conflicts.yml b/.github/workflows/predict-conflicts.yml index 45969660b0cca..6abecd01ee06b 100644 --- a/.github/workflows/predict-conflicts.yml +++ b/.github/workflows/predict-conflicts.yml @@ -24,5 +24,7 @@ jobs: uses: PastaPastaPasta/potential-conflicts-checker-action@0.1.9 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"