Skip to content

Commit

Permalink
CICD (#204)
Browse files Browse the repository at this point in the history
* Demo support

* Demo support

* Project path

* Print more info about the directory structure

* Print more diagnostic info

* repair symlink

* Copy manually folders

* Revert: Copy manually folders

* Manually create a project

* Copy without symlinks

* Correct copy directory

* Correct copy directory

* Correct copy directory

* Prepare folder

* Remove demo project from assets

* Remove demo project from assets

* Do not copy symlinks recursive

* Drop symlink

* Move project to the dir

* Use package

* Use different unity version

* package link

* correct YAML file

* correct YAML file

* fix YAML

* See the directory

* Correct project path

* Drop demo for now

* Use package directory insted

* Bring back backtrace untiy reference

* Use example test

* yaml formatting

* yaml formatting

* yaml formatting

* Project path

* 1 level project path

* package name

* Use different test action

* Bring back previous configuration

* Generate manually a game and add SDK to it

* Correct project path

* Correct project path

* Downgrade version and use custom parameters

* revert: Downgrade version and use custom parameters

* Drop unused env variables

* use cache and bring back env var

* Different approach to build and test app

* Changed unity version

* Remove plugins directory

* Clean up demo before copy-pasting it

* Simplify example

* Add correct unity license

* Use serial

* Use different unity version

* Specific runner version

* For testing purposes remove WaitForEndOfFrame

* fix tests

* fix tests

* Different test

* Waiter abstraction

* Add missing namespace

* Comp fixes

* Bring back yield return to tests

* Test against different unity versions

* Header name

* Bump 2018 version

* Bump unity versions to the latest lts

* Clean up the code

* Try to build a game

* Use serial

* Build name

* Divide workflow into two separated actions

* Project path

* Use specific untiy version

* Allow dirty

* Drop untiy version due to license issues and update build task name

* Change triggering conditions
  • Loading branch information
konraddysput authored Feb 6, 2024
1 parent dc0e304 commit 5073999
Show file tree
Hide file tree
Showing 21 changed files with 297 additions and 84 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build package

on:
push:
branches: [master]
pull_request:

jobs:
test:
name: Run Build for ${{ matrix.unityVersion }} ${{ matrix.unityVersion }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
projectPath:
- test-package
unityVersion:
- 2019.4.40f1
targetPlatform:
- StandaloneOSX
- StandaloneWindows
- StandaloneWindows64
- StandaloneLinux64
- iOS
- Android
- WebGL
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
lfs: true

- name: Setup Environment
run: |
mkdir ${{ matrix.projectPath }}
mv Editor Runtime Tests Android iOS Windows package.json ${{ matrix.projectPath }}/
- if: matrix.targetPlatform == 'Android'
uses: jlumbroso/[email protected]

- uses: game-ci/unity-builder@v4
name: Build game for platform ${{ matrix.targetPlatform }}
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
with:
unityVersion: ${{ matrix.unityVersion }}
targetPlatform: ${{ matrix.targetPlatform }}
projectPath: ${{ matrix.projectPath }}/
allowDirtyBuild: true
46 changes: 46 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Test package

on:
push:
branches: [master]
pull_request:

jobs:
test:
name: Run Tests in ${{ matrix.testMode }} ${{ matrix.unityVersion }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
testMode:
- playmode
# - editmode
projectPath:
- test-package
unityVersion:
- 2022.3.19f1
- 2019.4.40f1
- 2020.3.48f1
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
lfs: true

- name: Setup Environment
run: |
mkdir ${{ matrix.projectPath }}
mv Editor Runtime Tests Android iOS Windows package.json ${{ matrix.projectPath }}/
- name: Run Tests
uses: game-ci/[email protected]
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
with:
packageMode: true
projectPath: ${{ matrix.projectPath }}/
testMode: ${{ matrix.testMode }}
unityVersion: ${{ matrix.unityVersion }}
coverageOptions: "generateAdditionalMetrics;generateHtmlReport;generateBadgeReport;assemblyFilters:+my.assembly.*"
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions Runtime/BacktraceClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ private IEnumerator CollectDataAndSend(BacktraceReport report, Action<BacktraceR

if (Database != null && Database.Enabled())
{
yield return new WaitForEndOfFrame();
yield return WaitForFrame.Wait();
if (EnablePerformanceStatistics)
{
stopWatch.Restart();
Expand Down Expand Up @@ -885,7 +885,7 @@ record = Database.Add(data);
stopWatch.Stop();
queryAttributes["performance.json"] = stopWatch.GetMicroseconds();
}
yield return new WaitForEndOfFrame();
yield return WaitForFrame.Wait();
if (string.IsNullOrEmpty(json))
{
yield break;
Expand Down
25 changes: 25 additions & 0 deletions Runtime/Model/WaitForFrame.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Backtrace.Unity.Model.Waiter;
using UnityEngine;

namespace Backtrace.Unity.Model
{
public class WaitForFrame
{
private static IWaiter _waiter = CreateWaiterStrategy();

public static YieldInstruction Wait()
{
return _waiter.Wait();
}

private static IWaiter CreateWaiterStrategy()
{
if (Application.isBatchMode)
{
return new BatchModeWaiter();
}

return new EndOfFrameWaiter();
}
}
}
11 changes: 11 additions & 0 deletions Runtime/Model/WaitForFrame.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Runtime/Waiter.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Runtime/Waiter/BatchModeWaiter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using UnityEngine;

namespace Backtrace.Unity.Model.Waiter
{
public class BatchModeWaiter : IWaiter
{
public YieldInstruction Wait()
{
return null;
}
}
}
11 changes: 11 additions & 0 deletions Runtime/Waiter/BatchModeWaiter.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Runtime/Waiter/EndOfFrameWaiter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using UnityEngine;

namespace Backtrace.Unity.Model.Waiter
{
public class EndOfFrameWaiter : IWaiter
{
public YieldInstruction Wait()
{
return new WaitForEndOfFrame();
}
}
}
11 changes: 11 additions & 0 deletions Runtime/Waiter/EndOfFrameWaiter.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions Runtime/Waiter/IWaiter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Collections;
using UnityEngine;

namespace Backtrace.Unity.Model.Waiter
{
public interface IWaiter
{
YieldInstruction Wait();
}
}
11 changes: 11 additions & 0 deletions Runtime/Waiter/IWaiter.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Tests/Runtime/BacktraceAttributeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public IEnumerator TesClientAttributeAccessor_BacktraceDataShouldIncludeClientAt
return null;
};
BacktraceClient.Send(new Exception("foo"));
yield return new WaitForEndOfFrame();
yield return WaitForFrame.Wait();
Assert.IsNotNull(data);
Assert.AreEqual(data.Attributes.Attributes[key], value);
yield return null;
Expand All @@ -60,9 +60,9 @@ public IEnumerator TesClientAttributes_ReportShouldntExtendClientAttributes_Clie
foreach (var exceptionMessage in exceptionsMessage)
{
BacktraceClient.Send(new Exception(exceptionMessage));
yield return new WaitForEndOfFrame();
}

}
yield return WaitForFrame.Wait();
Assert.AreEqual(data.Attributes.Attributes[key], value);
Assert.AreEqual(numberOfKeysBeforeSendRequest, BacktraceClient.GetAttributesCount());
yield return null;
Expand All @@ -85,7 +85,7 @@ public IEnumerator TesClientAttributesMethod_BacktraceDataShouldIncludeClientAtt
return null;
};
BacktraceClient.Send(new Exception("foo"));
yield return new WaitForEndOfFrame();
yield return WaitForFrame.Wait();

Assert.IsNotNull(data);
Assert.AreEqual(data.Attributes.Attributes[key], value);
Expand Down
15 changes: 9 additions & 6 deletions Tests/Runtime/BacktraceClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public IEnumerator TestBeforeSendEvent_UpdateReportAttributesForUnhandledExcepti

var unhandledException = new BacktraceUnhandledException("foo", string.Empty);
BacktraceClient.Send(unhandledException);
yield return null;
yield return WaitForFrame.Wait();
}

[UnityTest]
Expand All @@ -108,7 +108,7 @@ public IEnumerator TestBeforeSendEvent_ValidConfiguration_EventTrigger()
return backtraceData;
};
BacktraceClient.Send(new Exception("test exception"));
yield return new WaitForEndOfFrame();
yield return WaitForFrame.Wait();
Assert.IsTrue(trigger);
yield return null;
}
Expand All @@ -128,7 +128,7 @@ public IEnumerator TestSendingReport_ValidConfiguration_ValidSend()
return new BacktraceResult();
};
BacktraceClient.Send(new Exception("test exception"));
yield return new WaitForEndOfFrame();
yield return WaitForFrame.Wait();
Assert.IsTrue(trigger);
yield return null;
}
Expand Down Expand Up @@ -217,9 +217,10 @@ public IEnumerator TestFingerprintBehaviorForNormalizedExceptionMessage_ShouldUs
return null;
};
BacktraceClient.Send(report);
yield return new WaitForEndOfFrame();
yield return WaitForFrame.Wait();

Assert.IsTrue(eventFired);
yield return null;
}

[Test]
Expand Down Expand Up @@ -284,15 +285,17 @@ public IEnumerator TestFingerprintBehaviorForNormalizedExceptionMessage_Shouldnt
return null;
};
BacktraceClient.Send(report);
yield return new WaitForEndOfFrame();
yield return WaitForFrame.Wait();
Assert.IsTrue(eventFired);
yield return null;
}


private IEnumerator CallBacktraceClientAndWait(BacktraceReport report)
{
BacktraceClient.Send(report);
yield return new WaitForEndOfFrame();
yield return WaitForFrame.Wait();

}
}
}
Loading

0 comments on commit 5073999

Please sign in to comment.