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

feat: add buildProfile parameter #685

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

MichaelBuhler
Copy link
Collaborator

@MichaelBuhler MichaelBuhler commented Jan 29, 2025

add new buildProfile action param, which will be passed into Unity as -customBuildProfile ... on the CLI. The build script will detect this and, if the Unity version supports build profiles, will run the build pipeline using the requested build profile.

closes #674

Changes

  • Add a new buildProfile GitHub action parameter to support Unity's new Build Profiles.

Related Issues

Related PRs

Successful Workflow Run Link

  • I provided an edit to the test workflow in this repo:

Checklist

Summary by CodeRabbit

Release Notes

  • New Features

    • Added optional buildProfile input parameter to enhance build configuration flexibility.
    • Introduced ability to specify a custom build profile path relative to the project root.
    • Added a static getter method for buildProfile in the Input class to improve input handling.
    • Enhanced environment variable handling to support custom build profiles.
    • Expanded build matrix in GitHub Actions to include configurations for WebGL builds with specified build profiles.
  • Documentation

    • Clarified projectPath input description to specify path relative to repository root.
  • Tests

    • Added new test cases to verify functionality related to the buildProfile property across relevant classes.

Copy link

Cat Gif

Copy link

coderabbitai bot commented Jan 29, 2025

📝 Walkthrough

Walkthrough

The pull request introduces a new buildProfile input parameter to the GitHub Action workflow. This parameter allows users to specify a path to a build profile relative to the project root. The changes span multiple files, including action.yml, input.ts, input.test.ts, build-parameters.ts, build-parameters.test.ts, and image-environment-factory.ts. The modifications enhance the configuration flexibility by adding support for specifying a build profile path and improving the clarity of existing input parameter descriptions.

Changes

File Changes
action.yml - Added optional buildProfile input parameter
- Updated projectPath description to clarify repository root reference
src/model/input.ts - Added static getter method buildProfile
src/model/input.test.ts - Added test suite for buildProfile property
src/model/build-parameters.ts - Added public buildProfile property
src/model/build-parameters.test.ts - Added test to verify buildProfile retrieval
src/model/image-environment-factory.ts - Added BUILD_PROFILE environment variable
src/model/platform-setup/setup-mac.ts - Set BUILD_PROFILE environment variable based on buildParameters.buildProfile
.github/workflows/build-tests-ubuntu.yml - Added configurations for unityVersion and buildProfile for WebGL
test-project/Assets/Settings.meta - Created new metadata file for asset folder
test-project/Assets/Settings/Build Profiles.meta - Created new metadata file for build profile folder
test-project/Assets/Settings/Build Profiles/Sample WebGL Build Profile.asset.meta - Created new metadata structure for Sample WebGL Build Profile

Assessment against linked issues

Objective Addressed Explanation
Support activeBuildProfile parameter [#674]
Allow specifying build profile path
Improve input parameter clarity

Poem

🐰 A rabbit's build tale unfolds with glee,
New profile paths, now set so free!
Configuration dancing, clear and bright,
GitHub Action's magic takes flight! 🚀
Hop, hop, hooray for code so neat! 🎉


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/model/input.test.ts (1)

62-73: LGTM! Consider adding edge case tests.

The test suite follows the established pattern and properly verifies both default value and user input scenarios.

Consider adding the following test cases to improve coverage:

  1. Invalid file paths (e.g., paths with invalid characters)
  2. Relative vs absolute paths
  3. File extension validation (if required)

Example:

it('handles invalid file paths gracefully', () => {
  const mockValue = 'invalid/*/path';
  const spy = jest.spyOn(core, 'getInput').mockReturnValue(mockValue);
  expect(Input.buildProfile).toStrictEqual(mockValue);
  expect(spy).toHaveBeenCalledTimes(1);
});

it('handles absolute paths', () => {
  const mockValue = '/absolute/path/to/build_profile.asset';
  const spy = jest.spyOn(core, 'getInput').mockReturnValue(mockValue);
  expect(Input.buildProfile).toStrictEqual(mockValue);
  expect(spy).toHaveBeenCalledTimes(1);
});
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4f3bec8 and 21e3152.

⛔ Files ignored due to path filters (5)
  • dist/index.js is excluded by !**/dist/**
  • dist/index.js.map is excluded by !**/dist/**, !**/*.map
  • dist/platforms/mac/steps/build.sh is excluded by !**/dist/**
  • dist/platforms/ubuntu/steps/build.sh is excluded by !**/dist/**
  • dist/platforms/windows/build.ps1 is excluded by !**/dist/**
📒 Files selected for processing (7)
  • action.yml (1 hunks)
  • src/model/build-parameters.test.ts (1 hunks)
  • src/model/build-parameters.ts (2 hunks)
  • src/model/image-environment-factory.ts (1 hunks)
  • src/model/input.test.ts (1 hunks)
  • src/model/input.ts (1 hunks)
  • src/model/platform-setup/setup-mac.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/model/platform-setup/setup-mac.ts
  • src/model/build-parameters.ts
  • src/model/input.ts
  • src/model/build-parameters.test.ts
  • action.yml
  • src/model/image-environment-factory.ts

add new `buildProfile` action param, which will be passed into
Unity as the `-activeBuildProfile ...` CLI param.

closes game-ci#674
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/model/input.test.ts (1)

62-74: LGTM! Consider adding validation test cases.

The test suite follows the established patterns and correctly verifies both default value and user input scenarios. The implementation is clean and consistent with other test suites in the file.

Consider adding test cases to verify:

  1. Path validation (if any)
  2. Handling of invalid paths
  3. Path normalization (if implemented)

Example test case structure:

it('handles invalid path characters', () => {
  const mockValue = 'path\\with\\invalid/mixed/separators';
  const spy = jest.spyOn(core, 'getInput').mockReturnValue(mockValue);
  expect(Input.buildProfile).toStrictEqual(/* expected normalized path */);
  expect(spy).toHaveBeenCalledTimes(1);
});
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 21e3152 and 3a87506.

