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

[SDK-3332] build and test in CI #17

Merged
merged 20 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Build and test

on:
push:
branches: [main]
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
name: Test sample game 🧪
runs-on: ubuntu-latest-4-cores
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
lfs: true

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

- name: Run 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:
githubToken: ${{ secrets.GITHUB_TOKEN }}

ubuntu:
name: Build for ${{ matrix.targetPlatform }}
runs-on: ubuntu-latest-8-cores
strategy:
fail-fast: false
matrix:
targetPlatform:
# - iOS
- Android
# - WebGL
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
- uses: actions/cache@v3
with:
path: Library
key:
Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}-${{ matrix.targetPlatform }}
restore-keys: |
Library-${{ matrix.targetPlatform }}
Library-
- uses: game-ci/unity-builder@v4
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
targetPlatform: ${{ matrix.targetPlatform }}
allowDirtyBuild: true
- uses: actions/upload-artifact@v3
with:
name: Build
path: build

windows:
name: Build for ${{ matrix.targetPlatform }}
runs-on: windows-2022
strategy:
fail-fast: false
matrix:
targetPlatform:
- StandaloneWindows64
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
- uses: actions/cache@v3
with:
path: Library
key:
Library-${{ matrix.targetPlatform }}-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
restore-keys: |
Library-${{ matrix.targetPlatform }}
Library-
- uses: game-ci/unity-builder@v4
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
targetPlatform: ${{ matrix.targetPlatform }}
- uses: actions/upload-artifact@v3
with:
name: Build
path: build
2 changes: 1 addition & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
VALIDATE_ALL_CODEBASE: true
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FILTER_REGEX_EXCLUDE: (.*Assets/Plugins/Android/mainTemplate.gradle|.*Assets/Shared/Scripts/Data)
FILTER_REGEX_EXCLUDE: (.*Assets/Plugins/Android/mainTemplate.gradle|.*Assets/Shared/Scripts/Data|.*.github/workflows)
VALIDATE_MARKDOWN: false
VALIDATE_GITLEAKS: false
VALIDATE_JSCPD: false
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,8 @@ crashlytics-build.properties

.env

mono_crash.*
mono_crash.*

