Skip to content

Commit a1e4dd1

Browse files
authored
Sync Branches CI fix (#1246)
* changed checkout ref to target and added base input * test run * workflow file ref changed * change the base branch since main and dev are upto date * added some logs for debugging * more logs * check with correct inputs * logs and added fetch just in case * cutting my losses and trying a third party action * skip ci added * skip CI inputs added * remove required from skip_ci input * apparently $ runs commands in bash * maybe pipe it * cutting my loses again * trying some stuff * trying something from stackoverflow * small edits * smaller edits * bash is so weird * message formatting * input options implemented * typo fix * more typo fixes :facepalm * reverted testing refs * typo fix * checking regular git commands if they work * logs and fetch * log latest commit * changed checkout branch at step removed branch log * log last commit command replaced * log status * checkout at base branch * added git branch to find base branch * trying more combinations * updated dev PR checks to trigger with multiple labels * setup now uses a proper command line parser * updated workflows with new command line parameters * updated local scripts with new arguments * text formatting * updated release argument * -r is also already in use, --deploy * typo fix * arguments fix for sync verb * fixed skip ci option * changed setup ref * typo fix * fixing some parsing issues * added a . at the end of path because git isn't finding path * logging and trying something I found on git * more logs and messing with directory * fixed path * allow unrelated histories * empty trigger * more logging * typo fixed * trial without exclusion logic * reverted changes * added git log on checkout * reverted log * added some merge options * merging the other way * reverted reverse merging * check if history is related * checking target's last commits * more logs * one line logging * GH actions is running one commit branches :faceplam * what happens if I force pull do I get all the commits? * TIL GitHub only fetches one commit from head by default * revert back testing changes * added back config input for sync dependencies * ci shouldn't be skipped on dev (for extra commits)
1 parent bb3879c commit a1e4dd1

16 files changed

+273
-130
lines changed

.github/workflows/duplicate_samples.yaml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,12 @@ name: Duplicate Samples 🪞
33
on:
44
workflow_call:
55
workflow_dispatch:
6-
inputs:
7-
arguments:
8-
required: false
9-
description: 'Run Arguments'
10-
type: string
11-
configuration:
12-
required: true
13-
description: 'Run Configuration'
14-
default: 'Release'
15-
type: choice
16-
options:
17-
- Release
18-
- Debug
196

207
jobs:
218
setup:
229
name: Duplicate Samples 🪞
2310
uses: ChainSafe/web3.unity/.github/workflows/setup.yaml@main
2411
with:
25-
arguments: "-duplicate_samples ${{ github.event.inputs.arguments || '-git:enabled' }} -c ${{ github.event.inputs.configuration || 'Release' }}"
12+
arguments: "-d"
2613
secrets: inherit
2714

.github/workflows/pull_request_checks_dev.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,21 @@ on:
99
- ready_for_review
1010

1111
jobs:
12+
pre_job:
13+
name: Pre Job 🚀
14+
runs-on: ubuntu-latest
15+
if: ${{ github.event.action == 'ready_for_review' || (!github.event.pull_request.draft && contains( github.event.pull_request.labels.*.name, 'ready-to-merge')) }}
16+
steps:
17+
- run: echo "Proceeding to checks..."
1218
web3_tests:
1319
name: Web3 tests 🕸
14-
if: ${{ github.event.action == 'ready_for_review' || github.event.label.name == 'ready-to-merge'}}
1520
uses: ChainSafe/web3.unity/.github/workflows/test.yaml@main
21+
needs: [ pre_job ]
1622
analyze_code:
1723
name: Analyze 🧐
18-
if: ${{ github.event.action == 'ready_for_review' || github.event.label.name == 'ready-to-merge'}}
1924
uses: ChainSafe/web3.unity/.github/workflows/codeql.yml@main
25+
needs: [ pre_job ]
2026
documentation_check:
2127
name: Documentation Check 📚
22-
uses: ChainSafe/web3.unity/.github/workflows/documentation_check.yml@main
28+
uses: ChainSafe/web3.unity/.github/workflows/documentation_check.yml@main
29+
needs: [ pre_job ]

.github/workflows/push_checks_main.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@ jobs:
99
name: Sync Branches ♾️
1010
uses: ChainSafe/web3.unity/.github/workflows/sync_branches.yaml@main
1111
with:
12-
branch: dev
12+
base: main
13+
target: dev
14+
skip_ci: false
1315
secrets: inherit

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
name: Setup job
1616
uses: ChainSafe/web3.unity/.github/workflows/setup.yaml@main
1717
with:
18-
arguments: "-release:${{ github.event.inputs.version }}"
18+
arguments: "--deploy ${{ github.event.inputs.version }}"
1919
secrets: inherit
2020
release:
2121
name: Release job

.github/workflows/setup.yaml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,24 @@ on:
66
arguments:
77
required: true
88
type: string
9+
configuration:
10+
required: false
11+
type: string
12+
default: "Release"
913
workflow_dispatch:
1014
inputs:
1115
arguments:
1216
required: true
1317
description: 'Arguments to pass to the setup script'
1418
type: string
19+
configuration:
20+
required: true
21+
description: 'Run Configuration'
22+
default: 'Release'
23+
type: choice
24+
options:
25+
- Release
26+
- Debug
1527
env:
1628
git_email: "${{ github.actor }}@users.noreply.github.com"
1729
git_actor: "${{ github.actor }}"
@@ -28,6 +40,7 @@ jobs:
2840
lfs: true
2941
ssh-key: ${{ secrets.DEPLOY_KEY }}
3042
submodules: recursive
43+
fetch-depth: 100
3144
- name: Setup .NET
3245
uses: actions/setup-dotnet@v3
3346
with:
@@ -36,10 +49,5 @@ jobs:
3649
- name: Run
3750
run: |
3851
cd Setup
39-
dotnet run ${{ inputs.arguments || github.event.inputs.arguments }} Setup/Setup.csproj
40-
git reset --hard
41-
- name: Cache
42-
uses: actions/cache/save@v4
43-
with:
44-
path: .git
45-
key: ${{ runner.os }}-git
52+
dotnet run ${{ inputs.arguments || github.event.inputs.arguments }} -c ${{ inputs.configuration || github.event.inputs.configuration }}
53+
git reset --hard
Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,37 @@
1-
name: Sync Branches
1+
name: Sync Branches ♾️
22

33
on:
44
workflow_call:
55
inputs:
6-
branch:
6+
base:
77
required: true
88
type: string
9+
target:
10+
required: true
11+
type: string
12+
skip_ci:
13+
type: boolean
14+
default: true
915
workflow_dispatch:
1016
inputs:
11-
branch:
17+
base:
1218
required: true
13-
description: "Branch to Sync"
19+
description: "Base branch to Sync"
1420
type: string
21+
target:
22+
required: true
23+
description: "Target branch to Sync"
24+
type: string
25+
skip_ci:
26+
required: true
27+
description: "Should push skip CI"
28+
type: boolean
29+
default: true
1530

1631
jobs:
1732
setup:
1833
name: Sync Branches ♾️
19-
runs-on: ubuntu-latest
20-
steps:
21-
- name: Checkout repository
22-
uses: actions/checkout@v4
23-
with:
24-
ref: ${{ github.head_ref || github.ref_name }}
25-
lfs: true
26-
ssh-key: ${{ secrets.DEPLOY_KEY }}
27-
- name: Sync Branches
28-
run: |
29-
git config user.email $git_email
30-
git config user.name $git_actor
31-
git fetch origin ${{ github.event.inputs.branch }}
32-
git checkout ${{ github.event.inputs.branch }}
33-
git pull
34-
git merge main --allow-unrelated-histories
35-
git push
36-
shell: bash
37-
env:
38-
git_email: "${{ github.actor }}@users.noreply.github.com"
39-
git_actor: "${{ github.actor }}"
34+
uses: ChainSafe/web3.unity/.github/workflows/setup.yaml@rob/sync-branches-ci-fix
35+
with:
36+
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 }}"
37+
secrets: inherit