⛔ Files ignored due to path filters (6)
  • dist/default-build-script/Assets/Editor/UnityBuilderAction/Builder.cs is excluded by !**/dist/**
  • dist/index.js is excluded by !**/dist/**
  • dist/index.js.map is excluded by !**/dist/**, !**/*.map
  • dist/platforms/mac/steps/build.sh is excluded by !**/dist/**
  • dist/platforms/ubuntu/steps/build.sh is excluded by !**/dist/**
  • dist/platforms/windows/build.ps1 is excluded by !**/dist/**
📒 Files selected for processing (7)
  • action.yml (1 hunks)
  • src/model/build-parameters.test.ts (1 hunks)
  • src/model/build-parameters.ts (2 hunks)
  • src/model/image-environment-factory.ts (1 hunks)
  • src/model/input.test.ts (1 hunks)
  • src/model/input.ts (1 hunks)
  • src/model/platform-setup/setup-mac.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/model/platform-setup/setup-mac.ts
  • src/model/build-parameters.ts
  • src/model/build-parameters.test.ts
  • src/model/image-environment-factory.ts
  • src/model/input.ts
  • action.yml

@MichaelBuhler MichaelBuhler marked this pull request as ready for review January 30, 2025 07:42
@MichaelBuhler
Copy link
Collaborator Author

@coderabbitai review

Copy link

coderabbitai bot commented Jan 30, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
.github/workflows/build-tests-ubuntu.yml (1)

94-99: Consider adding test cases for edge cases in the buildProfile parameter.

While the current test matrix includes basic cases for the new buildProfile parameter, consider adding test cases for:

  1. Invalid build profile paths
  2. Build profiles with special characters
  3. Missing build profile files

This would help ensure robust error handling in the implementation.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3a87506 and 0955c19.

⛔ Files ignored due to path filters (1)
  • test-project/Assets/Settings/Build Profiles/Sample WebGL Build Profile.asset is excluded by !**/*.asset
