Skip to content

Commit 4294afd

Browse files
authored
Merge pull request #83 from dojoengine/workflows
chore(workflows): add ci and release workflows
2 parents 86a44f7 + c9ec5f3 commit 4294afd

24 files changed

+604
-283
lines changed

.github/workflows/ci.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
# test:
11+
# name: Run Tests
12+
# runs-on: ubuntu-latest
13+
# steps:
14+
# - uses: actions/checkout@v3
15+
16+
# # Git LFS
17+
# - name: Create LFS file list
18+
# run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
19+
20+
# - name: Restore LFS cache
21+
# uses: actions/cache@v3
22+
# id: lfs-cache
23+
# with:
24+
# path: .git/lfs
25+
# key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}
26+
27+
# - name: Git LFS Pull
28+
# run: |
29+
# git lfs pull
30+
# git add .
31+
# git reset --hard
32+
33+
# # Cache
34+
# - uses: actions/cache@v3
35+
# with:
36+
# path: Library
37+
# key: Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
38+
# restore-keys: |
39+
# Library-
40+
41+
# - name: Run Unity Tests
42+
# uses: game-ci/unity-test-runner@v4
43+
# env:
44+
# UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
45+
# UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
46+
# UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
47+
# with:
48+
# projectPath: .
49+
# testMode: all
50+
# artifactsPath: TestResults
51+
# githubToken: ${{ secrets.GITHUB_TOKEN }}
52+
53+
# - name: Upload Test Results
54+
# uses: actions/upload-artifact@v3
55+
# if: always()
56+
# with:
57+
# name: Test Results
58+
# path: TestResults
59+
60+
format:
61+
name: Check Code Format
62+
runs-on: ubuntu-latest
63+
steps:
64+
- uses: actions/checkout@v3
65+
66+
- name: Setup .NET
67+
uses: actions/setup-dotnet@v3
68+
with:
69+
dotnet-version: '6.0.x'
70+
71+
- name: Install dotnet-format
72+
run: dotnet tool install -g dotnet-format
73+
74+
# Create a temporary solution and add all .cs files
75+
- name: Create temporary solution
76+
run: |
77+
# Create a temporary directory for the solution
78+
mkdir -p _temp
79+
cd _temp
80+
81+
# Create a new solution
82+
dotnet new sln -n TempSolution
83+
84+
# Create a temporary project and add all .cs files
85+
dotnet new classlib -n TempProject
86+
rm ./TempProject/Class1.cs
87+
88+
# Copy all .cs files from Assets to the temp project (adjust paths as needed)
89+
find ../Assets -name "*.cs" -exec cp {} ./TempProject/ \;
90+
91+
# Add project to solution
92+
dotnet sln add ./TempProject/TempProject.csproj
93+
94+
cd ..
95+
96+
# Run dotnet format on the temporary solution
97+
- name: Check C# Formatting
98+
run: dotnet format ./_temp/TempSolution.sln --verify-no-changes --verbosity detailed --severity error
99+
100+
# Cleanup
101+
- name: Cleanup temporary files
102+
run: rm -rf _temp

.github/workflows/release.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
build:
9+
name: Build Package
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
with:
14+
lfs: true
15+
16+
# Git LFS
17+
- name: Create LFS file list
18+
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
19+
20+
- name: Restore LFS cache
21+
uses: actions/cache@v3
22+
id: lfs-cache
23+
with:
24+
path: .git/lfs
25+
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}
26+
27+
- name: Git LFS Pull
28+
run: |
29+
git lfs pull
30+
git add .
31+
git reset --hard
32+
33+
# Unity Cache
34+
- uses: actions/cache@v3
35+
with:
36+
path: Library
37+
key: Library-Build-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
38+
restore-keys: |
39+
Library-Build-
40+
41+
# Build
42+
- name: Build Unity Package
43+
uses: game-ci/unity-builder@v4
44+
env:
45+
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
46+
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
47+
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
48+
with:
49+
targetPlatform: StandaloneLinux64
50+
buildMethod: Editor.Builder.BuildPackage
51+
52+
# Upload package to release
53+
- name: Upload Release Asset
54+
uses: actions/upload-release-asset@v1
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
with:
58+
upload_url: ${{ github.event.release.upload_url }}
59+
asset_path: ./Build/dojo.unitypackage
60+
asset_name: dojo.unitypackage
61+
asset_content_type: application/octet-stream

Assets/Dojo/Runtime/Starknet/BurnerManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public async Task<Account> DeployBurner(SigningKey signingKey = null)
4848

4949
Burners.Add(await masterAccount.DeployBurner(provider, signingKey));
5050
currentBurnerIndex = Burners.Count - 1;
51-
51+
5252

5353
if (UseStorage)
5454
{

Assets/Dojo/Runtime/Starknet/FieldElement.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
namespace Dojo.Starknet
1212
{
13-
class FieldElementConverter : JsonConverter {
13+
class FieldElementConverter : JsonConverter
14+
{
1415
public override bool CanConvert(Type objectType)
1516
{
1617
return objectType == typeof(FieldElement);
@@ -84,7 +85,8 @@ public FieldElement(Span<byte> bytes)
8485
// This handles BigIntegers as well as primitive types
8586
public FieldElement(BigInteger bigInteger)
8687
{
87-
if (bigInteger.Sign < 0) {
88+
if (bigInteger.Sign < 0)
89+
{
8890
bigInteger = StarkField - bigInteger;
8991
}
9092

Assets/Dojo/Runtime/Starknet/Helpers/ExecutionHelper.cs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,50 @@
55
using Dojo.Starknet;
66
using dojo_bindings;
77

8-
namespace Starknet {
9-
public struct Call {
8+
namespace Starknet
9+
{
10+
public struct Call
11+
{
1012
public FieldElement contractAddress;
1113
public string selector;
1214
public FieldElement[] calldata;
1315

14-
public Call(FieldElement contractAddress, string selector, params FieldElement[] calldata) {
16+
public Call(FieldElement contractAddress, string selector, params FieldElement[] calldata)
17+
{
1518
this.contractAddress = contractAddress;
1619
this.selector = selector;
1720
this.calldata = calldata;
1821
}
1922
}
2023

2124
// A helper class for constructing and executing Starknet transactions.
22-
public class ExecutionHelper {
25+
public class ExecutionHelper
26+
{
2327
public Account account { get; }
2428
private List<Call> calls;
2529

26-
public ExecutionHelper(Account account) {
30+
public ExecutionHelper(Account account)
31+
{
2732
this.account = account;
2833
calls = new List<Call>();
2934
}
3035

31-
public ExecutionHelper AddCall(Call call) {
36+
public ExecutionHelper AddCall(Call call)
37+
{
3238
calls.Add(call);
3339
return this;
3440
}
3541

36-
public ExecutionHelper AddCall(FieldElement contractAddress, string selector, params FieldElement[] calldata) {
42+
public ExecutionHelper AddCall(FieldElement contractAddress, string selector, params FieldElement[] calldata)
43+
{
3744
var call = new Call(contractAddress, selector, calldata);
3845
return AddCall(call);
3946
}
4047

41-
public async Task<FieldElement> Execute() {
42-
return await account.ExecuteRaw(calls.Select(call => new dojo.Call {
48+
public async Task<FieldElement> Execute()
49+
{
50+
return await account.ExecuteRaw(calls.Select(call => new dojo.Call
51+
{
4352
to = call.contractAddress.Inner,
4453
selector = call.selector,
4554
calldata = call.calldata.Select(field => field.Inner).ToArray()

0 commit comments

Comments
 (0)