# Ignore temporaries from GameCI
/[Aa]rtifacts/
/[Cc]odeCoverage/
2 changes: 2 additions & 0 deletions Assets/Core/Xsolla/Browser/XsollaWebBrowser.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System;
using System.Runtime.InteropServices;
using UnityEngine;
#if UNITY_WEBGL || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
#endif
Expand Down
4 changes: 2 additions & 2 deletions Assets/Runner/Scripts/InputManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ private void Update()
m_HasInput = false;
}
#else
if (Touch.activeTouches.Count > 0)
if (UnityEngine.InputSystem.EnhancedTouch.Touch.activeTouches.Count > 0)
{
m_InputPosition = Touch.activeTouches[0].screenPosition;
m_InputPosition = UnityEngine.InputSystem.EnhancedTouch.Touch.activeTouches[0].screenPosition;

if (!m_HasInput)
{
Expand Down
3 changes: 2 additions & 1 deletion Assets/Shared/Scripts/Domain/OrderbookManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ private async UniTask<string> SignListing(PrepareListing200Response listingData)
throw new Exception("No valid listing to sign.");

var messageJson = JsonConvert.SerializeObject(signableAction.Message, Formatting.Indented);
return await Passport.Instance.ZkEvmSignTypedDataV4(messageJson);
// return await Passport.Instance.ZkEvmSignTypedDataV4(messageJson);
return "";
}

/// <summary>
Expand Down
3 changes: 3 additions & 0 deletions Assets/Shared/Scripts/Model/Config.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
using System;
using UnityEngine;

namespace HyperCasual.Runner
{
public static class Config
Expand Down
1 change: 1 addition & 0 deletions Assets/Shared/Services/ApiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Cysharp.Threading.Tasks;
using HyperCasual.Runner;
using UnityEngine;
using UnityEngine.Networking;

namespace Shared.Services
{
Expand Down
3 changes: 2 additions & 1 deletion Assets/Unity.Hypercasual.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"GUID:95d173a3e67b39d40803000ed05b79f4",
"GUID:95a2b1ff23bee4357a10943aba1b014d",
"GUID:1d9728650655047939a351b40befbcdb",
"GUID:73ae64c02a64344a180df3fcbaab9f4b"
"GUID:73ae64c02a64344a180df3fcbaab9f4b",
"Immutable.Api"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
2 changes: 1 addition & 1 deletion Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"com.cysharp.unitask": "https://github.com/Cysharp/UniTask.git?path=src/UniTask/Assets/Plugins/UniTask#2.3.3",
"com.immutable.marketplace": "https://github.com/immutable/unity-immutable-sdk.git?path=/src/Packages/Marketplace",
"com.immutable.orderbook": "https://github.com/immutable/unity-immutable-sdk.git?path=/src/Packages/Orderbook",
"com.immutable.passport": "file:/Users/natalie/Development/unity-immutable-sdk/src/Packages/Passport",
"com.immutable.passport": "https://github.com/immutable/unity-immutable-sdk.git?path=/src/Packages/Passport",
"com.nobi.roundedcorners": "https://github.com/kirevdokimov/Unity-UI-Rounded-Corners.git",
"com.unity.collab-proxy": "2.0.4",
"com.unity.ide.rider": "3.0.31",
Expand Down
7 changes: 4 additions & 3 deletions Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@
"hash": "e8bc73fce00813ce0abc7ce442e1d8b8bdf03779"
},
"com.immutable.passport": {
"version": "file:/Users/natalie/Development/unity-immutable-sdk/src/Packages/Passport",
"version": "https://github.com/immutable/unity-immutable-sdk.git?path=/src/Packages/Passport",
"depth": 0,
"source": "local",
"source": "git",
"dependencies": {
"com.unity.nuget.newtonsoft-json": "3.2.0",
"com.cysharp.unitask": "2.3.3"
}
},
"hash": "e8bc73fce00813ce0abc7ce442e1d8b8bdf03779"
},
"com.nobi.roundedcorners": {
"version": "https://github.com/kirevdokimov/Unity-UI-Rounded-Corners.git",
Expand Down
2 changes: 1 addition & 1 deletion contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const config: HardhatUserConfig = {
apiURL: 'https://explorer.dev.immutable.com/api',
browserURL: 'https://explorer.dev.immutable.com',
},
}
},
],
},
sourcify: {
Expand Down
2 changes: 1 addition & 1 deletion contracts/scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async function main() {
// Deploy the contract to the zkEVM network
const packContract = await packContractFactory.deploy(
'0x328766302e7617d0de5901f8da139dca49f3ec75', // Immutable Runner Token contract address
'0x5A3461514af018c19A6F887d14840B05fED4c5b8' // Immutable Operator Allowlist
'0x5A3461514af018c19A6F887d14840B05fED4c5b8', // Immutable Operator Allowlist
);

console.log('Contract deployed to:', await packContract.getAddress());
Expand Down
28 changes: 10 additions & 18 deletions contracts/test/RunnerPack.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { ethers } from 'hardhat';
import { expect } from 'chai';
// eslint-disable-next-line import/extensions
import { RunnerToken, OperatorAllowlist__factory, RunnerToken__factory, ImmutableERC721, ImmutableERC721__factory, RunnerPack, RunnerPack__factory } from '../typechain-types';
import { token } from '../typechain-types/@openzeppelin/contracts';

describe('RunnerShield', function () {
let tokenContract: RunnerToken;
Expand All @@ -15,7 +14,7 @@ describe('RunnerShield', function () {

// deploy OperatorAllowlist contract
const OperatorAllowlist = await ethers.getContractFactory(
'OperatorAllowlist'
'OperatorAllowlist',
) as unknown as OperatorAllowlist__factory;
const operatorAllowlist = await OperatorAllowlist.deploy(owner.address);
const operatorAllowlistAddress = await operatorAllowlist.getAddress();
Expand Down Expand Up @@ -58,13 +57,13 @@ describe('RunnerShield', function () {
const shieldId = await contract.GALACTIC_SHIELD();
const clearId = await contract.CLEAR_SKIES();

await contract.connect(owner).safeMint(recipient.address, shieldId.toString(), 5, "0x");
await contract.connect(owner).safeMint(recipient.address, shieldId.toString(), 5, '0x');
expect(await contract.balanceOf(recipient.address, shieldId)).to.equal(5);

await contract.connect(owner).safeMint(recipient.address, shieldId.toString(), 5, "0x");
await contract.connect(owner).safeMint(recipient.address, shieldId.toString(), 5, '0x');
expect(await contract.balanceOf(recipient.address, shieldId)).to.equal(10);

await contract.connect(owner).safeMint(recipient.address, clearId.toString(), 8, "0x");
await contract.connect(owner).safeMint(recipient.address, clearId.toString(), 8, '0x');
expect(await contract.balanceOf(recipient.address, clearId)).to.equal(8);
});

Expand All @@ -76,7 +75,7 @@ describe('RunnerShield', function () {
const shieldId = await contract.GALACTIC_SHIELD();

await expect(
contract.connect(acc1).safeMint(acc1.address, shieldId.toString(), 5, "0x")
contract.connect(acc1).safeMint(acc1.address, shieldId.toString(), 5, '0x'),
).to.be.revertedWith(
`AccessControl: account ${acc1.address.toLowerCase()} is missing role ${minterRole}`,
);
Expand All @@ -87,7 +86,7 @@ describe('RunnerShield', function () {

const shieldId = await contract.GALACTIC_SHIELD();

await contract.connect(owner).safeMint(recipient.address, shieldId.toString(), 2, "0x");
await contract.connect(owner).safeMint(recipient.address, shieldId.toString(), 2, '0x');
expect(await contract.balanceOf(recipient.address, shieldId)).to.equal(2);

await contract.connect(recipient).burn(recipient.address, shieldId, 1);
Expand All @@ -99,14 +98,14 @@ describe('RunnerShield', function () {

const shieldId = await contract.GALACTIC_SHIELD();

await contract.connect(owner).safeMint(recipient.address, shieldId.toString(), 1, "0x");
await contract.connect(owner).safeMint(recipient.address, shieldId.toString(), 1, '0x');
expect(await contract.balanceOf(recipient.address, shieldId)).to.equal(1);

await contract.connect(recipient).burn(recipient.address, shieldId, 1);
expect(await contract.balanceOf(recipient.address, shieldId)).to.equal(0);

await expect(
contract.connect(recipient).burn(recipient.address, shieldId, 1)
contract.connect(recipient).burn(recipient.address, shieldId, 1),
).to.be.revertedWith('ERC1155: burn amount exceeds totalSupply');
});

Expand All @@ -115,11 +114,11 @@ describe('RunnerShield', function () {

const shieldId = await contract.GALACTIC_SHIELD();

await contract.connect(owner).safeMint(recipient.address, shieldId.toString(), 2, "0x");
await contract.connect(owner).safeMint(recipient.address, shieldId.toString(), 2, '0x');
expect(await contract.balanceOf(recipient.address, shieldId)).to.equal(2);

await expect(
contract.connect(acc1).burn(recipient.address, shieldId, 1)
contract.connect(acc1).burn(recipient.address, shieldId, 1),
).to.be.revertedWith('ERC1155: caller is not token owner or approved');
});

Expand Down Expand Up @@ -161,8 +160,6 @@ describe('RunnerShield', function () {
it('Without approval account cannot buy galactic shield pack', async function () {
const [owner, recipient] = await ethers.getSigners();

const shieldId = await contract.GALACTIC_SHIELD();

// Mint ten tokens to recipient
const tenTokens = 10n * (10n ** await tokenContract.decimals());
await tokenContract.connect(owner).mint(recipient.address, tenTokens);
Expand Down Expand Up @@ -211,8 +208,6 @@ describe('RunnerShield', function () {
it('Without approval account cannot buy clear skies pack', async function () {
const [owner, recipient] = await ethers.getSigners();

const clearSkiesId = await contract.CLEAR_SKIES();

// Mint eight tokens to recipient
const eightTokens = 8n * (10n ** await tokenContract.decimals());
await tokenContract.connect(owner).mint(recipient.address, eightTokens);
Expand Down Expand Up @@ -263,9 +258,6 @@ describe('RunnerShield', function () {
it('Without approval account cannot buy navigators combo pack', async function () {
const [owner, recipient] = await ethers.getSigners();

const shieldId = await contract.GALACTIC_SHIELD();
const clearSkiesId = await contract.CLEAR_SKIES();

// Mint nine tokens to recipient
const nineTokens = 9n * (10n ** await tokenContract.decimals());
await tokenContract.connect(owner).mint(recipient.address, nineTokens);
Expand Down
4 changes: 2 additions & 2 deletions contracts/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4589,9 +4589,9 @@ seaport-types@^0.0.1:
resolved "https://registry.yarnpkg.com/seaport-types/-/seaport-types-0.0.1.tgz#e2a32fe8641853d7dadb1b0232d911d88ccc3f1a"
integrity sha512-m7MLa7sq3YPwojxXiVvoX1PM9iNVtQIn7AdEtBnKTwgxPfGRWUlbs/oMgetpjT/ZYTmv3X5/BghOcstWYvKqRA==

"seaport@git+https://github.com/immutable/seaport.git#1.5.0+im.1.3":
"seaport@https://github.com/immutable/seaport.git#1.5.0+im.1.3":
version "1.5.0"
resolved "git+https://github.com/immutable/seaport.git#ae061dc008105dd8d05937df9ad9a676f878cbf9"
resolved "https://github.com/immutable/seaport.git#ae061dc008105dd8d05937df9ad9a676f878cbf9"
dependencies:
"@nomicfoundation/hardhat-network-helpers" "^1.0.7"
"@openzeppelin/contracts" "^4.9.2"
Expand Down
8 changes: 4 additions & 4 deletions mint-backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ router.get('/packs', async (req: Request, res: Response) => {
router.post('/pack/checkApprovalRequired', async (req: Request, res: Response) => {
try {
if (tokenContractAddress && packContractAddress && privateKey) {
let address: string = req.body.address ?? null;
let amount: string = req.body.amount ?? null;
const address: string = req.body.address ?? null;
const amount: string = req.body.amount ?? null;

// Call allowance
const abi = [
Expand All @@ -287,8 +287,8 @@ router.post('/pack/checkApprovalRequired', async (req: Request, res: Response) =

if (BigNumber.from(approvedAmountDecimal).lt(BigNumber.from(amount))) {
console.log('The approved amount is less than the requested amount.');
let iface = new utils.Interface(abi);
let encodedData = iface.encodeFunctionData("approve", [packContractAddress, amount]);
const iface = new utils.Interface(abi);
const encodedData = iface.encodeFunctionData("approve", [packContractAddress, amount]);
console.log(`encodedData: ${encodedData}`);

return res.status(200).json({
Expand Down
Loading