📒 Files selected for processing (4)
  • .github/workflows/build-tests-ubuntu.yml (1 hunks)
  • test-project/Assets/Settings.meta (1 hunks)
  • test-project/Assets/Settings/Build Profiles.meta (1 hunks)
  • test-project/Assets/Settings/Build Profiles/Sample WebGL Build Profile.asset.meta (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • test-project/Assets/Settings/Build Profiles.meta
  • test-project/Assets/Settings.meta
  • test-project/Assets/Settings/Build Profiles/Sample WebGL Build Profile.asset.meta
🔇 Additional comments (3)
.github/workflows/build-tests-ubuntu.yml (3)

94-99: LGTM! The matrix configuration properly tests the new buildProfile parameter.

The changes effectively test the new buildProfile parameter with both default and custom profile configurations for WebGL builds.


94-99: Verify matrix exclusions for new configurations.

The new WebGL configurations with Unity version 6000.0.36f1 should be explicitly excluded from incompatible combinations in the exclude section, similar to other WebGL configurations:

  • Exclude il2cpp builds (already covered by existing exclusion)
  • Exclude server builds (already covered by existing exclusion)
✅ Verification successful

Existing matrix exclusions are sufficient

The current matrix configuration already handles WebGL builds correctly through platform-based exclusions that apply to all Unity versions:

  • WebGL builds are excluded from il2cpp builds
  • WebGL builds are excluded from server builds

No additional exclusions are needed for Unity version 6000.0.36f1 as the constraints are version-independent.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the new configurations are properly excluded
# by checking the effective matrix after GitHub Actions processes it

gh workflow view "build-tests-ubuntu.yml" --json jobs -q '.jobs[].strategy.matrix' || echo "Unable to fetch effective matrix configuration"

Length of output: 508


Script:

#!/bin/bash
# Get the complete matrix configuration including exclude patterns
cat .github/workflows/build-tests-ubuntu.yml | grep -A 50 "matrix:"

Length of output: 2086


95-96: Verify the Unity version number format.

The Unity version 6000.0.36f1 appears to be non-standard. Unity versions typically follow the format YYYY.N.PfX (e.g., 2023.2.2f1). Is this a test version or should it be updated to match a real Unity version?

✅ Verification successful

The Unity version 6000.0.36f1 is intentionally used for testing purposes.

The version follows an established testing pattern in the codebase, where year 6000 is used in test files for version parsing and feature validation. This is consistent with similar test versions found in unity-versioning.test.ts and image-tag.test.ts.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if this is a valid Unity version
# Note: This script helps verify if the version exists in Unity's download archive

curl -s "https://unity.com/releases/editor/archive" | grep -o "Unity [0-9]\{4\}\.[0-9]\+\.[0-9]\+[[:alpha:]][0-9]\+" || echo "Version not found in Unity's archive"

Length of output: 202


Script:

#!/bin/bash
# Check for test documentation and similar version patterns
echo "=== Checking workflow file ==="
cat .github/workflows/build-tests-ubuntu.yml

echo -e "\n=== Checking for test documentation ==="
fd -e md | xargs grep -l "test" || true

echo -e "\n=== Checking for similar version patterns ==="
rg "6000\.0\." || true

Length of output: 9871

Copy link

codecov bot commented Jan 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 37.04%. Comparing base (83c8532) to head (b077fd4).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #685      +/-   ##
==========================================
+ Coverage   37.00%   37.04%   +0.04%     
==========================================
  Files          77       77              
  Lines        3129     3131       +2     
  Branches      610      647      +37     
==========================================
+ Hits         1158     1160       +2     
+ Misses       1971     1828     -143     
- Partials        0      143     +143     
Files with missing lines Coverage Δ
src/model/build-parameters.ts 90.00% <ø> (ø)
src/model/image-environment-factory.ts 4.00% <ø> (ø)
src/model/input.ts 88.96% <100.00%> (+0.14%) ⬆️

... and 35 files with indirect coverage changes

Copy link
Member

@webbertakken webbertakken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Could use a second pair of eyes from @davidmfinol, @GabLeRoux and/or @AndrewKahr

if [ -z "$BUILD_PROFILE" ]; then
# User has not provided a build profile
#
echo "Doing a default \"$BUILD_TARGET\" platform build."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already said on line 20.
Probably better to only add the echo from when $BUILD_PROFILE is set.

Comment on lines +29 to +34
echo "Doing a default \"$BUILD_TARGET\" platform build."
#
else
# User has provided a path to a build profile `.asset` file
#
echo "Using build profile \"$BUILD_PROFILE\" relative to \"$UNITY_PROJECT_PATH\"."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Comment on lines +27 to +34
Write-Output "$('Using build profile "')$($Env:BUILD_PROFILE)$('" relative to "')$($Env:UNITY_PROJECT_PATH)$('".')"
#
}
else
{
# User has not provided a build profile
#
Write-Output "$('Doing a default "')$($Env:BUILD_TARGET)$('" platform build.')"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Comment on lines +62 to +73
describe('buildProfile', () => {
it('returns the default value', () => {
expect(Input.buildProfile).toStrictEqual('');
});

it('takes input from the users workflow', () => {
const mockValue = 'path/to/build_profile.asset';
const spy = jest.spyOn(core, 'getInput').mockReturnValue(mockValue);
expect(Input.buildProfile).toStrictEqual(mockValue);
expect(spy).toHaveBeenCalledTimes(1);
});
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test gods thank you for your contribution

@MichaelBuhler
Copy link
Collaborator Author

Are we able to do a manual dispatch of the Builds - Ubuntu workflow using this PR branch?

@webbertakken
Copy link
Member

@MichaelBuhler Unfortunately not, but I can give you repo access, so that you can push your branch to upstream, in which case it can be achieved and you could run these by yourself.

Invite pending.

Comment on lines +9 to +11
#if UNITY_6000_0_OR_NEWER
using UnityEditor.Build.Profile;
#endif
Copy link
Member

@GabLeRoux GabLeRoux Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we upgrade the dist/default-build-script project to Unity 6 too? I don't think it would affect anything, but it would make opening Unity in that folder easier to confirm that feature and Unity would complain less. 🤔

The Unity complaints 😛

CleanShot 2025-01-30 at 12 07 11@2x

CleanShot 2025-01-30 at 12 07 50@2x

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, that'd probably be a great idea!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I am mistaken, the dist/default-build-script is never opened in Unity. Rather, that folder is bind mounted onto the Docker container, and the contents of dist/default-build-script/Assets/Editor are copied into the users's Unity project, then compiled by Unity when their project launches.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ For this reason, I think the code in dist/default-build-script must be backwards compatible using scripting defines: so that the default-build-script can be built by older versions of Unity.

Such as most of these jobs: https://github.com/game-ci/unity-builder/actions/runs/13057500403

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dist/default-build-script is never opened in Unity.

That’s correct for script usage, but opening the file in JetBrains Rider with Unity integration makes sense for development.

Rather, that folder is bind mounted onto the Docker container, and the contents of dist/default-build-script/Assets/Editor are copied into the users's Unity project, then compiled by Unity when their project launches.

✅ That is correct

I think the code in dist/default-build-script must be backwards compatible using scripting defines

I definitely agree that the code in dist/default-build-script should remain backwards compatible using scripting defines.

I can confirm the folder itself is a Unity project.

The directory structure of `dist/default-build-script`

.
├── Assets
│   ├── Editor
│   │   ├── UnityBuilderAction
│   │   │   ├── Builder.cs
│   │   │   ├── Builder.cs.meta
│   │   │   ├── Input
│   │   │   │   ├── AndroidSettings.cs
│   │   │   │   ├── AndroidSettings.cs.meta
│   │   │   │   ├── ArgumentsParser.cs
│   │   │   │   └── ArgumentsParser.cs.meta
│   │   │   ├── Input.meta
│   │   │   ├── Reporting
│   │   │   │   ├── CompileListener.cs
│   │   │   │   ├── CompileListener.cs.meta
│   │   │   │   ├── StdOutReporter.cs
│   │   │   │   └── StdOutReporter.cs.meta
│   │   │   ├── Reporting.meta
│   │   │   ├── System
│   │   │   │   ├── ProcessExtensions.cs
│   │   │   │   └── ProcessExtensions.cs.meta
│   │   │   ├── System.meta
│   │   │   ├── UnityBuilderAction.asmdef
│   │   │   ├── UnityBuilderAction.asmdef.meta
│   │   │   ├── Versioning
│   │   │   │   ├── Git.cs
│   │   │   │   ├── Git.cs.meta
│   │   │   │   ├── GitException.cs
│   │   │   │   ├── GitException.cs.meta
│   │   │   │   ├── VersionApplicator.cs
│   │   │   │   ├── VersionApplicator.cs.meta
│   │   │   │   ├── VersionGenerator.cs
│   │   │   │   └── VersionGenerator.cs.meta
│   │   │   └── Versioning.meta
│   │   └── UnityBuilderAction.meta
│   └── Editor.meta
├── Packages
│   └── manifest.json
└── ProjectSettings
    ├── AudioManager.asset
    ├── ClusterInputManager.asset
    ├── DynamicsManager.asset
    ├── EditorBuildSettings.asset
    ├── EditorSettings.asset
    ├── GraphicsSettings.asset
    ├── InputManager.asset
    ├── NavMeshAreas.asset
    ├── Physics2DSettings.asset
    ├── PresetManager.asset
    ├── ProjectSettings.asset
    ├── ProjectVersion.txt
    ├── QualitySettings.asset
    ├── TagManager.asset
    ├── TimeManager.asset
    ├── UnityConnectSettings.asset
    └── VFXManager.asset

10 directories, 46 files

My suggestion is more about files like ProjectSettings/ProjectVersion.txt, updating it wouldn’t change much, but it could improve development workflow. However, since the alternative is creating a blank Unity project and manually copying files (which mirrors the action’s behavior), that approach remains valid too.

The main goal was to open the project in Unity/Rider to check for issues. I'm just lacking an older version on my system. I’m still unsure if we should upgrade the project in that folder, it likely wouldn’t make much difference, but might make sense for development. :) 🤷

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GabLeRoux Ah, I get what you are saying. That's actually what I did: I copied dist/default-build-script/Assets/Editor into my Unity 6 project, drafted/tested it, and copied it back into this repo.

@MichaelBuhler
Copy link
Collaborator Author

@webbertakken Okay, great. ❤️

Here is a success workflow job with a defined buildProfile:

https://github.com/game-ci/unity-builder/actions/runs/13057500403/job/36432150028#step:6:4

Copy link

@coderabbitai coderabbitai bot left a 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

🧹 Nitpick comments (1)
.github/workflows/build-tests-ubuntu.yml (1)

204-204: Simplify and standardize artifact naming.

The artifact name is overly complex and contains redundant conditional logic. Long artifact names might cause issues with file system limitations on some platforms.

Consider simplifying the artifact name:

-"Build ${{ matrix.targetPlatform }}${{ startsWith(matrix.buildProfile, 'Assets') && ' (via Build Profile)' || '' }} on Ubuntu (${{ matrix.unityVersion }}_il2cpp_${{ matrix.buildWithIl2cpp }}_params_${{ matrix.additionalParameters }})"
+"${{ matrix.targetPlatform }}-${{ matrix.unityVersion }}${{ matrix.buildProfile && '-profile' || '' }}"

This shorter format:

  1. Remains informative while being more concise
  2. Uses hyphen separators for better readability
  3. Avoids potential path length issues
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0955c19 and b077fd4.

📒 Files selected for processing (1)
  • .github/workflows/build-tests-ubuntu.yml (6 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Tests

.github/workflows/build-tests-ubuntu.yml Show resolved Hide resolved
.github/workflows/build-tests-ubuntu.yml Show resolved Hide resolved
Copy link
Member

@davidmfinol davidmfinol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! I just had 2 questions.


// Apply Android settings
if (buildTarget == BuildTarget.Android) {
VersionApplicator.SetAndroidVersionCode(options["androidVersionCode"]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we still set the androidVersionCode when using a build profile for Android?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a complex question, which applies not only to the version code, but also to all other Android settings supported by this unity-builder GitHub action.

You can set the Android Bundle Version Code within the Build Profile itself. In this case I suppose that you would run the GitHub action with buildProfile: ... and versioning: None.

However, if you want to rely on the GitHub action to determine the version code... I think I have not implemented that--actually, it might even be impossible:

After we load the BuildProfile from the /Assets folder, the object has no public members or methods by which we can modify/edit the Build Profile at runtime.

From decompiled code, I can see that the BuildProfile class has internal classes and getter/setters, as well as private members, that hold the platform build settings and player overrides deserialized from the build profile asset. There also seems to be no public constructor, so you cannot instantiate/build the build profile at runtime.

I would guess that Unity will add these features/abilities in a later version, but they do not seem to be in Unity 6.1 Beta, yet.

So, I suppose the only possible solution today would be to modify (edit in place) the build profile's .asset YAML before launching the build. For instance, I just made a new Android Build Profile and set Bundle Version Code: 990099:

Screenshot 2025-01-31 at 1 49 27 PM

This resulted in this on line 206 of the .asset file:

    - line: '|   AndroidBundleVersionCode: 990099'

So we would have to Regex replace that 6-digit value before launching Unity.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, we may want to create a follow-up issue to check on setting Android version code when using a build profile, but I don't think that should be a blocker for this PR.


#if UNITY_2021_2_OR_NEWER
// Determine subtarget
StandaloneBuildSubtarget buildSubtarget;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do build profiles set StandaloneBuildSubtarget?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's appears to me that the Build Profile feature eliminates the need for defining the build subtarget.

The old build method works by setting BuildPlayerOptions.target in conjunction with BuildPlayerOptions.subtarget. However these fields do not exist on the new BuildPlayerWithProfileOptions.

Rather, Windows Server, macOS Server, and Linux Server are entirely different types of build profiles:

Screenshot 2025-01-31 at 1 58 12 PM

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, then we should be fine to ignore subtarget when using a build profile. We may just want to add a comment about it to the docs.

MichaelBuhler added a commit to MichaelBuhler/game-ci-documentation that referenced this pull request Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support activeBuildProfile parameter
4 participants