This repository was archived by the owner on Jun 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
RealNickk
committed
Oct 17, 2022
1 parent
096b660
commit d04756f
Showing
10 changed files
with
217 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,11 +5,11 @@ on: | |
branches: | ||
- main | ||
paths: | ||
- ".github/workflows/**" | ||
- "src/**" | ||
- ".github/workflows/**" # This is the path to the workflow files | ||
- "src/**" # Any source files | ||
|
||
env: | ||
GITHUB_ACTIONS: 1 | ||
IS_CI: 1 # Let the build know that it's running in CI, so it doesn't run stuff that'll fail | ||
|
||
jobs: | ||
ci: | ||
|
@@ -27,14 +27,28 @@ jobs: | |
- name: Setup NuGet | ||
uses: NuGet/[email protected] | ||
|
||
- name: Setup NUnit | ||
run: nuget install NUnit.ConsoleRunner -Version 3.15.2 -OutputDirectory nunit | ||
|
||
- name: Restore packages | ||
run: nuget restore src/Starlight.sln | ||
run: nuget restore Starlight.sln | ||
|
||
- name: Build solution | ||
run: msbuild.exe src/Starlight.sln -p:Configuration=Release | ||
run: msbuild.exe Starlight.sln -p:Configuration=Release | ||
|
||
- name: Run tests | ||
run: testrunner/NUnit.ConsoleRunner.3.15.2/tools/nunit3-console.exe src/Starlight.Test/bin/Release/Starlight.Test.dll | ||
|
||
- name: Upload artifacts | ||
uses: actions/[email protected] | ||
with: | ||
name: starlight-bundle | ||
path: "src/Starlight/bin/Release" | ||
name: bundle | ||
path: "bin/Release/" | ||
|
||
- name: Upload test artifacts # Maybe useful for debugging... | ||
uses: actions/[email protected] | ||
with: | ||
name: test-results | ||
path: | | ||
"TestResult.xml" | ||
"src/Starlight.Test/bin/Release/Logs/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
using NUnit.Framework; | ||
using Starlight.Core; | ||
using Starlight.Misc; | ||
using System; | ||
using System.IO; | ||
using System.Threading; | ||
|
||
namespace Starlight.Test | ||
{ | ||
[TestFixture] | ||
public class BootstrapperTests | ||
{ | ||
[OneTimeSetUp] | ||
public void InitLogger() | ||
{ | ||
Logger.Init(true); | ||
} | ||
|
||
[Test] | ||
public void GetLatestHash() | ||
{ | ||
try | ||
{ | ||
Bootstrapper.GetLatestHash(); | ||
} | ||
catch (BootstrapException) | ||
{ | ||
Assert.Inconclusive("Couldn't fetch latest hash."); | ||
} | ||
} | ||
|
||
[Test] | ||
public void FetchManifest() | ||
{ | ||
var manifest = Bootstrapper.GetManifest(Bootstrapper.GetLatestHash()); | ||
if (manifest is null) | ||
Assert.Inconclusive("Couldn't fetch manifest."); | ||
} | ||
|
||
static void PreNativeInstall() | ||
{ | ||
var localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); | ||
var installPath = Path.Combine(localAppData, "Roblox"); | ||
|
||
// Uninstall Roblox if it's installed. | ||
if (Directory.Exists(installPath)) | ||
Directory.Delete(installPath, true); | ||
} | ||
|
||
[Test] | ||
public void NativeInstall() | ||
{ | ||
Env.AssertCi(); | ||
|
||
PreNativeInstall(); | ||
try | ||
{ | ||
var client = Bootstrapper.NativeInstall(); | ||
Assert.IsFalse(client is null, "Client installation failed."); | ||
} | ||
catch (BootstrapException ex) | ||
{ | ||
Assert.Fail("Client installation failed: " + ex.Message, ex); | ||
} | ||
Thread.Sleep(1000); // idk bruh it works lol | ||
} | ||
|
||
[Test] | ||
public void Query() | ||
{ | ||
Env.AssertCi(); | ||
|
||
if (Bootstrapper.GetClients().Count < 1) | ||
Bootstrapper.Install(); | ||
|
||
var clients = Bootstrapper.GetClients(); | ||
if (clients.Count < 1) | ||
Assert.Fail("Failed to find any clients."); | ||
|
||
var client = Bootstrapper.QueryClient(clients[0].Hash); | ||
Assert.IsFalse(client is null, "Client query failed."); | ||
} | ||
|
||
[Test] | ||
public void Uninstall() | ||
{ | ||
Env.AssertCi(); | ||
|
||
if (Bootstrapper.GetClients().Count < 1) | ||
Bootstrapper.Install(); | ||
|
||
var clients = Bootstrapper.GetClients(); | ||
Bootstrapper.Uninstall(clients[0]); | ||
} | ||
|
||
[Test] | ||
public void Install() | ||
{ | ||
Env.AssertCi(); | ||
|
||
var client = Bootstrapper.Install(); | ||
if (client is null) | ||
Assert.Fail("Client installation failed."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using NUnit.Framework; | ||
|
||
namespace Starlight.Test | ||
{ | ||
internal class Env | ||
{ | ||
public static bool IsCi => Environment.GetEnvironmentVariable("IS_CI") is not null; | ||
|
||
public static string AuthToken => Environment.GetEnvironmentVariable("AUTH_TOKEN"); | ||
|
||
public static void AssertCi() | ||
{ | ||
if (IsCi) | ||
Assert.Inconclusive("Cannot run this test on CI."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using NUnit.Framework; | ||
using Starlight.Misc; | ||
|
||
namespace Starlight.Test | ||
{ | ||
[TestFixture, Order(1)] | ||
internal class Initial | ||
{ | ||
[OneTimeSetUp] | ||
public void Initialize() | ||
{ | ||
Logger.Init(true); | ||
if (Env.IsCi) | ||
Console.WriteLine("Running on CI. ENSURE THAT INCONCLUSIVE TESTS PASS BEFORE YOU MERGE A PR!"); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using NUnit.Framework; | ||
using Starlight.Core; | ||
using Starlight.Rbx; | ||
using Starlight.Rbx.JoinGame; | ||
|
||
namespace Starlight.Test | ||
{ | ||
[TestFixture, Order(2)] | ||
public class LauncherTests | ||
{ | ||
[Test] | ||
public void Launch() | ||
{ | ||
Env.AssertCi(); | ||
|
||
if (Bootstrapper.GetClients().Count < 1) | ||
Bootstrapper.Install(); | ||
|
||
if (Env.AuthToken is null) | ||
Assert.Inconclusive("No Roblox token was provided. Please set the AUTH_TOKEN environment variable."); | ||
|
||
var session = Session.Login(Env.AuthToken); | ||
var ticket = session.GetTicket(); | ||
|
||
var info = new LaunchParams | ||
{ | ||
// Roblox join stuff. | ||
Ticket = ticket, | ||
Request = new JoinRequest | ||
{ | ||
PlaceId = 4483381587, // https://www.roblox.com/games/4483381587/a-literal-baseplate | ||
ReqType = JoinType.Auto | ||
}, | ||
|
||
// Should make everything run | ||
FpsCap = 160, | ||
Headless = true, | ||
Spoof = true, | ||
Resolution = "800x600" | ||
}; | ||
|
||
// Launch Roblox | ||
var inst = Launcher.Launch(info); | ||
if (inst is null) | ||
Assert.Fail("Failed to launch Roblox."); | ||
|
||
inst.Proc.Kill(); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.