.github/workflows/sync_dependencies.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ on:
44
workflow_call:
55
workflow_dispatch:
66
inputs:
7-
arguments:
8-
required: false
9-
description: 'Run Arguments'
10-
type: string
117
configuration:
128
required: true
139
description: 'Run Configuration'
@@ -22,6 +18,7 @@ jobs:
2218
name: Sync Dependencies 🔄
2319
uses: ChainSafe/web3.unity/.github/workflows/setup.yaml@main
2420
with:
25-
arguments: "-sync_dependencies ${{ github.event.inputs.arguments || '-git:enabled' }} -c ${{ github.event.inputs.configuration || 'Release' }}"
21+
arguments: "-s"
22+
configuration: ${{ github.event.inputs.configuration || 'Release' }}
2623
secrets: inherit
2724

Setup/DefaultOptions.cs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using System.Collections.Generic;
2+
using CommandLine;
3+
using Setup.Utils;
4+
5+
namespace Setup;
6+
7+
[Verb("do", true, HelpText = "Runs default options.")]
8+
public class DefaultOptions
9+
{
10+
[Option('s', "sync_dependencies", Required = false, Default = false, HelpText = "Generate and copy dependencies to Sample Project.")]
11+
public bool SyncDependencies { get; set; }
12+
13+
[Option('d', "duplicate_samples", Required = false, Default = false, HelpText = "Duplicate samples in Sample Project into package samples.")]
14+
public bool DuplicateSamples { get; set; }
15+
16+
[Option("deploy", Required = false, HelpText = "Version to release.")]
17+
public string Release { get; set; }
18+
19+
[Option('g', "git", Required = false, Default = true, HelpText = "Enable Git.")]
20+
public bool? EnableGit { get; set; }
21+
22+
public List<IRunnable> GetRunnableList()
23+
{
24+
List<IRunnable> runnableList = new List<IRunnable>();
25+
26+
if (SyncDependencies)
27+
{
28+
runnableList.Add(new SyncDependencies());
29+
}
30+
31+
if (DuplicateSamples)
32+
{
33+
runnableList.Add(new DuplicateSamples());
34+
}
35+
36+
if (!string.IsNullOrEmpty(Release))
37+
{
38+
runnableList.Add(new Release(Release));
39+
}
40+
41+
EnableGit ??= false;
42+
43+
runnableList.Add(new Git(EnableGit.Value));
44+
45+
return runnableList;
46+
}
47+
}

0 commit comments

Comments
 (0)