From 5bd176d60d8664e40a67dcc6d7cdec0eb6775495 Mon Sep 17 00:00:00 2001 From: DavHau Date: Mon, 7 Aug 2023 10:30:59 +0200 Subject: [PATCH 1/4] action-create-pr: fix $@ not forwarded --- pkgs/action-create-pr/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/action-create-pr/default.nix b/pkgs/action-create-pr/default.nix index 456c857..05e4f40 100644 --- a/pkgs/action-create-pr/default.nix +++ b/pkgs/action-create-pr/default.nix @@ -6,5 +6,5 @@ , writePureShellScriptBin }: writePureShellScriptBin "action-create-pr" [ bash coreutils git tea openssh ] '' - bash ${./script.sh} + bash ${./script.sh} "$@" '' From c69943feb385ca9b98b58f12f7e06ee40223b433 Mon Sep 17 00:00:00 2001 From: DavHau Date: Mon, 7 Aug 2023 10:34:17 +0200 Subject: [PATCH 2/4] clan-merge: whitelist hsjobeki & Qubasa --- modules/web01/clan-merge.nix | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/web01/clan-merge.nix b/modules/web01/clan-merge.nix index 9c17c7a..76c97e3 100644 --- a/modules/web01/clan-merge.nix +++ b/modules/web01/clan-merge.nix @@ -16,9 +16,18 @@ script = '' while sleep 10; do ${self.packages.${pkgs.system}.clan-merge}/bin/clan-merge \ - --allowed-users clan-bot DavHau lassulus Mic92 \ - --repos clan-infra clan-core clan-homepage \ - --bot-name clan-bot + --bot-name clan-bot \ + --allowed-users \ + clan-bot \ + hsjobeki \ + DavHau \ + lassulus \ + Mic92 \ + Qubasa \ + --repos\ + clan-infra \ + clan-core \ + clan-homepage done ''; }; From cf07775f7318222eb0e6a38c8e53402c3bc31d1f Mon Sep 17 00:00:00 2001 From: DavHau Date: Mon, 7 Aug 2023 10:36:56 +0200 Subject: [PATCH 3/4] clan-merge: print PR number and ID when checking CI --- pkgs/clan-merge/clan_merge/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/clan-merge/clan_merge/__init__.py b/pkgs/clan-merge/clan_merge/__init__.py index 3d9ae1e..0158dd8 100644 --- a/pkgs/clan-merge/clan_merge/__init__.py +++ b/pkgs/clan-merge/clan_merge/__init__.py @@ -13,7 +13,7 @@ def load_token() -> str: def is_ci_green(pr: dict) -> bool: - print("Checking CI status for PR " + str(pr["id"])) + print(f"Checking CI status for PR {pr['number']} (id: {pr['id']})") repo = pr["base"]["repo"]["name"] url = ( "https://git.clan.lol/api/v1/repos/clan/" From e0a849d3833ad458c56a3bf8570c5475cf16c9ba Mon Sep 17 00:00:00 2001 From: DavHau Date: Mon, 7 Aug 2023 10:40:37 +0200 Subject: [PATCH 4/4] clan-merge: improve PR debug messages --- pkgs/clan-merge/clan_merge/__init__.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/pkgs/clan-merge/clan_merge/__init__.py b/pkgs/clan-merge/clan_merge/__init__.py index 0158dd8..d76330f 100644 --- a/pkgs/clan-merge/clan_merge/__init__.py +++ b/pkgs/clan-merge/clan_merge/__init__.py @@ -12,8 +12,12 @@ def load_token() -> str: return f.read().strip() +def pr_message(pr: dict) -> str: + return f"PR {pr['number']} in repo {pr['base']['repo']['name']} from user {pr['user']['login']}: {pr['title']}" + + def is_ci_green(pr: dict) -> bool: - print(f"Checking CI status for PR {pr['number']} (id: {pr['id']})") + print(f"Checking CI status for {pr_message(pr)}") repo = pr["base"]["repo"]["name"] url = ( "https://git.clan.lol/api/v1/repos/clan/" @@ -26,9 +30,7 @@ def is_ci_green(pr: dict) -> bool: data = json.loads(response.read()) # check for all commit statuses to have status "success" if not data["statuses"]: - print( - f"No CI status for PR {pr['number']} in repo {repo} from user {pr['user']['login']}" - ) + print(f"No CI status for {pr_message(pr)}") return False for status in data["statuses"]: if status["status"] != "success": @@ -122,13 +124,9 @@ def clan_merge( + f"?token={gitea_token}" ) if dry_run is True: - print( - f"Would merge PR {pr['number']} in repo {repo} from user {pr['user']['login']}" - ) + print(f"Would merge {pr_message(pr)}") else: - print( - f"Merging PR {pr['number']} in repo {repo} from user {pr['user']['login']}" - ) + print(f"Merging {pr_message(pr)}") data = dict( Do="merge", )