From 201d763f91f95541ee6841128a7c053d15b3a7cc Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 10:13:00 +0300 Subject: [PATCH 01/73] changed checkout ref to target and added base input --- .github/workflows/push_checks_main.yml | 3 ++- .github/workflows/sync_branches.yaml | 18 +++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/push_checks_main.yml b/.github/workflows/push_checks_main.yml index f6aebda25..f8aadf201 100644 --- a/.github/workflows/push_checks_main.yml +++ b/.github/workflows/push_checks_main.yml @@ -9,5 +9,6 @@ jobs: name: Sync Branches ♾️ uses: ChainSafe/web3.unity/.github/workflows/sync_branches.yaml@main with: - branch: dev + base: main + target: dev secrets: inherit \ No newline at end of file diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index feaa06195..94e7b178d 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -3,12 +3,19 @@ name: Sync Branches on: workflow_call: inputs: - branch: + base: + required: true + type: string + target: required: true type: string workflow_dispatch: inputs: - branch: + base: + required: true + description: "Branch to Sync" + type: string + target: required: true description: "Branch to Sync" type: string @@ -21,17 +28,14 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 with: - ref: ${{ github.head_ref || github.ref_name }} + ref: ${{ github.event.inputs.target }} lfs: true ssh-key: ${{ secrets.DEPLOY_KEY }} - name: Sync Branches run: | git config user.email $git_email git config user.name $git_actor - git fetch origin ${{ github.event.inputs.branch }} - git checkout ${{ github.event.inputs.branch }} - git pull - git merge main --allow-unrelated-histories + git merge ${{ github.event.inputs.base }} --allow-unrelated-histories git push shell: bash env: From 4653680095b0549944f9b9336e5f30aeba63f888 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 10:15:20 +0300 Subject: [PATCH 02/73] test run --- .github/workflows/push_checks_main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_checks_main.yml b/.github/workflows/push_checks_main.yml index f8aadf201..8bf8d7a30 100644 --- a/.github/workflows/push_checks_main.yml +++ b/.github/workflows/push_checks_main.yml @@ -2,7 +2,7 @@ name: Post Push Checks on: push: - branches: [ main ] + branches: [ rob/sync-branches-ci-fix ] jobs: sync_branches: From 0950269bfb6cd51bfa9db9fd76869dbf9a27b1eb Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 10:16:21 +0300 Subject: [PATCH 03/73] workflow file ref changed --- .github/workflows/push_checks_main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_checks_main.yml b/.github/workflows/push_checks_main.yml index 8bf8d7a30..5e387d799 100644 --- a/.github/workflows/push_checks_main.yml +++ b/.github/workflows/push_checks_main.yml @@ -7,7 +7,7 @@ on: jobs: sync_branches: name: Sync Branches ♾️ - uses: ChainSafe/web3.unity/.github/workflows/sync_branches.yaml@main + uses: ChainSafe/web3.unity/.github/workflows/sync_branches.yaml@rob/sync-branches-ci-fix with: base: main target: dev From 993933fcabfbbbd07e7d534bccb4e9322a954a03 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 10:21:00 +0300 Subject: [PATCH 04/73] change the base branch since main and dev are upto date --- .github/workflows/push_checks_main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push_checks_main.yml b/.github/workflows/push_checks_main.yml index 5e387d799..7af31545e 100644 --- a/.github/workflows/push_checks_main.yml +++ b/.github/workflows/push_checks_main.yml @@ -9,6 +9,6 @@ jobs: name: Sync Branches ♾️ uses: ChainSafe/web3.unity/.github/workflows/sync_branches.yaml@rob/sync-branches-ci-fix with: - base: main - target: dev + base: rob/sync-branches-ci-fix + target: rob/sync-branches-ci-fix-test-branch secrets: inherit \ No newline at end of file From 2c273247dbe0cfa8f3431a604e13b4525f386623 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 10:24:51 +0300 Subject: [PATCH 05/73] added some logs for debugging --- .github/workflows/sync_branches.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index 94e7b178d..b9b6dec7f 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -35,6 +35,8 @@ jobs: run: | git config user.email $git_email git config user.name $git_actor + git branch --show-current + echo "Syncing branches... base: ${{ github.event.inputs.base }} target: ${{ github.event.inputs.target }}" git merge ${{ github.event.inputs.base }} --allow-unrelated-histories git push shell: bash From bd05d99345127e030360f44d4bb3f58e32f0cef9 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 10:33:46 +0300 Subject: [PATCH 06/73] more logs --- .github/workflows/sync_branches.yaml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index b9b6dec7f..5e4b8f0f5 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -4,20 +4,24 @@ on: workflow_call: inputs: base: + description: "Base branch to Sync" required: true type: string + default: "main" target: + description: "Target branch to Sync" required: true type: string + default: "dev" workflow_dispatch: inputs: base: required: true - description: "Branch to Sync" + description: "Base branch to Sync" type: string target: required: true - description: "Branch to Sync" + description: "Target branch to Sync" type: string jobs: @@ -37,6 +41,8 @@ jobs: git config user.name $git_actor git branch --show-current echo "Syncing branches... base: ${{ github.event.inputs.base }} target: ${{ github.event.inputs.target }}" + echo "Syncing branches... second check base: ${{ github.inputs.base }} target: ${{ github.inputs.target }}" + echo "Syncing branches... third check base: ${{ inputs.base }} target: ${{ inputs.target }}" git merge ${{ github.event.inputs.base }} --allow-unrelated-histories git push shell: bash From c4732b1a0c108cff59f415ebd67c6622b7d96ead Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 10:36:11 +0300 Subject: [PATCH 07/73] check with correct inputs --- .github/workflows/sync_branches.yaml | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index 5e4b8f0f5..0779ab6d1 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -4,15 +4,11 @@ on: workflow_call: inputs: base: - description: "Base branch to Sync" required: true type: string - default: "main" target: - description: "Target branch to Sync" required: true type: string - default: "dev" workflow_dispatch: inputs: base: @@ -32,18 +28,15 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 with: - ref: ${{ github.event.inputs.target }} + ref: ${{ inputs.target }} lfs: true ssh-key: ${{ secrets.DEPLOY_KEY }} - name: Sync Branches run: | git config user.email $git_email git config user.name $git_actor - git branch --show-current - echo "Syncing branches... base: ${{ github.event.inputs.base }} target: ${{ github.event.inputs.target }}" - echo "Syncing branches... second check base: ${{ github.inputs.base }} target: ${{ github.inputs.target }}" - echo "Syncing branches... third check base: ${{ inputs.base }} target: ${{ inputs.target }}" - git merge ${{ github.event.inputs.base }} --allow-unrelated-histories + echo "Syncing branches... base: ${{ inputs.base }} target: ${{ inputs.target }}" + git merge ${{ inputs.base }} --allow-unrelated-histories git push shell: bash env: From c144efbc1c709fbba486215266314ed3a677f813 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 10:39:51 +0300 Subject: [PATCH 08/73] logs and added fetch just in case --- .github/workflows/sync_branches.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index 0779ab6d1..d471f1ec4 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -35,6 +35,9 @@ jobs: run: | git config user.email $git_email git config user.name $git_actor + git branch --show-current + git branch + git fetch echo "Syncing branches... base: ${{ inputs.base }} target: ${{ inputs.target }}" git merge ${{ inputs.base }} --allow-unrelated-histories git push From 0cadd2aa5b269cf240e972c5da7eca3291acf15e Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 10:48:08 +0300 Subject: [PATCH 09/73] cutting my losses and trying a third party action --- .github/workflows/sync_branches.yaml | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index d471f1ec4..5eb839370 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -27,21 +27,10 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 - with: - ref: ${{ inputs.target }} - lfs: true - ssh-key: ${{ secrets.DEPLOY_KEY }} - name: Sync Branches - run: | - git config user.email $git_email - git config user.name $git_actor - git branch --show-current - git branch - git fetch - echo "Syncing branches... base: ${{ inputs.base }} target: ${{ inputs.target }}" - git merge ${{ inputs.base }} --allow-unrelated-histories - git push - shell: bash - env: - git_email: "${{ github.actor }}@users.noreply.github.com" - git_actor: "${{ github.actor }}" \ No newline at end of file + uses: devmasx/merge-branch@master + with: + type: now + from_branch: ${{ inputs.base }} + target_branch: ${{ inputs.target }} + github_token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 1ec1acf47a7286c6016a7ce755fb95e2510d1180 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 10:50:51 +0300 Subject: [PATCH 10/73] skip ci added --- .github/workflows/sync_branches.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index 5eb839370..8f1e4b94b 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -33,4 +33,5 @@ jobs: type: now from_branch: ${{ inputs.base }} target_branch: ${{ inputs.target }} + message: Auto Merge [skip ci] github_token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From cb42309bf6c880dc915b2d9fe1de7af6fcde9c66 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 12:16:29 +0300 Subject: [PATCH 11/73] skip CI inputs added --- .github/workflows/sync_branches.yaml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index 8f1e4b94b..679383094 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -9,6 +9,10 @@ on: target: required: true type: string + skip_ci: + required: true + type: boolean + default: true workflow_dispatch: inputs: base: @@ -19,19 +23,30 @@ on: required: true description: "Target branch to Sync" type: string + skip_ci: + required: true + description: "Should push also skip CI" + type: boolean + default: true + +env: + message: "Auto Sync with ${{ inputs.base }}" jobs: - setup: + sync: name: Sync Branches ♾️ runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 + - name: Set Automation + if: ${{ inputs.skip_ci }} + run: $message += " [ skip-ci ]" - name: Sync Branches uses: devmasx/merge-branch@master with: type: now from_branch: ${{ inputs.base }} target_branch: ${{ inputs.target }} - message: Auto Merge [skip ci] + message: $message github_token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 45f7c8eebd8b051c218713a66b1fa70ad0bd1bed Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 12:17:38 +0300 Subject: [PATCH 12/73] remove required from skip_ci input --- .github/workflows/sync_branches.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index 679383094..251e84096 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -10,7 +10,6 @@ on: required: true type: string skip_ci: - required: true type: boolean default: true workflow_dispatch: From 17cfb55b4e5de95d582bbba2687dd12526621825 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 12:21:59 +0300 Subject: [PATCH 13/73] apparently $ runs commands in bash --- .github/workflows/sync_branches.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index 251e84096..2a1c249e8 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -40,7 +40,7 @@ jobs: uses: actions/checkout@v4 - name: Set Automation if: ${{ inputs.skip_ci }} - run: $message += " [ skip-ci ]" + run: message += " [ skip-ci ]" - name: Sync Branches uses: devmasx/merge-branch@master with: From 93a36b0abdd12b9b683992ce97c36fd24ad12ef6 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 12:24:11 +0300 Subject: [PATCH 14/73] maybe pipe it --- .github/workflows/sync_branches.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index 2a1c249e8..598b8c9fb 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -40,7 +40,8 @@ jobs: uses: actions/checkout@v4 - name: Set Automation if: ${{ inputs.skip_ci }} - run: message += " [ skip-ci ]" + run: | + $message += " [ skip-ci ]" - name: Sync Branches uses: devmasx/merge-branch@master with: From b0c34aca30b89743a25faa155226c09d425ff416 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 12:25:33 +0300 Subject: [PATCH 15/73] cutting my loses again --- .github/workflows/sync_branches.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index 598b8c9fb..7e6880f4b 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -40,8 +40,7 @@ jobs: uses: actions/checkout@v4 - name: Set Automation if: ${{ inputs.skip_ci }} - run: | - $message += " [ skip-ci ]" + run: echo $message += " [ skip-ci ]" - name: Sync Branches uses: devmasx/merge-branch@master with: From 35468a39ca118213458216a15e5402cb36215283 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 12:29:05 +0300 Subject: [PATCH 16/73] trying some stuff --- .github/workflows/sync_branches.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index 7e6880f4b..e4b5ea3fb 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -47,5 +47,5 @@ jobs: type: now from_branch: ${{ inputs.base }} target_branch: ${{ inputs.target }} - message: $message + message: ${{ env.message }} github_token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 0b1dc21cf45db9abb7627952eb36b61447ca9f37 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 12:35:49 +0300 Subject: [PATCH 17/73] trying something from stackoverflow --- .github/workflows/sync_branches.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index e4b5ea3fb..055c8333a 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -40,7 +40,7 @@ jobs: uses: actions/checkout@v4 - name: Set Automation if: ${{ inputs.skip_ci }} - run: echo $message += " [ skip-ci ]" + run: echo "message+=' [ skip-ci ]'" >> $GITHUB_ENV - name: Sync Branches uses: devmasx/merge-branch@master with: From 68d2254ea5da4d117c86dde23a3b94b318ee874f Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 12:38:55 +0300 Subject: [PATCH 18/73] small edits --- .github/workflows/sync_branches.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index 055c8333a..6ebe58f0a 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -40,7 +40,9 @@ jobs: uses: actions/checkout@v4 - name: Set Automation if: ${{ inputs.skip_ci }} - run: echo "message+=' [ skip-ci ]'" >> $GITHUB_ENV + run: | + skip_ci=" [skip-ci]" + echo "message+=$skip_ci" >> $GITHUB_ENV - name: Sync Branches uses: devmasx/merge-branch@master with: From f4f874cb4b6dabe43d4e99a0a9701d6d29d063b7 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 12:43:09 +0300 Subject: [PATCH 19/73] smaller edits --- .github/workflows/sync_branches.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index 6ebe58f0a..09939dd66 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -42,7 +42,7 @@ jobs: if: ${{ inputs.skip_ci }} run: | skip_ci=" [skip-ci]" - echo "message+=$skip_ci" >> $GITHUB_ENV + echo "message=message+$skip_ci" >> $GITHUB_ENV - name: Sync Branches uses: devmasx/merge-branch@master with: From efb04cbe3721715c094a94bc0aed494517c51da8 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 12:44:37 +0300 Subject: [PATCH 20/73] bash is so weird --- .github/workflows/sync_branches.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index 09939dd66..722dacd08 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -42,7 +42,7 @@ jobs: if: ${{ inputs.skip_ci }} run: | skip_ci=" [skip-ci]" - echo "message=message+$skip_ci" >> $GITHUB_ENV + echo "message=$message+$skip_ci" >> $GITHUB_ENV - name: Sync Branches uses: devmasx/merge-branch@master with: From e863689d59e5707fd588f3bc13ac92a868fa9a03 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 12:47:49 +0300 Subject: [PATCH 21/73] message formatting --- .github/workflows/sync_branches.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index 722dacd08..7def27314 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -42,7 +42,7 @@ jobs: if: ${{ inputs.skip_ci }} run: | skip_ci=" [skip-ci]" - echo "message=$message+$skip_ci" >> $GITHUB_ENV + echo "message=$message$skip_ci" >> $GITHUB_ENV - name: Sync Branches uses: devmasx/merge-branch@master with: From 1eab7cf99d868330d9bd9c33fd689b5cf2ec0433 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 12:51:23 +0300 Subject: [PATCH 22/73] input options implemented --- .github/workflows/sync_branches.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index 7def27314..08cdee56b 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -30,6 +30,8 @@ on: env: message: "Auto Sync with ${{ inputs.base }}" + base: ${{ github.event.inputs.base || inputs.base }} + target: ${{ github.event.inputs.target || inputs.base }}" jobs: sync: @@ -47,7 +49,7 @@ jobs: uses: devmasx/merge-branch@master with: type: now - from_branch: ${{ inputs.base }} - target_branch: ${{ inputs.target }} + from_branch: ${{ env.base }} + target_branch: ${{ env.target }} message: ${{ env.message }} github_token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 45960bd8e50e385fb8d7d2f68bcc5222361d4fca Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 12:54:08 +0300 Subject: [PATCH 23/73] typo fix --- .github/workflows/sync_branches.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index 08cdee56b..afe2a6986 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -31,7 +31,7 @@ on: env: message: "Auto Sync with ${{ inputs.base }}" base: ${{ github.event.inputs.base || inputs.base }} - target: ${{ github.event.inputs.target || inputs.base }}" + target: ${{ github.event.inputs.target || inputs.target }}" jobs: sync: From 7e8eef6dca8ccfb9ce80def0ef39d87686db7c8a Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 12:55:58 +0300 Subject: [PATCH 24/73] more typo fixes :facepalm --- .github/workflows/sync_branches.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index afe2a6986..2f8e60b59 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -31,7 +31,7 @@ on: env: message: "Auto Sync with ${{ inputs.base }}" base: ${{ github.event.inputs.base || inputs.base }} - target: ${{ github.event.inputs.target || inputs.target }}" + target: ${{ github.event.inputs.target || inputs.target }} jobs: sync: From 331b331f09ec8ec476ebf03ff7b945c4af6447a6 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 12:59:20 +0300 Subject: [PATCH 25/73] reverted testing refs --- .github/workflows/push_checks_main.yml | 8 ++++---- .github/workflows/sync_branches.yaml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/push_checks_main.yml b/.github/workflows/push_checks_main.yml index 7af31545e..a53fefcfb 100644 --- a/.github/workflows/push_checks_main.yml +++ b/.github/workflows/push_checks_main.yml @@ -2,13 +2,13 @@ name: Post Push Checks on: push: - branches: [ rob/sync-branches-ci-fix ] + branches: [ main ] jobs: sync_branches: name: Sync Branches ♾️ - uses: ChainSafe/web3.unity/.github/workflows/sync_branches.yaml@rob/sync-branches-ci-fix + uses: ChainSafe/web3.unity/.github/workflows/sync_branches.yaml@rob/main with: - base: rob/sync-branches-ci-fix - target: rob/sync-branches-ci-fix-test-branch + base: main + target: dev secrets: inherit \ No newline at end of file diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index 2f8e60b59..5a5dd8b28 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -24,7 +24,7 @@ on: type: string skip_ci: required: true - description: "Should push also skip CI" + description: "Should push skip CI" type: boolean default: true From 252869a05ba670eb33ff972ce38fad43d7e958a1 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 13:00:23 +0300 Subject: [PATCH 26/73] typo fix --- .github/workflows/push_checks_main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_checks_main.yml b/.github/workflows/push_checks_main.yml index a53fefcfb..f8aadf201 100644 --- a/.github/workflows/push_checks_main.yml +++ b/.github/workflows/push_checks_main.yml @@ -7,7 +7,7 @@ on: jobs: sync_branches: name: Sync Branches ♾️ - uses: ChainSafe/web3.unity/.github/workflows/sync_branches.yaml@rob/main + uses: ChainSafe/web3.unity/.github/workflows/sync_branches.yaml@main with: base: main target: dev From a2ae15be70ab1937f64d3fd4533724b69e93db9b Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 13:32:53 +0300 Subject: [PATCH 27/73] checking regular git commands if they work --- .github/workflows/push_checks_main.yml | 8 ++++---- .github/workflows/sync_branches.yaml | 18 +++++++++++------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/.github/workflows/push_checks_main.yml b/.github/workflows/push_checks_main.yml index f8aadf201..7af31545e 100644 --- a/.github/workflows/push_checks_main.yml +++ b/.github/workflows/push_checks_main.yml @@ -2,13 +2,13 @@ name: Post Push Checks on: push: - branches: [ main ] + branches: [ rob/sync-branches-ci-fix ] jobs: sync_branches: name: Sync Branches ♾️ - uses: ChainSafe/web3.unity/.github/workflows/sync_branches.yaml@main + uses: ChainSafe/web3.unity/.github/workflows/sync_branches.yaml@rob/sync-branches-ci-fix with: - base: main - target: dev + base: rob/sync-branches-ci-fix + target: rob/sync-branches-ci-fix-test-branch secrets: inherit \ No newline at end of file diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index 5a5dd8b28..1bb0fa514 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -46,10 +46,14 @@ jobs: skip_ci=" [skip-ci]" echo "message=$message$skip_ci" >> $GITHUB_ENV - name: Sync Branches - uses: devmasx/merge-branch@master - with: - type: now - from_branch: ${{ env.base }} - target_branch: ${{ env.target }} - message: ${{ env.message }} - github_token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + run: | + git config user.email $git_email + git config user.name $git_actor + git checkout ${{ env.target }} + git pull + git merge ${{ env.base }} --allow-unrelated-histories + git push + shell: bash + env: + git_email: "${{ github.actor }}@users.noreply.github.com" + git_actor: "${{ github.actor }}" \ No newline at end of file From 5787a52f3e9ce0c8791da33e58f888260fe37ae7 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 13:36:02 +0300 Subject: [PATCH 28/73] logs and fetch --- .github/workflows/sync_branches.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index 1bb0fa514..55398fe89 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -49,6 +49,8 @@ jobs: run: | git config user.email $git_email git config user.name $git_actor + git branch + git fetch origin ${{ env.target }} git checkout ${{ env.target }} git pull git merge ${{ env.base }} --allow-unrelated-histories From e9ae835aa5b1e191461e14661e182836698b77e0 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 13:44:06 +0300 Subject: [PATCH 29/73] log latest commit --- .github/workflows/sync_branches.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index 55398fe89..6178921b9 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -52,8 +52,9 @@ jobs: git branch git fetch origin ${{ env.target }} git checkout ${{ env.target }} + git log --name-status HEAD^..HEAD git pull - git merge ${{ env.base }} --allow-unrelated-histories + git merge ${{ env.base }} git push shell: bash env: From 0961c31f0ca9e77978f675f4404e958e207260b8 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 13:47:48 +0300 Subject: [PATCH 30/73] changed checkout branch at step removed branch log --- .github/workflows/sync_branches.yaml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index 6178921b9..24c551ae2 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -40,6 +40,9 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 + with: + ref: ${{ env.target }} + ssh-key: ${{ secrets.DEPLOY_KEY }} - name: Set Automation if: ${{ inputs.skip_ci }} run: | @@ -49,12 +52,10 @@ jobs: run: | git config user.email $git_email git config user.name $git_actor - git branch - git fetch origin ${{ env.target }} - git checkout ${{ env.target }} + git fetch origin ${{ env.base }} git log --name-status HEAD^..HEAD git pull - git merge ${{ env.base }} + git merge ${{ env.base }} --allow-unrelated-histories git push shell: bash env: From 2788ff01374236188bcafbedcecd712814c5ac2e Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 13:49:01 +0300 Subject: [PATCH 31/73] log last commit command replaced --- .github/workflows/sync_branches.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index 24c551ae2..3e4af81ae 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -53,7 +53,7 @@ jobs: git config user.email $git_email git config user.name $git_actor git fetch origin ${{ env.base }} - git log --name-status HEAD^..HEAD + git show --summary git pull git merge ${{ env.base }} --allow-unrelated-histories git push From 5924ce5a846158f10fd39d593ca8ac6e97642ed0 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 13:53:55 +0300 Subject: [PATCH 32/73] log status --- .github/workflows/sync_branches.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index 3e4af81ae..889d1c9a8 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -52,9 +52,8 @@ jobs: run: | git config user.email $git_email git config user.name $git_actor + git status git fetch origin ${{ env.base }} - git show --summary - git pull git merge ${{ env.base }} --allow-unrelated-histories git push shell: bash From d7991255a3a6edefbd52f7df473bb183853348b0 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 14:01:10 +0300 Subject: [PATCH 33/73] checkout at base branch --- .github/workflows/sync_branches.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index 889d1c9a8..5a58262b6 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -53,7 +53,8 @@ jobs: git config user.email $git_email git config user.name $git_actor git status - git fetch origin ${{ env.base }} + git checkout ${{ env.base }} + git checkout ${{ env.target }} git merge ${{ env.base }} --allow-unrelated-histories git push shell: bash From 54384657e16eda585c75a52d75db51752d25cc46 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 14:02:42 +0300 Subject: [PATCH 34/73] added git branch to find base branch --- .github/workflows/sync_branches.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index 5a58262b6..28281c870 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -53,8 +53,7 @@ jobs: git config user.email $git_email git config user.name $git_actor git status - git checkout ${{ env.base }} - git checkout ${{ env.target }} + git branch git merge ${{ env.base }} --allow-unrelated-histories git push shell: bash From c35a5e480128a15d87e2aba6595695881be3c0f6 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 14:04:02 +0300 Subject: [PATCH 35/73] trying more combinations --- .github/workflows/sync_branches.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index 28281c870..99bd9634e 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -53,7 +53,9 @@ jobs: git config user.email $git_email git config user.name $git_actor git status - git branch + git fetch origin ${{ env.base }} + git checkout ${{ env.base }} + git checkout ${{ env.target }} git merge ${{ env.base }} --allow-unrelated-histories git push shell: bash From 12913c2516ea408bed5311e0214c19b8f3e8aa63 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Wed, 27 Nov 2024 15:40:24 +0300 Subject: [PATCH 36/73] updated dev PR checks to trigger with multiple labels --- .github/workflows/pull_request_checks_dev.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pull_request_checks_dev.yml b/.github/workflows/pull_request_checks_dev.yml index 627e50c9c..2463f30c2 100644 --- a/.github/workflows/pull_request_checks_dev.yml +++ b/.github/workflows/pull_request_checks_dev.yml @@ -9,14 +9,21 @@ on: - ready_for_review jobs: + pre_job: + name: Pre Job 🚀 + runs-on: ubuntu-latest + if: ${{ github.event.action == 'ready_for_review' || (!github.event.pull_request.draft && contains( github.event.pull_request.labels.*.name, 'ready-to-merge')) }} + steps: + - run: echo "Proceeding to checks..." web3_tests: name: Web3 tests 🕸 - if: ${{ github.event.action == 'ready_for_review' || github.event.label.name == 'ready-to-merge'}} uses: ChainSafe/web3.unity/.github/workflows/test.yaml@main + needs: [ pre_job ] analyze_code: name: Analyze 🧐 - if: ${{ github.event.action == 'ready_for_review' || github.event.label.name == 'ready-to-merge'}} uses: ChainSafe/web3.unity/.github/workflows/codeql.yml@main + needs: [ pre_job ] documentation_check: name: Documentation Check 📚 - uses: ChainSafe/web3.unity/.github/workflows/documentation_check.yml@main \ No newline at end of file + uses: ChainSafe/web3.unity/.github/workflows/documentation_check.yml@main + needs: [ pre_job ] \ No newline at end of file From 9c61e1bb7e1b8110a7ce32b597a90073e32aac9c Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 13:30:51 +0300 Subject: [PATCH 37/73] setup now uses a proper command line parser --- Setup/DefaultOptions.cs | 45 ++++++++++++++++++ Setup/Git.cs | 98 ++++++++++++++++++++++++++------------- Setup/Setup.cs | 42 ++++++----------- Setup/Setup.csproj | 1 + Setup/SyncBranches.cs | 67 ++++++++++++++++++++++++++ Setup/SyncDependencies.cs | 3 ++ Setup/Utils/Utilities.cs | 10 ---- 7 files changed, 196 insertions(+), 70 deletions(-) create mode 100644 Setup/DefaultOptions.cs create mode 100644 Setup/SyncBranches.cs diff --git a/Setup/DefaultOptions.cs b/Setup/DefaultOptions.cs new file mode 100644 index 000000000..9f42d58ca --- /dev/null +++ b/Setup/DefaultOptions.cs @@ -0,0 +1,45 @@ +using System.Collections.Generic; +using CommandLine; +using Setup.Utils; + +namespace Setup; + +[Verb("do", true, HelpText = "Runs default options.")] +public class DefaultOptions +{ + [Option('s', "sync_dependencies", Required = false, Default = false, HelpText = "Generate and copy dependencies to Sample Project.")] + public bool SyncDependencies { get; set; } + + [Option('d', "duplicate_samples", Required = false, Default = false, HelpText = "Duplicate samples in Sample Project into package samples.")] + public bool DuplicateSamples { get; set; } + + [Option('p', "publish", Required = false, HelpText = "Version to release.")] + public string Release { get; set; } + + [Option('g', "git", Required = false, Default = false, HelpText = "Enable Git.")] + public bool Git { get; set; } + + public List GetRunnableList() + { + List runnableList = new List(); + + if (SyncDependencies) + { + runnableList.Add(new SyncDependencies()); + } + + if (DuplicateSamples) + { + runnableList.Add(new DuplicateSamples()); + } + + if (!string.IsNullOrEmpty(Release)) + { + runnableList.Add(new Release(Release)); + } + + runnableList.Add(new Git(Git)); + + return runnableList; + } +} \ No newline at end of file diff --git a/Setup/Git.cs b/Setup/Git.cs index 1c2db11aa..7b2125f6c 100644 --- a/Setup/Git.cs +++ b/Setup/Git.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; using Setup.Utils; namespace Setup; @@ -8,46 +6,61 @@ namespace Setup; /// /// Git helper class. /// -public static class Git +public class Git : IRunnable { private static bool _configured; - public static bool Enabled { get; private set; } = true; + public static bool Enabled { get; private set; } - public static void Configure(string configuration) + public int Order => - 1; + + public Git(bool enabled) { - switch (configuration) + Enabled = enabled; + } + + public void Run() + { + Console.WriteLine($"Git {nameof(Enabled)} : {Enabled}"); + } + + private static void Execute(string command) + { + if (!Enabled) { - case "enabled": - Enabled = true; - break; - case "disabled": - Enabled = false; - break; - default: - throw new Exception($"-git can't configure {configuration}"); + Console.WriteLine($"Git disabled skipping command: {command}"); + } + else + { + if (!_configured) + { + "git config user.email $git_email".Run(); + + "git config user.name $git_actor".Run(); + + _configured = true; + } + + $"git {command}".Run(); } } public static void Add(string path) { - $"git add \"{path}\" -f".Run(); + Execute($"add \"{path}\" -f"); } - public static void Commit(string message, string[] tags = null, bool skipCi = true) + public static void Commit(string message, string[] tags = null, bool skipCi = true, bool allowEmpty = false) { - if (!_configured) - { - Configure(); - } - if (skipCi) { message += " [skip ci]"; } - - // Checks if there are any changes to commit before committing - $"git diff-index --cached --quiet HEAD || git commit -m \"{message}\"".Run(); + + Execute(allowEmpty + ? $"commit --allow-empty -m \"{message}\"" + // Checks if there are any changes to commit before committing + : $"diff-index --cached --quiet HEAD || git commit -m \"{message}\""); if (tags != null) { @@ -63,7 +76,7 @@ public static void Commit(string message, string[] tags = null, bool skipCi = tr public static void Push(string[] tags = null) { - "git push -f".Run(); + Execute("push -f"); if (tags != null) { @@ -71,7 +84,7 @@ public static void Push(string[] tags = null) { if (!string.IsNullOrEmpty(tag)) { - $"git push origin \"{tag}\"".Run(); + Execute($"push origin \"{tag}\""); } } } @@ -83,17 +96,38 @@ public static void CommitAndPush(string message, string[] tags = null, bool skip Push(tags); } + + public static void Fetch(string branch) + { + Execute($"fetch origin {branch}"); + } - public static void Tag(string tag) + public static void Checkout(string branch, string path = "") { - $"git tag \"{tag}\"".Run(); + string command = $"checkout {branch}"; + + if (!string.IsNullOrEmpty(path)) + { + command += $" \"{path}\""; + } + + Execute(command); } - private static void Configure() + public static void Merge(string branch, bool allowUnrelatedHistories = false) { - "git config user.email $git_email".Run(); - "git config user.name $git_actor".Run(); + string command = $"merge {branch}"; - _configured = true; + if (allowUnrelatedHistories) + { + command += " --allow-unrelated-histories"; + } + + Execute(command); + } + + public static void Tag(string tag) + { + Execute($"tag \"{tag}\""); } } \ No newline at end of file diff --git a/Setup/Setup.cs b/Setup/Setup.cs index 28d96e9d2..aef349527 100644 --- a/Setup/Setup.cs +++ b/Setup/Setup.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using CommandLine; using Newtonsoft.Json; using Setup.Utils; @@ -57,35 +58,20 @@ private static List GetRunnableList(string[] args) { List runnableList = new List(); - // Parse arguments and Run operations based on that. - foreach (var arg in args) - { - switch (arg) + Parser.Default.ParseArguments(args) + .WithParsed(options => { - case not null when arg.StartsWith("-release"): - - string version = arg.Split(":")[1]; - runnableList.AddRunnable(new Release(version)); - break; - - case "-duplicate_samples": - runnableList.AddRunnable(new DuplicateSamples()); - break; - - case "-sync_dependencies": - runnableList.AddRunnable(new SyncDependencies()); - break; - - case not null when arg.StartsWith("-git"): - - string configuration = arg.Split(":")[1]; - Git.Configure(configuration); - continue; - - default: - continue; - } - } + switch (options) + { + case DefaultOptions defaultOptions: + runnableList.AddRange(defaultOptions.GetRunnableList()); + break; + case SyncBranches syncBranches: + runnableList.Add(syncBranches); + runnableList.Add(new Git(true)); + break; + } + }); return runnableList; } diff --git a/Setup/Setup.csproj b/Setup/Setup.csproj index e567b1161..10b9afa2f 100644 --- a/Setup/Setup.csproj +++ b/Setup/Setup.csproj @@ -6,6 +6,7 @@ + diff --git a/Setup/SyncBranches.cs b/Setup/SyncBranches.cs new file mode 100644 index 000000000..8ce786d53 --- /dev/null +++ b/Setup/SyncBranches.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.IO; +using CommandLine; +using Newtonsoft.Json; +using Setup.Utils; + +namespace Setup; + +/// +/// Sync branches (merge). +/// +[Verb("sync_branches", HelpText = "Sync branches.")] +public class SyncBranches : IRunnable +{ + public int Order => 0; + + public IEnumerable CommandLineArgument { get; set; } + + private readonly string[] _excludedPaths; + + [Option('b', "base", Required = true, HelpText = "Base branch.")] + public string Base { get; set; } + + [Option('t', "target", Required = true, HelpText = "Target branch.")] + public string Target { get; set; } + + [Option('s', "skip_ci", Required = false, Default = true, HelpText = "Disable/Skip CI triggers for sync/merge.")] + public bool SkipCi { get; set; } + + public SyncBranches() + { + Dependency[] dependencies = JsonConvert.DeserializeObject(File.ReadAllText("dependencies.json")); + + _excludedPaths = Array.ConvertAll(dependencies, d => d.Path); + } + + public void Run() + { + Console.WriteLine($"Syncing {Target} branch to {Base} branch..."); + + Git.Fetch(Base); + + Git.Checkout(Base); + + Git.Fetch(Target); + + Git.Checkout(Target); + + foreach (string path in _excludedPaths) + { + Git.Checkout(Base, path); + + Git.Add(path); + } + + Git.Commit("Exclude Paths - Auto Commit", skipCi: SkipCi, allowEmpty: true); + + Git.Merge(Base); + + Git.Commit($"Sync to {Base} - Auto Commit", skipCi: SkipCi, allowEmpty: true); + + Git.Push(); + + Console.WriteLine($"Synced {Target} branch to {Base} branch completed."); + } +} \ No newline at end of file diff --git a/Setup/SyncDependencies.cs b/Setup/SyncDependencies.cs index fe154c8b3..a8abc8d55 100644 --- a/Setup/SyncDependencies.cs +++ b/Setup/SyncDependencies.cs @@ -5,6 +5,9 @@ namespace Setup; +/// +/// Generate and copy dependencies to Sample Project. +/// public class SyncDependencies : IRunnable { public int Order => 0; diff --git a/Setup/Utils/Utilities.cs b/Setup/Utils/Utilities.cs index aab767060..6497f9114 100644 --- a/Setup/Utils/Utilities.cs +++ b/Setup/Utils/Utilities.cs @@ -11,16 +11,6 @@ public static class Utilities { public static void Run(this string command) { - if (!Git.Enabled) - { - if (command.ToLower().StartsWith("git")) - { - Console.WriteLine($"Git disabled skipping command: {command}"); - - return; - } - } - // Tried switch statement couldn't find a way to make it work if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { From 65e4f0dbc32bf2ab27841d4e2123dbdb4eb4f938 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 13:51:45 +0300 Subject: [PATCH 38/73] updated workflows with new command line parameters --- .github/workflows/duplicate_samples.yaml | 15 +--------- .github/workflows/release.yaml | 2 +- .github/workflows/setup.yaml | 21 +++++++++----- .github/workflows/sync_branches.yaml | 36 +++++------------------- .github/workflows/sync_dependencies.yaml | 16 ++--------- Setup/DefaultOptions.cs | 2 +- 6 files changed, 26 insertions(+), 66 deletions(-) diff --git a/.github/workflows/duplicate_samples.yaml b/.github/workflows/duplicate_samples.yaml index b650ae5d0..e24841e5e 100644 --- a/.github/workflows/duplicate_samples.yaml +++ b/.github/workflows/duplicate_samples.yaml @@ -3,25 +3,12 @@ name: Duplicate Samples 🪞 on: workflow_call: workflow_dispatch: - inputs: - arguments: - required: false - description: 'Run Arguments' - type: string - configuration: - required: true - description: 'Run Configuration' - default: 'Release' - type: choice - options: - - Release - - Debug jobs: setup: name: Duplicate Samples 🪞 uses: ChainSafe/web3.unity/.github/workflows/setup.yaml@main with: - arguments: "-duplicate_samples ${{ github.event.inputs.arguments || '-git:enabled' }} -c ${{ github.event.inputs.configuration || 'Release' }}" + arguments: "-d" secrets: inherit \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a73bb718c..c3e7774b1 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -15,7 +15,7 @@ jobs: name: Setup job uses: ChainSafe/web3.unity/.github/workflows/setup.yaml@main with: - arguments: "-release:${{ github.event.inputs.version }}" + arguments: "-p ${{ github.event.inputs.version }}" secrets: inherit release: name: Release job diff --git a/.github/workflows/setup.yaml b/.github/workflows/setup.yaml index c24b07ef3..f96ebc298 100644 --- a/.github/workflows/setup.yaml +++ b/.github/workflows/setup.yaml @@ -6,12 +6,24 @@ on: arguments: required: true type: string + configuration: + required: false + type: string + default: "Release" workflow_dispatch: inputs: arguments: required: true description: 'Arguments to pass to the setup script' type: string + configuration: + required: true + description: 'Run Configuration' + default: 'Release' + type: choice + options: + - Release + - Debug env: git_email: "${{ github.actor }}@users.noreply.github.com" git_actor: "${{ github.actor }}" @@ -36,10 +48,5 @@ jobs: - name: Run run: | cd Setup - dotnet run ${{ inputs.arguments || github.event.inputs.arguments }} Setup/Setup.csproj - git reset --hard - - name: Cache - uses: actions/cache/save@v4 - with: - path: .git - key: ${{ runner.os }}-git \ No newline at end of file + dotnet run -c ${{ inputs.configuration || github.event.inputs.configuration }} ${{ inputs.arguments || github.event.inputs.arguments }} + git reset --hard \ No newline at end of file diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index 99bd9634e..a7c7e3fd2 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -1,4 +1,4 @@ -name: Sync Branches +name: Sync Branches ♾️ on: workflow_call: @@ -29,36 +29,14 @@ on: default: true env: - message: "Auto Sync with ${{ inputs.base }}" base: ${{ github.event.inputs.base || inputs.base }} target: ${{ github.event.inputs.target || inputs.target }} + skip_ci: ${{ github.event.inputs.skip_ci || inputs.skip_ci }} jobs: - sync: + setup: name: Sync Branches ♾️ - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - ref: ${{ env.target }} - ssh-key: ${{ secrets.DEPLOY_KEY }} - - name: Set Automation - if: ${{ inputs.skip_ci }} - run: | - skip_ci=" [skip-ci]" - echo "message=$message$skip_ci" >> $GITHUB_ENV - - name: Sync Branches - run: | - git config user.email $git_email - git config user.name $git_actor - git status - git fetch origin ${{ env.base }} - git checkout ${{ env.base }} - git checkout ${{ env.target }} - git merge ${{ env.base }} --allow-unrelated-histories - git push - shell: bash - env: - git_email: "${{ github.actor }}@users.noreply.github.com" - git_actor: "${{ github.actor }}" \ No newline at end of file + uses: ChainSafe/web3.unity/.github/workflows/setup.yaml@main + with: + arguments: "-b ${{ env.base }} -t ${{ env.taret }} -s ${{ env.skip_ci }}" + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/sync_dependencies.yaml b/.github/workflows/sync_dependencies.yaml index 5e0f0b3fa..97cac2d7f 100644 --- a/.github/workflows/sync_dependencies.yaml +++ b/.github/workflows/sync_dependencies.yaml @@ -3,25 +3,13 @@ name: Sync Dependencies 🔄 on: workflow_call: workflow_dispatch: - inputs: - arguments: - required: false - description: 'Run Arguments' - type: string - configuration: - required: true - description: 'Run Configuration' - default: 'Release' - type: choice - options: - - Release - - Debug jobs: setup: name: Sync Dependencies 🔄 uses: ChainSafe/web3.unity/.github/workflows/setup.yaml@main with: - arguments: "-sync_dependencies ${{ github.event.inputs.arguments || '-git:enabled' }} -c ${{ github.event.inputs.configuration || 'Release' }}" + arguments: "-s" + configuration: ${{ github.event.inputs.configuration || 'Release' }} secrets: inherit \ No newline at end of file diff --git a/Setup/DefaultOptions.cs b/Setup/DefaultOptions.cs index 9f42d58ca..73ead66ef 100644 --- a/Setup/DefaultOptions.cs +++ b/Setup/DefaultOptions.cs @@ -16,7 +16,7 @@ public class DefaultOptions [Option('p', "publish", Required = false, HelpText = "Version to release.")] public string Release { get; set; } - [Option('g', "git", Required = false, Default = false, HelpText = "Enable Git.")] + [Option('g', "git", Required = false, Default = true, HelpText = "Enable Git.")] public bool Git { get; set; } public List GetRunnableList() From cf02efbdfd019e17714f8953930b1c0f6a19f5ae Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 14:05:02 +0300 Subject: [PATCH 39/73] updated local scripts with new arguments --- Setup/DefaultOptions.cs | 6 ++++-- scripts/setup.bat | 2 +- scripts/setup.sh | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Setup/DefaultOptions.cs b/Setup/DefaultOptions.cs index 73ead66ef..77a2138e2 100644 --- a/Setup/DefaultOptions.cs +++ b/Setup/DefaultOptions.cs @@ -17,7 +17,7 @@ public class DefaultOptions public string Release { get; set; } [Option('g', "git", Required = false, Default = true, HelpText = "Enable Git.")] - public bool Git { get; set; } + public bool? EnableGit { get; set; } public List GetRunnableList() { @@ -38,7 +38,9 @@ public List GetRunnableList() runnableList.Add(new Release(Release)); } - runnableList.Add(new Git(Git)); + EnableGit ??= false; + + runnableList.Add(new Git(EnableGit.Value)); return runnableList; } diff --git a/scripts/setup.bat b/scripts/setup.bat index f94a29e1c..a26225e22 100644 --- a/scripts/setup.bat +++ b/scripts/setup.bat @@ -14,6 +14,6 @@ if "%1"=="" ( set "config=%1" ) -dotnet run -sync_dependencies -git:disabled -c %config% Setup.csproj +dotnet run -s -g false -c %config% Setup.csproj popd diff --git a/scripts/setup.sh b/scripts/setup.sh index f1ef9469c..cf07865e2 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -7,6 +7,6 @@ git submodule update --init pushd "$scripts_dir"/../Setup # publish DLLs to unity package -dotnet run -sync_dependencies -git:disabled -c ${1:-Release} Setup.csproj +dotnet run -s -g false -c ${1:-Release} popd \ No newline at end of file From f939e519fd1e096c67780de8f2501c82df89ec82 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 14:05:30 +0300 Subject: [PATCH 40/73] text formatting --- .github/workflows/setup.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/setup.yaml b/.github/workflows/setup.yaml index f96ebc298..d024ed7a5 100644 --- a/.github/workflows/setup.yaml +++ b/.github/workflows/setup.yaml @@ -48,5 +48,5 @@ jobs: - name: Run run: | cd Setup - dotnet run -c ${{ inputs.configuration || github.event.inputs.configuration }} ${{ inputs.arguments || github.event.inputs.arguments }} + dotnet run ${{ inputs.arguments || github.event.inputs.arguments }} -c ${{ inputs.configuration || github.event.inputs.configuration }} git reset --hard \ No newline at end of file From 1b69fb5ba70a77860f192ae5ad85f5a3d0b20fe0 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 14:09:14 +0300 Subject: [PATCH 41/73] updated release argument --- .github/workflows/release.yaml | 2 +- Setup/DefaultOptions.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index c3e7774b1..6ed46fefc 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -15,7 +15,7 @@ jobs: name: Setup job uses: ChainSafe/web3.unity/.github/workflows/setup.yaml@main with: - arguments: "-p ${{ github.event.inputs.version }}" + arguments: "-r ${{ github.event.inputs.version }}" secrets: inherit release: name: Release job diff --git a/Setup/DefaultOptions.cs b/Setup/DefaultOptions.cs index 77a2138e2..0e30f9065 100644 --- a/Setup/DefaultOptions.cs +++ b/Setup/DefaultOptions.cs @@ -13,7 +13,7 @@ public class DefaultOptions [Option('d', "duplicate_samples", Required = false, Default = false, HelpText = "Duplicate samples in Sample Project into package samples.")] public bool DuplicateSamples { get; set; } - [Option('p', "publish", Required = false, HelpText = "Version to release.")] + [Option('r', "release", Required = false, HelpText = "Version to release.")] public string Release { get; set; } [Option('g', "git", Required = false, Default = true, HelpText = "Enable Git.")] From 2bf7590c9f7b5e4798471b890a65f0068795e4db Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 14:11:01 +0300 Subject: [PATCH 42/73] -r is also already in use, --deploy --- .github/workflows/release.yaml | 2 +- Setup/DefaultOptions.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6ed46fefc..8cbadce4a 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -15,7 +15,7 @@ jobs: name: Setup job uses: ChainSafe/web3.unity/.github/workflows/setup.yaml@main with: - arguments: "-r ${{ github.event.inputs.version }}" + arguments: "--deploy ${{ github.event.inputs.version }}" secrets: inherit release: name: Release job diff --git a/Setup/DefaultOptions.cs b/Setup/DefaultOptions.cs index 0e30f9065..815f36bec 100644 --- a/Setup/DefaultOptions.cs +++ b/Setup/DefaultOptions.cs @@ -13,7 +13,7 @@ public class DefaultOptions [Option('d', "duplicate_samples", Required = false, Default = false, HelpText = "Duplicate samples in Sample Project into package samples.")] public bool DuplicateSamples { get; set; } - [Option('r', "release", Required = false, HelpText = "Version to release.")] + [Option("--deploy", Required = false, HelpText = "Version to release.")] public string Release { get; set; } [Option('g', "git", Required = false, Default = true, HelpText = "Enable Git.")] From fc967603c6adfdae7a2e4fa43b4ad0c75da49057 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 14:11:29 +0300 Subject: [PATCH 43/73] typo fix --- Setup/DefaultOptions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Setup/DefaultOptions.cs b/Setup/DefaultOptions.cs index 815f36bec..76c214d06 100644 --- a/Setup/DefaultOptions.cs +++ b/Setup/DefaultOptions.cs @@ -13,7 +13,7 @@ public class DefaultOptions [Option('d', "duplicate_samples", Required = false, Default = false, HelpText = "Duplicate samples in Sample Project into package samples.")] public bool DuplicateSamples { get; set; } - [Option("--deploy", Required = false, HelpText = "Version to release.")] + [Option("deploy", Required = false, HelpText = "Version to release.")] public string Release { get; set; } [Option('g', "git", Required = false, Default = true, HelpText = "Enable Git.")] From 91fe663c5010e97009a064b593949d6c4f499302 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 14:16:02 +0300 Subject: [PATCH 44/73] arguments fix for sync verb --- .github/workflows/sync_branches.yaml | 2 +- Setup/SyncBranches.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index a7c7e3fd2..3033c9bee 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -38,5 +38,5 @@ jobs: name: Sync Branches ♾️ uses: ChainSafe/web3.unity/.github/workflows/setup.yaml@main with: - arguments: "-b ${{ env.base }} -t ${{ env.taret }} -s ${{ env.skip_ci }}" + arguments: "sync -b ${{ env.base }} -t ${{ env.taret }} -s ${{ env.skip_ci }}" secrets: inherit \ No newline at end of file diff --git a/Setup/SyncBranches.cs b/Setup/SyncBranches.cs index 8ce786d53..d48c31c5a 100644 --- a/Setup/SyncBranches.cs +++ b/Setup/SyncBranches.cs @@ -10,7 +10,7 @@ namespace Setup; /// /// Sync branches (merge). /// -[Verb("sync_branches", HelpText = "Sync branches.")] +[Verb("sync", HelpText = "Sync branches.")] public class SyncBranches : IRunnable { public int Order => 0; From 0f2171d3510da571d9292f6cd4d5f1f847092f66 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 14:21:25 +0300 Subject: [PATCH 45/73] fixed skip ci option --- Setup/SyncBranches.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Setup/SyncBranches.cs b/Setup/SyncBranches.cs index d48c31c5a..bb8774394 100644 --- a/Setup/SyncBranches.cs +++ b/Setup/SyncBranches.cs @@ -26,7 +26,7 @@ public class SyncBranches : IRunnable public string Target { get; set; } [Option('s', "skip_ci", Required = false, Default = true, HelpText = "Disable/Skip CI triggers for sync/merge.")] - public bool SkipCi { get; set; } + public bool? SkipCi { get; set; } public SyncBranches() { @@ -37,6 +37,8 @@ public SyncBranches() public void Run() { + SkipCi ??= false; + Console.WriteLine($"Syncing {Target} branch to {Base} branch..."); Git.Fetch(Base); @@ -54,11 +56,11 @@ public void Run() Git.Add(path); } - Git.Commit("Exclude Paths - Auto Commit", skipCi: SkipCi, allowEmpty: true); + Git.Commit("Exclude Paths - Auto Commit", skipCi: SkipCi.Value, allowEmpty: true); Git.Merge(Base); - Git.Commit($"Sync to {Base} - Auto Commit", skipCi: SkipCi, allowEmpty: true); + Git.Commit($"Sync to {Base} - Auto Commit", skipCi: SkipCi.Value, allowEmpty: true); Git.Push(); From 4ed71d70cf57ecfa077867e5eeb57acf6dd52fef Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 14:30:17 +0300 Subject: [PATCH 46/73] changed setup ref --- .github/workflows/sync_branches.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index 3033c9bee..8c8d0e6a1 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -36,7 +36,7 @@ env: jobs: setup: name: Sync Branches ♾️ - uses: ChainSafe/web3.unity/.github/workflows/setup.yaml@main + uses: ChainSafe/web3.unity/.github/workflows/setup.yaml@rob/sync-branches-ci-fix with: arguments: "sync -b ${{ env.base }} -t ${{ env.taret }} -s ${{ env.skip_ci }}" secrets: inherit \ No newline at end of file From 336deb71edc91a4c18d340e87192376dfe939eb9 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 14:32:43 +0300 Subject: [PATCH 47/73] typo fix --- .github/workflows/sync_branches.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index 8c8d0e6a1..868322b74 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -38,5 +38,5 @@ jobs: name: Sync Branches ♾️ uses: ChainSafe/web3.unity/.github/workflows/setup.yaml@rob/sync-branches-ci-fix with: - arguments: "sync -b ${{ env.base }} -t ${{ env.taret }} -s ${{ env.skip_ci }}" + arguments: "sync -b ${{ env.base }} -t ${{ env.target }} -s ${{ env.skip_ci }}" secrets: inherit \ No newline at end of file From 658187671df9453948440e4ef2f3fe6d8c714ad3 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 14:38:28 +0300 Subject: [PATCH 48/73] fixing some parsing issues --- .github/workflows/sync_branches.yaml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index 868322b74..00110345b 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -28,15 +28,10 @@ on: type: boolean default: true -env: - base: ${{ github.event.inputs.base || inputs.base }} - target: ${{ github.event.inputs.target || inputs.target }} - skip_ci: ${{ github.event.inputs.skip_ci || inputs.skip_ci }} - jobs: setup: name: Sync Branches ♾️ uses: ChainSafe/web3.unity/.github/workflows/setup.yaml@rob/sync-branches-ci-fix with: - arguments: "sync -b ${{ env.base }} -t ${{ env.target }} -s ${{ env.skip_ci }}" + arguments: "sync -b ${{ github.event.inputs.base || inputs.base }} -t ${{ github.event.inputs.target || inputs.target }} -s ${{ github.event.inputs.skip_ci || inputs.skip_ci }}" secrets: inherit \ No newline at end of file From 3d7e4075293999274aed77fba130fcfc5f759037 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 14:45:38 +0300 Subject: [PATCH 49/73] added a . at the end of path because git isn't finding path --- Setup/Git.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Setup/Git.cs b/Setup/Git.cs index 7b2125f6c..b47f2ef81 100644 --- a/Setup/Git.cs +++ b/Setup/Git.cs @@ -108,7 +108,7 @@ public static void Checkout(string branch, string path = "") if (!string.IsNullOrEmpty(path)) { - command += $" \"{path}\""; + command += $" \"{path}.\""; } Execute(command); From 3b26430a5a6f6e612d3fc5360dd4f5e7d01ced61 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 14:49:14 +0300 Subject: [PATCH 50/73] logging and trying something I found on git --- Setup/Git.cs | 2 +- Setup/Utils/Utilities.cs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Setup/Git.cs b/Setup/Git.cs index b47f2ef81..067bb8666 100644 --- a/Setup/Git.cs +++ b/Setup/Git.cs @@ -108,7 +108,7 @@ public static void Checkout(string branch, string path = "") if (!string.IsNullOrEmpty(path)) { - command += $" \"{path}.\""; + command += $" -- \"{path}\""; } Execute(command); diff --git a/Setup/Utils/Utilities.cs b/Setup/Utils/Utilities.cs index 6497f9114..628556f80 100644 --- a/Setup/Utils/Utilities.cs +++ b/Setup/Utils/Utilities.cs @@ -11,6 +11,8 @@ public static class Utilities { public static void Run(this string command) { + Console.WriteLine($"Running Command {command}..."); + // Tried switch statement couldn't find a way to make it work if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { @@ -27,8 +29,8 @@ public static void Run(this string command) throw new Exception($"[Unsupported OS] Can't run command: {command}"); } } - - public static void RunWithPowershell(this string command) + + private static void RunWithPowershell(this string command) { using (PowerShell powerShell = PowerShell.Create()) { @@ -52,7 +54,7 @@ public static void RunWithPowershell(this string command) /// /// Command to run. /// If command fails. - public static void RunWithBash( this string command) + private static void RunWithBash( this string command) { if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { From 106b1454a4f8a14f94ac50f9c187e46820456714 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 14:53:35 +0300 Subject: [PATCH 51/73] more logs and messing with directory --- Setup/Git.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Setup/Git.cs b/Setup/Git.cs index 067bb8666..a788b1c50 100644 --- a/Setup/Git.cs +++ b/Setup/Git.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using Setup.Utils; namespace Setup; @@ -106,9 +107,11 @@ public static void Checkout(string branch, string path = "") { string command = $"checkout {branch}"; + Console.WriteLine(Directory.GetCurrentDirectory()); + if (!string.IsNullOrEmpty(path)) { - command += $" -- \"{path}\""; + command += $" \"../{path}\""; } Execute(command); From 5bdf76742b2379cb48899153f27fce2bafb3fb88 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 14:56:44 +0300 Subject: [PATCH 52/73] fixed path --- Setup/Git.cs | 5 +---- Setup/SyncBranches.cs | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Setup/Git.cs b/Setup/Git.cs index a788b1c50..7b2125f6c 100644 --- a/Setup/Git.cs +++ b/Setup/Git.cs @@ -1,5 +1,4 @@ using System; -using System.IO; using Setup.Utils; namespace Setup; @@ -107,11 +106,9 @@ public static void Checkout(string branch, string path = "") { string command = $"checkout {branch}"; - Console.WriteLine(Directory.GetCurrentDirectory()); - if (!string.IsNullOrEmpty(path)) { - command += $" \"../{path}\""; + command += $" \"{path}\""; } Execute(command); diff --git a/Setup/SyncBranches.cs b/Setup/SyncBranches.cs index bb8774394..1f20e10a0 100644 --- a/Setup/SyncBranches.cs +++ b/Setup/SyncBranches.cs @@ -32,7 +32,7 @@ public SyncBranches() { Dependency[] dependencies = JsonConvert.DeserializeObject(File.ReadAllText("dependencies.json")); - _excludedPaths = Array.ConvertAll(dependencies, d => d.Path); + _excludedPaths = Array.ConvertAll(dependencies, d => $"../{d.Path}"); } public void Run() From c69af48c835b08cdaea76ed7b321e2e26b0fa8a7 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 14:58:34 +0300 Subject: [PATCH 53/73] allow unrelated histories --- Setup/Git.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Setup/Git.cs b/Setup/Git.cs index 7b2125f6c..9d2e0d85e 100644 --- a/Setup/Git.cs +++ b/Setup/Git.cs @@ -114,7 +114,7 @@ public static void Checkout(string branch, string path = "") Execute(command); } - public static void Merge(string branch, bool allowUnrelatedHistories = false) + public static void Merge(string branch, bool allowUnrelatedHistories = true) { string command = $"merge {branch}"; From 726aa2a4d5e29447a6f9e9035d1171f3d1f3ccf1 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 15:02:12 +0300 Subject: [PATCH 54/73] empty trigger From bdef4818f6da91a8f3612fbbaa7e09b422ad6fb5 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 15:09:47 +0300 Subject: [PATCH 55/73] more logging --- Setup/Git.cs | 4 ++++ Setup/Utils/Utilities.cs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Setup/Git.cs b/Setup/Git.cs index 9d2e0d85e..9ebe90346 100644 --- a/Setup/Git.cs +++ b/Setup/Git.cs @@ -116,6 +116,10 @@ public static void Checkout(string branch, string path = "") public static void Merge(string branch, bool allowUnrelatedHistories = true) { + Execute("reset --hard"); + + Execute("git status"); + string command = $"merge {branch}"; if (allowUnrelatedHistories) diff --git a/Setup/Utils/Utilities.cs b/Setup/Utils/Utilities.cs index 628556f80..e2e59ff00 100644 --- a/Setup/Utils/Utilities.cs +++ b/Setup/Utils/Utilities.cs @@ -11,7 +11,7 @@ public static class Utilities { public static void Run(this string command) { - Console.WriteLine($"Running Command {command}..."); + Console.WriteLine($"Running Command : {command}"); // Tried switch statement couldn't find a way to make it work if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) From 2535b6f908ef414cbfa70ad0451180912fdf7f43 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 15:10:39 +0300 Subject: [PATCH 56/73] typo fixed --- Setup/Git.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Setup/Git.cs b/Setup/Git.cs index 9ebe90346..a79e783ff 100644 --- a/Setup/Git.cs +++ b/Setup/Git.cs @@ -118,7 +118,7 @@ public static void Merge(string branch, bool allowUnrelatedHistories = true) { Execute("reset --hard"); - Execute("git status"); + Execute("status"); string command = $"merge {branch}"; From 9bf18911eda5099b9636bf4a532c17c2611b4658 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 15:15:03 +0300 Subject: [PATCH 57/73] trial without exclusion logic --- Setup/Git.cs | 4 ---- Setup/SyncBranches.cs | 16 ++++++++-------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Setup/Git.cs b/Setup/Git.cs index a79e783ff..9d2e0d85e 100644 --- a/Setup/Git.cs +++ b/Setup/Git.cs @@ -116,10 +116,6 @@ public static void Checkout(string branch, string path = "") public static void Merge(string branch, bool allowUnrelatedHistories = true) { - Execute("reset --hard"); - - Execute("status"); - string command = $"merge {branch}"; if (allowUnrelatedHistories) diff --git a/Setup/SyncBranches.cs b/Setup/SyncBranches.cs index 1f20e10a0..1ef56b96c 100644 --- a/Setup/SyncBranches.cs +++ b/Setup/SyncBranches.cs @@ -49,14 +49,14 @@ public void Run() Git.Checkout(Target); - foreach (string path in _excludedPaths) - { - Git.Checkout(Base, path); - - Git.Add(path); - } - - Git.Commit("Exclude Paths - Auto Commit", skipCi: SkipCi.Value, allowEmpty: true); + // foreach (string path in _excludedPaths) + // { + // Git.Checkout(Base, path); + // + // Git.Add(path); + // } + // + // Git.Commit("Exclude Paths - Auto Commit", skipCi: SkipCi.Value, allowEmpty: true); Git.Merge(Base); From 796afb891add7515d16edc10bb9034e5f9fb7323 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 15:17:12 +0300 Subject: [PATCH 58/73] reverted changes --- Setup/Git.cs | 2 ++ Setup/SyncBranches.cs | 16 ++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Setup/Git.cs b/Setup/Git.cs index 9d2e0d85e..c2cb742f3 100644 --- a/Setup/Git.cs +++ b/Setup/Git.cs @@ -22,6 +22,8 @@ public Git(bool enabled) public void Run() { Console.WriteLine($"Git {nameof(Enabled)} : {Enabled}"); + + Execute("status"); } private static void Execute(string command) diff --git a/Setup/SyncBranches.cs b/Setup/SyncBranches.cs index 1ef56b96c..1f20e10a0 100644 --- a/Setup/SyncBranches.cs +++ b/Setup/SyncBranches.cs @@ -49,14 +49,14 @@ public void Run() Git.Checkout(Target); - // foreach (string path in _excludedPaths) - // { - // Git.Checkout(Base, path); - // - // Git.Add(path); - // } - // - // Git.Commit("Exclude Paths - Auto Commit", skipCi: SkipCi.Value, allowEmpty: true); + foreach (string path in _excludedPaths) + { + Git.Checkout(Base, path); + + Git.Add(path); + } + + Git.Commit("Exclude Paths - Auto Commit", skipCi: SkipCi.Value, allowEmpty: true); Git.Merge(Base); From be45dc7a2fa7f1d291affdc55d8a26650643a63c Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 15:28:52 +0300 Subject: [PATCH 59/73] added git log on checkout --- Setup/Git.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Setup/Git.cs b/Setup/Git.cs index c2cb742f3..565881f2e 100644 --- a/Setup/Git.cs +++ b/Setup/Git.cs @@ -114,6 +114,8 @@ public static void Checkout(string branch, string path = "") } Execute(command); + + Execute("log -1"); } public static void Merge(string branch, bool allowUnrelatedHistories = true) From ac4a02b64a431d1203dd579d94e3be39c4ec3262 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 15:31:47 +0300 Subject: [PATCH 60/73] reverted log --- Setup/Git.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Setup/Git.cs b/Setup/Git.cs index 565881f2e..c2cb742f3 100644 --- a/Setup/Git.cs +++ b/Setup/Git.cs @@ -114,8 +114,6 @@ public static void Checkout(string branch, string path = "") } Execute(command); - - Execute("log -1"); } public static void Merge(string branch, bool allowUnrelatedHistories = true) From d24c0e2bffa158d7ac3cc4ec75cf897eb11461f6 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 15:48:00 +0300 Subject: [PATCH 61/73] added some merge options --- Setup/Git.cs | 9 +++++++-- Setup/SyncBranches.cs | 11 ++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Setup/Git.cs b/Setup/Git.cs index c2cb742f3..db447245f 100644 --- a/Setup/Git.cs +++ b/Setup/Git.cs @@ -116,10 +116,15 @@ public static void Checkout(string branch, string path = "") Execute(command); } - public static void Merge(string branch, bool allowUnrelatedHistories = true) + public static void Merge(string branch, string message = "", bool allowUnrelatedHistories = true) { - string command = $"merge {branch}"; + string command = $"merge {branch} --no-edit --commit --no-ff"; + if (!string.IsNullOrEmpty(message)) + { + command += $" -m \"{message}\""; + } + if (allowUnrelatedHistories) { command += " --allow-unrelated-histories"; diff --git a/Setup/SyncBranches.cs b/Setup/SyncBranches.cs index 1f20e10a0..d7538a944 100644 --- a/Setup/SyncBranches.cs +++ b/Setup/SyncBranches.cs @@ -57,10 +57,15 @@ public void Run() } Git.Commit("Exclude Paths - Auto Commit", skipCi: SkipCi.Value, allowEmpty: true); + + string message = $"Sync to {Base} - Auto Commit"; + + if (SkipCi.Value) + { + message += " [skip ci]"; + } - Git.Merge(Base); - - Git.Commit($"Sync to {Base} - Auto Commit", skipCi: SkipCi.Value, allowEmpty: true); + Git.Merge(Base, message); Git.Push(); From dde4e9ed7f339fffe4065d6235a32230098e75ca Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 15:56:10 +0300 Subject: [PATCH 62/73] merging the other way --- Setup/SyncBranches.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Setup/SyncBranches.cs b/Setup/SyncBranches.cs index d7538a944..4fff8f0f7 100644 --- a/Setup/SyncBranches.cs +++ b/Setup/SyncBranches.cs @@ -49,6 +49,12 @@ public void Run() Git.Checkout(Target); + Git.Checkout(Base); + + Git.Merge(Target, $"Sync to {Target} - Auto Commit"); + + Git.Checkout(Target); + foreach (string path in _excludedPaths) { Git.Checkout(Base, path); From 685ae00cfbddeb34f1177f53b9cfb68599e7d7f2 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 15:58:21 +0300 Subject: [PATCH 63/73] reverted reverse merging --- Setup/SyncBranches.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Setup/SyncBranches.cs b/Setup/SyncBranches.cs index 4fff8f0f7..d7538a944 100644 --- a/Setup/SyncBranches.cs +++ b/Setup/SyncBranches.cs @@ -49,12 +49,6 @@ public void Run() Git.Checkout(Target); - Git.Checkout(Base); - - Git.Merge(Target, $"Sync to {Target} - Auto Commit"); - - Git.Checkout(Target); - foreach (string path in _excludedPaths) { Git.Checkout(Base, path); From d818f8ee40ef9c31887af8596ea785615dc50c3a Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 16:00:00 +0300 Subject: [PATCH 64/73] check if history is related --- Setup/SyncBranches.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Setup/SyncBranches.cs b/Setup/SyncBranches.cs index d7538a944..b9fe2a3b6 100644 --- a/Setup/SyncBranches.cs +++ b/Setup/SyncBranches.cs @@ -49,6 +49,8 @@ public void Run() Git.Checkout(Target); + $"git rev-list --count {Target}..{Base}".Run(); + foreach (string path in _excludedPaths) { Git.Checkout(Base, path); From 8321b39796ccf5d017492207ef9b74530a990169 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 16:04:40 +0300 Subject: [PATCH 65/73] checking target's last commits --- Setup/SyncBranches.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Setup/SyncBranches.cs b/Setup/SyncBranches.cs index b9fe2a3b6..43850b7a6 100644 --- a/Setup/SyncBranches.cs +++ b/Setup/SyncBranches.cs @@ -51,6 +51,10 @@ public void Run() $"git rev-list --count {Target}..{Base}".Run(); + "git log -5".Run(); + + $"git rev-list --count {Base}..{Target}".Run(); + foreach (string path in _excludedPaths) { Git.Checkout(Base, path); From 4e66aea615f0dc5943fca66300acad0df5720f83 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 16:09:07 +0300 Subject: [PATCH 66/73] more logs --- Setup/SyncBranches.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Setup/SyncBranches.cs b/Setup/SyncBranches.cs index 43850b7a6..befc8b555 100644 --- a/Setup/SyncBranches.cs +++ b/Setup/SyncBranches.cs @@ -49,11 +49,9 @@ public void Run() Git.Checkout(Target); - $"git rev-list --count {Target}..{Base}".Run(); + $"git log {Base} -n 3".Run(); - "git log -5".Run(); - - $"git rev-list --count {Base}..{Target}".Run(); + $"git log {Target} -n 3".Run(); foreach (string path in _excludedPaths) { From ddc158aca166d1dfbea1630877ef3f20246d6a41 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 16:13:01 +0300 Subject: [PATCH 67/73] one line logging --- Setup/SyncBranches.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Setup/SyncBranches.cs b/Setup/SyncBranches.cs index befc8b555..c246e811a 100644 --- a/Setup/SyncBranches.cs +++ b/Setup/SyncBranches.cs @@ -49,9 +49,9 @@ public void Run() Git.Checkout(Target); - $"git log {Base} -n 3".Run(); + $"git log {Base} --oneline -n 3".Run(); - $"git log {Target} -n 3".Run(); + $"git log {Target} --oneline -n 3".Run(); foreach (string path in _excludedPaths) { From 8e095f420a592ed248efdb5badb6938406c01f55 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 16:16:23 +0300 Subject: [PATCH 68/73] GH actions is running one commit branches :faceplam --- Setup/SyncBranches.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Setup/SyncBranches.cs b/Setup/SyncBranches.cs index c246e811a..d55ede9d0 100644 --- a/Setup/SyncBranches.cs +++ b/Setup/SyncBranches.cs @@ -49,9 +49,9 @@ public void Run() Git.Checkout(Target); - $"git log {Base} --oneline -n 3".Run(); + $"git rev-list --count {Base}".Run(); - $"git log {Target} --oneline -n 3".Run(); + $"git rev-list --count {Target}".Run(); foreach (string path in _excludedPaths) { From 017501d7437717244c1896f2194c4b0c6f37a9b3 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 16:18:48 +0300 Subject: [PATCH 69/73] what happens if I force pull do I get all the commits? --- Setup/SyncBranches.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Setup/SyncBranches.cs b/Setup/SyncBranches.cs index d55ede9d0..57cba6e21 100644 --- a/Setup/SyncBranches.cs +++ b/Setup/SyncBranches.cs @@ -49,7 +49,7 @@ public void Run() Git.Checkout(Target); - $"git rev-list --count {Base}".Run(); + "git pull -f".Run(); $"git rev-list --count {Target}".Run(); From 8ba436cfc9fcc31acef3784de0d2c8d92833cfb9 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 16:26:26 +0300 Subject: [PATCH 70/73] TIL GitHub only fetches one commit from head by default --- .github/workflows/setup.yaml | 1 + Setup/SyncBranches.cs | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/setup.yaml b/.github/workflows/setup.yaml index d024ed7a5..b48230a69 100644 --- a/.github/workflows/setup.yaml +++ b/.github/workflows/setup.yaml @@ -40,6 +40,7 @@ jobs: lfs: true ssh-key: ${{ secrets.DEPLOY_KEY }} submodules: recursive + fetch-depth: 100 - name: Setup .NET uses: actions/setup-dotnet@v3 with: diff --git a/Setup/SyncBranches.cs b/Setup/SyncBranches.cs index 57cba6e21..d7538a944 100644 --- a/Setup/SyncBranches.cs +++ b/Setup/SyncBranches.cs @@ -49,10 +49,6 @@ public void Run() Git.Checkout(Target); - "git pull -f".Run(); - - $"git rev-list --count {Target}".Run(); - foreach (string path in _excludedPaths) { Git.Checkout(Base, path); From 4579d1e4cba99ae5206505b8da30c39c7cc42890 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 20:35:30 +0300 Subject: [PATCH 71/73] revert back testing changes --- .github/workflows/push_checks_main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/push_checks_main.yml b/.github/workflows/push_checks_main.yml index 7af31545e..f8aadf201 100644 --- a/.github/workflows/push_checks_main.yml +++ b/.github/workflows/push_checks_main.yml @@ -2,13 +2,13 @@ name: Post Push Checks on: push: - branches: [ rob/sync-branches-ci-fix ] + branches: [ main ] jobs: sync_branches: name: Sync Branches ♾️ - uses: ChainSafe/web3.unity/.github/workflows/sync_branches.yaml@rob/sync-branches-ci-fix + uses: ChainSafe/web3.unity/.github/workflows/sync_branches.yaml@main with: - base: rob/sync-branches-ci-fix - target: rob/sync-branches-ci-fix-test-branch + base: main + target: dev secrets: inherit \ No newline at end of file From 14345c5e39a44bb25d7c85dd7c44386f36177db9 Mon Sep 17 00:00:00 2001 From: rob1997 Date: Thu, 28 Nov 2024 20:41:26 +0300 Subject: [PATCH 72/73] added back config input for sync dependencies --- .github/workflows/sync_dependencies.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/sync_dependencies.yaml b/.github/workflows/sync_dependencies.yaml index 97cac2d7f..500ff9b72 100644 --- a/.github/workflows/sync_dependencies.yaml +++ b/.github/workflows/sync_dependencies.yaml @@ -3,6 +3,15 @@ name: Sync Dependencies 🔄 on: workflow_call: workflow_dispatch: + inputs: + configuration: + required: true + description: 'Run Configuration' + default: 'Release' + type: choice + options: + - Release + - Debug jobs: setup: From 6cf695c8aa02f564e4dba689a2dd0ce596d573ff Mon Sep 17 00:00:00 2001 From: rob1997 Date: Tue, 3 Dec 2024 12:49:20 +0300 Subject: [PATCH 73/73] ci shouldn't be skipped on dev (for extra commits) --- .github/workflows/push_checks_main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/push_checks_main.yml b/.github/workflows/push_checks_main.yml index f8aadf201..025d8c5a3 100644 --- a/.github/workflows/push_checks_main.yml +++ b/.github/workflows/push_checks_main.yml @@ -11,4 +11,5 @@ jobs: with: base: main target: dev + skip_ci: false secrets: inherit \ No newline at end of file