Skip to content

Commit a519e93

Browse files
committed
More refactoring
1 parent ec7256b commit a519e93

File tree

4 files changed

+70
-90
lines changed

4 files changed

+70
-90
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using RecipeEngine.Api.Commands;
2+
using RecipeEngine.Api.Extensions;
3+
using RecipeEngine.Api.Platforms;
4+
using RecipeEngine.Platforms;
5+
6+
namespace InputSystem.Cookbook.Recipes.Extensions;
7+
8+
internal static class CommandExtensions
9+
{
10+
public static Command WithPlatform(this Command command, Platform platform)
11+
{
12+
switch (platform.System)
13+
{
14+
case SystemType.Android:
15+
return command.Concat("--platform=android");
16+
case SystemType.IOS:
17+
return command.Concat("--platform=ios");
18+
case SystemType.TvOS:
19+
return command.Concat("--platform=tvOS");
20+
default:
21+
return command;
22+
}
23+
}
24+
}

Tools/CI/Recipes/MobileFunctionalTests.cs

Lines changed: 20 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using InputSystem.Cookbook.Recipes.Extensions;
12
using RecipeEngine.Api.Extensions;
23
using RecipeEngine.Api.Jobs;
34
using RecipeEngine.Modules.UnifiedTestRunner;
@@ -24,32 +25,21 @@ protected override IJobBuilder ProduceJob(string jobName, Package package, Platf
2425
.WithDescription(jobName)
2526
.WithPlatform(platform)
2627
.WithCommands(Utilities.GetEditorDownloadCommand(unityBranch, platform));
27-
28+
2829
var utrCommand = UtrCommand.Run(platform.System, b => b
29-
.WithTestProject($"{ProjectPath}")
30-
.WithEditor(".Editor")
31-
.WithSuite(UtrTestSuiteType.Playmode)
32-
.WithCategory("!Performance")
33-
.WithExtraArgs("--clean-library")
34-
.WithRerun(1, true)
35-
.WithBuildOnly()
36-
.WithPlayerSavePath("build/players")
37-
.WithArtifacts("build/logs"));
30+
.WithTestProject($"{ProjectPath}")
31+
.WithEditor(".Editor")
32+
.WithSuite(UtrTestSuiteType.Playmode)
33+
.WithCategory("!Performance")
34+
.WithExtraArgs("--clean-library")
35+
.WithRerun(1, true)
36+
.WithBuildOnly()
37+
.WithPlayerSavePath("build/players")
38+
.WithArtifacts("build/logs"))
39+
.WithPlatform(platform);
3840

39-
if (platform.System == SystemType.Android)
40-
{
41-
utrCommand = utrCommand.Concat("--platform=android");
42-
if(jobName.Contains("il2cpp"))
43-
utrCommand = utrCommand.Concat("--scripting-backend=il2cpp");
44-
}
45-
else if (platform.System == SystemType.TvOS)
46-
{
47-
utrCommand = utrCommand.Concat("--platform=tvOS");
48-
}
49-
else if (platform.System == SystemType.IOS)
50-
{
51-
utrCommand = utrCommand.Concat("--platform=ios");
52-
}
41+
if (platform.System == SystemType.Android && jobName.Contains("il2cpp"))
42+
utrCommand = utrCommand.Concat("--scripting-backend=il2cpp");
5343

5444
job.WithCommands(utrCommand)
5545
.WithArtifact(new Artifact("players", "build/players/**/*"), new Artifact("logs", "build/logs/**/*"))
@@ -100,24 +90,12 @@ protected override IJobBuilder ProduceJob(string jobName, Package package, Platf
10090
job.WithCommands(Settings.AndroidExtraCommands).WithAfterCommands(Settings.AndroidExtraAfterCommands);
10191

10292
var utrCommand = UtrCommand.Run(platform.System, b => b
103-
.WithSuite(UtrTestSuiteType.Playmode)
104-
.WithCategory("!Performance")
105-
.WithRerun(1)
106-
.WithPlayerLoadPath("build/players")
107-
.WithArtifacts("build/test-results"));
108-
109-
if (platform.System == SystemType.Android)
110-
{
111-
utrCommand = utrCommand.Concat("--platform=android");
112-
}
113-
else if (platform.System == SystemType.TvOS)
114-
{
115-
utrCommand = utrCommand.Concat("--platform=tvOS");
116-
}
117-
else if (platform.System == SystemType.IOS)
118-
{
119-
utrCommand = utrCommand.Concat("--platform=ios");
120-
}
93+
.WithSuite(UtrTestSuiteType.Playmode)
94+
.WithCategory("!Performance")
95+
.WithRerun(1)
96+
.WithPlayerLoadPath("build/players")
97+
.WithArtifacts("build/test-results"))
98+
.WithPlatform(platform);
12199

122100
job.WithCommands(utrCommand)
123101
.WithDependencies(buildJob)

Tools/CI/Recipes/MobilePerformanceTests.cs

