Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(workflows): add ci and release workflows #83

Merged
merged 19 commits into from
Dec 31, 2024
102 changes: 102 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
# test:
# name: Run Tests
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3

# # Git LFS
# - name: Create LFS file list
# run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id

# - name: Restore LFS cache
# uses: actions/cache@v3
# id: lfs-cache
# with:
# path: .git/lfs
# key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}

# - name: Git LFS Pull
# run: |
# git lfs pull
# git add .
# git reset --hard

# # Cache
# - uses: actions/cache@v3
# with:
# path: Library
# key: Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
# restore-keys: |
# Library-

# - name: Run Unity Tests
# uses: game-ci/unity-test-runner@v4
# env:
# UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
# UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
# UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
# with:
# projectPath: .
# testMode: all
# artifactsPath: TestResults
# githubToken: ${{ secrets.GITHUB_TOKEN }}

# - name: Upload Test Results
# uses: actions/upload-artifact@v3
# if: always()
# with:
# name: Test Results
# path: TestResults

format:
name: Check Code Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.0.x'

- name: Install dotnet-format
run: dotnet tool install -g dotnet-format

# Create a temporary solution and add all .cs files
- name: Create temporary solution
run: |
# Create a temporary directory for the solution
mkdir -p _temp
cd _temp

# Create a new solution
dotnet new sln -n TempSolution

# Create a temporary project and add all .cs files
dotnet new classlib -n TempProject
rm ./TempProject/Class1.cs

# Copy all .cs files from Assets to the temp project (adjust paths as needed)
find ../Assets -name "*.cs" -exec cp {} ./TempProject/ \;

# Add project to solution
dotnet sln add ./TempProject/TempProject.csproj

cd ..

# Run dotnet format on the temporary solution
- name: Check C# Formatting
run: dotnet format ./_temp/TempSolution.sln --verify-no-changes --verbosity detailed --severity error

# Cleanup
- name: Cleanup temporary files
run: rm -rf _temp
61 changes: 61 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Release

on:
release:
types: [created]

jobs:
build:
name: Build Package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
lfs: true

# Git LFS
- name: Create LFS file list
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id

- name: Restore LFS cache
uses: actions/cache@v3
id: lfs-cache
with:
path: .git/lfs
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}

- name: Git LFS Pull
run: |
git lfs pull
git add .
git reset --hard

# Unity Cache
- uses: actions/cache@v3
with:
path: Library
key: Library-Build-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
restore-keys: |
Library-Build-

# Build
- name: Build Unity Package
uses: game-ci/unity-builder@v4
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
targetPlatform: StandaloneLinux64
buildMethod: Editor.Builder.BuildPackage

# Upload package to release
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./Build/dojo.unitypackage
asset_name: dojo.unitypackage
asset_content_type: application/octet-stream
2 changes: 1 addition & 1 deletion Assets/Dojo/Runtime/Starknet/BurnerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public async Task<Account> DeployBurner(SigningKey signingKey = null)

Burners.Add(await masterAccount.DeployBurner(provider, signingKey));
currentBurnerIndex = Burners.Count - 1;


if (UseStorage)
{
Expand Down
6 changes: 4 additions & 2 deletions Assets/Dojo/Runtime/Starknet/FieldElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

namespace Dojo.Starknet
{
class FieldElementConverter : JsonConverter {
class FieldElementConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
return objectType == typeof(FieldElement);
Expand Down Expand Up @@ -84,7 +85,8 @@ public FieldElement(Span<byte> bytes)
// This handles BigIntegers as well as primitive types
public FieldElement(BigInteger bigInteger)
{
if (bigInteger.Sign < 0) {
if (bigInteger.Sign < 0)
{
bigInteger = StarkField - bigInteger;
}

Expand Down
27 changes: 18 additions & 9 deletions Assets/Dojo/Runtime/Starknet/Helpers/ExecutionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,50 @@
using Dojo.Starknet;
using dojo_bindings;

namespace Starknet {
public struct Call {
namespace Starknet
{
public struct Call
{
public FieldElement contractAddress;
public string selector;
public FieldElement[] calldata;

public Call(FieldElement contractAddress, string selector, params FieldElement[] calldata) {
public Call(FieldElement contractAddress, string selector, params FieldElement[] calldata)
{
this.contractAddress = contractAddress;
this.selector = selector;
this.calldata = calldata;
}
}

// A helper class for constructing and executing Starknet transactions.
public class ExecutionHelper {
public class ExecutionHelper
{
public Account account { get; }
private List<Call> calls;

public ExecutionHelper(Account account) {
public ExecutionHelper(Account account)
{
this.account = account;
calls = new List<Call>();
}

public ExecutionHelper AddCall(Call call) {
public ExecutionHelper AddCall(Call call)
{
calls.Add(call);
return this;
}

public ExecutionHelper AddCall(FieldElement contractAddress, string selector, params FieldElement[] calldata) {
public ExecutionHelper AddCall(FieldElement contractAddress, string selector, params FieldElement[] calldata)
{
var call = new Call(contractAddress, selector, calldata);
return AddCall(call);
}

public async Task<FieldElement> Execute() {
return await account.ExecuteRaw(calls.Select(call => new dojo.Call {
public async Task<FieldElement> Execute()
{
return await account.ExecuteRaw(calls.Select(call => new dojo.Call
{
to = call.contractAddress.Inner,
selector = call.selector,
calldata = call.calldata.Select(field => field.Inner).ToArray()
Expand Down
Loading
Loading