-
-
Notifications
You must be signed in to change notification settings - Fork 120
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
Document new buildProfile
config option
#498
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe documentation for the Unity Builder action in GitHub has been updated with a new configuration option Changes
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Once we've confirmed on the other PR, can we also take the changes in |
Sounds good. |
Relates to game-ci/unity-builder#674 Relates to game-ci/unity-builder#685
f78f98d
to
fb8c347
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
docs/03-github/04-builder.mdx
(1 hunks)example/BuildScript.cs
(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- docs/03-github/04-builder.mdx
🔇 Additional comments (1)
example/BuildScript.cs (1)
7-9
: LGTM! Proper version gating for Unity 6.0.0+ features.The conditional compilation directive ensures the new BuildProfile functionality is only available for Unity 6.0.0 or newer versions.
ExitWithResult(buildSummary.result); | ||
} | ||
#endif | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Update GetValidatedOptions for build profile support.
The GetValidatedOptions method should be updated to validate the customBuildProfile option when using Unity 6.0.0 or newer.
Apply this diff to update the method:
private static Dictionary<string, string> GetValidatedOptions()
{
ParseCommandLineArguments(out Dictionary<string, string> validatedOptions);
+#if UNITY_6000_0_OR_NEWER
+ // Validate customBuildProfile when using BuildWithProfile
+ if (validatedOptions.TryGetValue("buildWithProfile", out string useProfile) &&
+ useProfile.ToLower() == "true" &&
+ !validatedOptions.TryGetValue("customBuildProfile", out string _))
+ {
+ Console.WriteLine("Missing argument -customBuildProfile when buildWithProfile is true");
+ EditorApplication.Exit(140);
+ }
+#endif
Committable suggestion skipped: line range outside the PR's diff.
example/BuildScript.cs
Outdated
#if UNITY_6000_0_OR_NEWER | ||
public static void BuildWithProfile() | ||
{ | ||
// Gather values from args | ||
Dictionary<string, string> options = GetValidatedOptions(); | ||
|
||
// Load build profile from Assets folder | ||
BuildProfile buildProfile = AssetDatabase.LoadAssetAtPath<BuildProfile>(options["customBuildProfile"]); | ||
|
||
// Set it as active | ||
BuildProfile.SetActiveBuildProfile(buildProfile); | ||
|
||
// Define BuildPlayerWithProfileOptions | ||
buildPlayerWithProfileOptions = new BuildPlayerWithProfileOptions { | ||
buildProfile = buildProfile, | ||
locationPathName = options["customBuildPath"], | ||
options = buildOptions, | ||
}; | ||
|
||
BuildSummary buildSummary = BuildPipeline.BuildPlayer(buildPlayerWithProfileOptions).summary; | ||
ReportSummary(buildSummary); | ||
ExitWithResult(buildSummary.result); | ||
} | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix compilation errors and add validation.
The new BuildWithProfile method has several issues that need to be addressed:
- Missing variable declarations for
buildPlayerWithProfileOptions
andbuildOptions
- Missing validation for the required
customBuildProfile
option - Missing XML documentation for the public method
Apply this diff to fix the issues:
+ /// <summary>
+ /// Builds the Unity project using a build profile for Unity 6.0.0 or newer versions.
+ /// </summary>
public static void BuildWithProfile()
{
// Gather values from args
Dictionary<string, string> options = GetValidatedOptions();
+ // Validate build profile path
+ if (!options.TryGetValue("customBuildProfile", out string buildProfilePath))
+ {
+ Console.WriteLine("Missing argument -customBuildProfile");
+ EditorApplication.Exit(140);
+ }
+
// Load build profile from Assets folder
- BuildProfile buildProfile = AssetDatabase.LoadAssetAtPath<BuildProfile>(options["customBuildProfile"]);
+ BuildProfile buildProfile = AssetDatabase.LoadAssetAtPath<BuildProfile>(buildProfilePath);
+ if (buildProfile == null)
+ {
+ Console.WriteLine($"Failed to load build profile at path: {buildProfilePath}");
+ EditorApplication.Exit(141);
+ }
// Set it as active
BuildProfile.SetActiveBuildProfile(buildProfile);
+ // Define build options
+ BuildOptions buildOptions = BuildOptions.None;
+
// Define BuildPlayerWithProfileOptions
- buildPlayerWithProfileOptions = new BuildPlayerWithProfileOptions {
+ var buildPlayerWithProfileOptions = new BuildPlayerWithProfileOptions {
buildProfile = buildProfile,
locationPathName = options["customBuildPath"],
options = buildOptions,
};
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
#if UNITY_6000_0_OR_NEWER | |
public static void BuildWithProfile() | |
{ | |
// Gather values from args | |
Dictionary<string, string> options = GetValidatedOptions(); | |
// Load build profile from Assets folder | |
BuildProfile buildProfile = AssetDatabase.LoadAssetAtPath<BuildProfile>(options["customBuildProfile"]); | |
// Set it as active | |
BuildProfile.SetActiveBuildProfile(buildProfile); | |
// Define BuildPlayerWithProfileOptions | |
buildPlayerWithProfileOptions = new BuildPlayerWithProfileOptions { | |
buildProfile = buildProfile, | |
locationPathName = options["customBuildPath"], | |
options = buildOptions, | |
}; | |
BuildSummary buildSummary = BuildPipeline.BuildPlayer(buildPlayerWithProfileOptions).summary; | |
ReportSummary(buildSummary); | |
ExitWithResult(buildSummary.result); | |
} | |
#endif | |
#if UNITY_6000_0_OR_NEWER | |
/// <summary> | |
/// Builds the Unity project using a build profile for Unity 6.0.0 or newer versions. | |
/// </summary> | |
public static void BuildWithProfile() | |
{ | |
// Gather values from args | |
Dictionary<string, string> options = GetValidatedOptions(); | |
// Validate build profile path | |
if (!options.TryGetValue("customBuildProfile", out string buildProfilePath)) | |
{ | |
Console.WriteLine("Missing argument -customBuildProfile"); | |
EditorApplication.Exit(140); | |
} | |
// Load build profile from Assets folder | |
BuildProfile buildProfile = AssetDatabase.LoadAssetAtPath<BuildProfile>(buildProfilePath); | |
if (buildProfile == null) | |
{ | |
Console.WriteLine($"Failed to load build profile at path: {buildProfilePath}"); | |
EditorApplication.Exit(141); | |
} | |
// Set it as active | |
BuildProfile.SetActiveBuildProfile(buildProfile); | |
// Define build options | |
BuildOptions buildOptions = BuildOptions.None; | |
// Define BuildPlayerWithProfileOptions | |
var buildPlayerWithProfileOptions = new BuildPlayerWithProfileOptions { | |
buildProfile = buildProfile, | |
locationPathName = options["customBuildPath"], | |
options = buildOptions, | |
}; | |
BuildSummary buildSummary = BuildPipeline.BuildPlayer(buildPlayerWithProfileOptions).summary; | |
ReportSummary(buildSummary); | |
ExitWithResult(buildSummary.result); | |
} | |
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coderabbitai Good catch! I am updating this now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MichaelBuhler Thanks for addressing these issues! Looking forward to reviewing the updates.
If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved 1.
Skipping 2. and 3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MichaelBuhler Thanks for fixing the compilation errors! I understand your decision to skip the validation and documentation improvements. Let me know if you need any further assistance!
@davidmfinol I am pushed a simple implementation: 2f5ba2f I think that if the user is going to write their own build method for BuildProfile build, it is going to be quite simple and not muddied with supporting old platform builds. I don't really every see the need to go back to doing platform builds after adopting Unity 6 build profiles. |
fb8c347
to
2f5ba2f
Compare
|
||
// Set it as active | ||
BuildProfile.SetActiveBuildProfile(buildProfile); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Get all buildOptions from options | |
BuildOptions buildOptions = BuildOptions.None; | |
foreach (string buildOptionString in Enum.GetNames(typeof(BuildOptions))) { | |
if (options.ContainsKey(buildOptionString)) { | |
BuildOptions buildOptionEnum = (BuildOptions) Enum.Parse(typeof(BuildOptions), buildOptionString); | |
buildOptions |= buildOptionEnum; | |
} | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noticed that buildOptions isn't defined in the BuildScript
Relates to game-ci/unity-builder#674
Relates to game-ci/unity-builder#685
Changes
buildProfile
parameter unity-builder#685Checklist
code of conduct
Summary by CodeRabbit
buildProfile
configuration option.projectPath
value to<your repository root>
.