Lines changed: 25 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using InputSystem.Cookbook.Recipes.Extensions;
12
using RecipeEngine.Api.Artifacts;
23
using RecipeEngine.Api.Dependencies;
34
using RecipeEngine.Api.Extensions;
@@ -24,34 +25,23 @@ protected override IJobBuilder ProduceJob(string jobName, Package package, Platf
2425
.WithDescription(jobName)
2526
.WithPlatform(platform)
2627
.WithCommands(Utilities.GetEditorDownloadCommand(unityBranch, platform));
27-
28+
2829
var utrCommand = UtrCommand.Run(platform.System, b => b
29-
.WithTestProject($"{ProjectPath}")
30-
.WithEditor(".Editor")
31-
.WithSuite(UtrTestSuiteType.Playmode)
32-
.WithCategory("Performance")
33-
.WithExtraArgs("--clean-library")
34-
.WithRerun(1, true)
35-
.WithBuildOnly()
36-
.WithPerformanceDataReporting(true)
37-
.WithPerformanceProject("InputSystem")
38-
.WithPlayerSavePath("build/players")
39-
.WithArtifacts("build/logs"));
30+
.WithTestProject($"{ProjectPath}")
31+
.WithEditor(".Editor")
32+
.WithSuite(UtrTestSuiteType.Playmode)
33+
.WithCategory("Performance")
34+
.WithExtraArgs("--clean-library")
35+
.WithRerun(1, true)
36+
.WithBuildOnly()
37+
.WithPerformanceDataReporting(true)
38+
.WithPerformanceProject("InputSystem")
39+
.WithPlayerSavePath("build/players")
40+
.WithArtifacts("build/logs"))
41+
.WithPlatform(platform);
4042

41-
if (platform.System == SystemType.Android)
42-
{
43-
utrCommand = utrCommand.Concat("--platform=android");
44-
if(jobName.Contains("il2cpp"))
45-
utrCommand = utrCommand.Concat("--scripting-backend=il2cpp");
46-
}
47-
else if (platform.System == SystemType.TvOS)
48-
{
49-
utrCommand = utrCommand.Concat("--platform=tvOS");
50-
}
51-
else if (platform.System == SystemType.IOS)
52-
{
53-
utrCommand = utrCommand.Concat("--platform=ios");
54-
}
43+
if (platform.System == SystemType.Android && jobName.Contains("il2cpp"))
44+
utrCommand = utrCommand.Concat("--scripting-backend=il2cpp");
5545

5646
job.WithCommands(utrCommand)
5747
.WithArtifact(new Artifact("players", "build/players/**/*"),
@@ -101,27 +91,15 @@ protected override IJobBuilder ProduceJob(string jobName, Package package, Platf
10191
job.WithCommands(Settings.AndroidExtraCommands).WithAfterCommands(Settings.AndroidExtraAfterCommands);
10292

10393
var utrCommand = UtrCommand.Run(platform.System, b => b
104-
.WithSuite(UtrTestSuiteType.Playmode)
105-
.WithCategory("Performance")
106-
.WithRerun(1)
107-
.WithPerformanceDataReporting(true)
108-
.WithPerformanceProject("InputSystem")
109-
.WithPlayerLoadPath("build/players")
110-
.WithArtifacts("build/test-results"));
111-
112-
if (platform.System == SystemType.Android)
113-
{
114-
utrCommand = utrCommand.Concat("--platform=android");
115-
}
116-
else if (platform.System == SystemType.TvOS)
117-
{
118-
utrCommand = utrCommand.Concat("--platform=tvOS");
119-
}
120-
else if (platform.System == SystemType.IOS)
121-
{
122-
utrCommand = utrCommand.Concat("--platform=ios");
123-
}
124-
94+
.WithSuite(UtrTestSuiteType.Playmode)
95+
.WithCategory("Performance")
96+
.WithRerun(1)
97+
.WithPerformanceDataReporting(true)
98+
.WithPerformanceProject("InputSystem")
99+
.WithPlayerLoadPath("build/players")
100+
.WithArtifacts("build/test-results"))
101+
.WithPlatform(platform);
102+
125103
job.WithCommands(utrCommand)
126104
.WithDependencies(buildJob)
127105
.WithArtifact(new Artifact("logs", "build/test-results/**/*"))

Tools/CI/Settings/InputSystemSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public InputSystemSettings()
9797

9898
var defaultUbuntuPlatform = WrenchPackage.DefaultEditorPlatforms[SystemType.Ubuntu];
9999
// Use Ubuntu image package-ci/ubuntu-22.04 which is required by 6000.0+ versions.
100-
Wrench.Packages["com.unity.inputsystem"].EditorPlatforms[SystemType.Ubuntu] = new Platform(new Agent("package-ci/ubuntu-22.04:default",
100+
InputSystemPackage.EditorPlatforms[SystemType.Ubuntu] = new Platform(new Agent("package-ci/ubuntu-22.04:default",
101101
defaultUbuntuPlatform.Agent.Flavor, defaultUbuntuPlatform.Agent.Resource), defaultUbuntuPlatform.System);
102102

103103
// ignore packages listed below in PreviewAPV

0 commit comments

Comments
 (0)