Skip to content

Adds support for useHostNetwork the unity-builder#828

Open
lupidan wants to merge 7 commits intogame-ci:mainfrom
lupidan:feature/useHostNetworkSupport
Open

Adds support for useHostNetwork the unity-builder#828
lupidan wants to merge 7 commits intogame-ci:mainfrom
lupidan:feature/useHostNetworkSupport

Conversation

@lupidan
Copy link
Copy Markdown
Contributor

@lupidan lupidan commented Apr 17, 2026

Changes

  • Adds optional useHostNetwork to action (to match unity's test runner)
  • Adds useHostNetwork to Input class
  • Adds useHostNetwork to BuildParameters class
  • Passes useHostNetwork parameter to docker command to add --net=host
  • Updates unity versions in workflow test for testing builds, so macos-latest can build them

This allows access, for example, to licensing servers that are inside a VPN, when VPN access is configured inside the Github Action

Test Builds in home repo

Checklist

Summary by CodeRabbit

  • New Features

    • Added a useHostNetwork option to enable Docker host-networking (Linux only).
  • Tests

    • Added unit tests validating the new option’s behavior and defaults.
  • Chores

    • Updated CI build matrices to use newer Unity editor versions across macOS, Ubuntu, and Windows.

@github-actions
Copy link
Copy Markdown

Cat Gif

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 17, 2026

📝 Walkthrough

Walkthrough

Added a new boolean action input useHostNetwork (Linux-only), exposed via Input.useHostNetwork, included in BuildParameters, and used to conditionally add --net=host to the Linux Docker run command; accompanying unit tests and CI Unity version matrix updates were also included.

Changes

Cohort / File(s) Summary
Action config & input accessor
action.yml, src/model/input.ts, src/model/input.test.ts
Added useHostNetwork action input; implemented Input.useHostNetwork getter that parses 'true'/'false' strings to boolean and added tests for default/true/false behavior.
Build parameters model & tests
src/model/build-parameters.ts, src/model/build-parameters.test.ts
Added useHostNetwork property to BuildParameters and wired Input.useHostNetwork into BuildParameters.create(); added parameterized test to assert propagation.
Docker command construction
src/model/docker.ts
Linux Docker command builder now conditionally appends --net=host when useHostNetwork is true; Windows path unchanged.
CI workflows (Unity versions)
.github/workflows/build-tests-mac.yml, .github/workflows/build-tests-ubuntu.yml, .github/workflows/build-tests-windows.yml
Updated Unity editor versions in CI job matrices for macOS, Ubuntu, and Windows workflows.

Sequence Diagram(s)

sequenceDiagram
    participant Action as GitHub Action
    participant Input as Input
    participant Params as BuildParameters
    participant Docker as Docker Builder
    participant Engine as Docker Engine

    Action->>Input: read `useHostNetwork` input
    Input-->>Action: boolean value
    Action->>Params: BuildParameters.create() (includes useHostNetwork)
    Params-->>Action: build parameters object
    Action->>Docker: construct docker run command (passes useHostNetwork)
    Docker->>Docker: if useHostNetwork == true add `--net=host`
    Docker->>Engine: execute `docker run ...`
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • webbertakken
  • davidmfinol
  • GabLeRoux

Poem

🐰 A little flag hops on the host,
Through Input, Params, and Docker it roams,
On Linux it finds its nest,
--net=host does the rest,
I nibble code and drum my thumps and thrones 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main feature addition—adding useHostNetwork support—but contains a minor grammatical issue ('the unity-builder' should be 'to the unity-builder').
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The pull request description covers all required template sections with comprehensive information about changes, related resources, and completed checklist items.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 17, 2026

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 31.27%. Comparing base (4a7fc08) to head (ac7de97).

Files with missing lines Patch % Lines
src/model/docker.ts 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #828      +/-   ##
==========================================
+ Coverage   31.23%   31.27%   +0.03%     
==========================================
  Files          84       84              
  Lines        4565     4569       +4     
  Branches     1054     1056       +2     
==========================================
+ Hits         1426     1429       +3     
- Misses       3139     3140       +1     
Files with missing lines Coverage Δ
src/model/build-parameters.ts 90.00% <ø> (ø)
src/model/input.ts 89.17% <100.00%> (+0.21%) ⬆️
src/model/docker.ts 9.80% <0.00%> (-0.20%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

@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.

🧹 Nitpick comments (2)
action.yml (1)

50-53: Nit: quote the default to match other boolean inputs.

Other boolean-like inputs in this file use quoted string defaults (e.g., 'false' for runAsHostUser, resourceTracking, cacheUnityInstallationOnMac, skipActivation). GitHub Actions input values are always strings, so using an unquoted YAML boolean false here is inconsistent with the rest of the file.

Proposed change
   useHostNetwork:
     required: false
-    default: false
+    default: 'false'
     description: 'Initialises Docker using the host network. (Linux only)'

Also consider documenting this input in the README as the PR description notes docs weren't yet updated.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@action.yml` around lines 50 - 53, The useHostNetwork input uses an unquoted
YAML boolean false; change its default to the quoted string 'false' to match
other boolean-like inputs (e.g., runAsHostUser, resourceTracking) and maintain
consistency because GitHub Actions inputs are strings; also add a short entry
documenting useHostNetwork in the README to reflect the new input.
src/model/docker.ts (1)

89-89: Consider warning when useHostNetwork is set on non-Linux platforms.

useHostNetwork is silently ignored on Windows (getWindowsCommand doesn't destructure or use it). The action.yml description already marks this Linux-only, but a core.warning when the flag is truthy on a non-Linux host would help users debug misconfigurations rather than wondering why --net=host isn't being applied.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/model/docker.ts` at line 89, The template includes useHostNetwork but on
non-Linux hosts that flag is ignored (getWindowsCommand doesn't use it); add a
runtime warning when useHostNetwork is true and process.platform !== 'linux' so
users know the flag will be ignored. Locate the code that builds the docker
command (the template line with ${useHostNetwork ? '--net=host' : ''}) and/or
getWindowsCommand, import and call core.warning (from `@actions/core`) when
useHostNetwork is truthy on non-Linux platforms, with a short message indicating
that --net=host is Linux-only and will be ignored on this OS.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@action.yml`:
- Around line 50-53: The useHostNetwork input uses an unquoted YAML boolean
false; change its default to the quoted string 'false' to match other
boolean-like inputs (e.g., runAsHostUser, resourceTracking) and maintain
consistency because GitHub Actions inputs are strings; also add a short entry
documenting useHostNetwork in the README to reflect the new input.

In `@src/model/docker.ts`:
- Line 89: The template includes useHostNetwork but on non-Linux hosts that flag
is ignored (getWindowsCommand doesn't use it); add a runtime warning when
useHostNetwork is true and process.platform !== 'linux' so users know the flag
will be ignored. Locate the code that builds the docker command (the template
line with ${useHostNetwork ? '--net=host' : ''}) and/or getWindowsCommand,
import and call core.warning (from `@actions/core`) when useHostNetwork is truthy
on non-Linux platforms, with a short message indicating that --net=host is
Linux-only and will be ignored on this OS.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 59743899-61eb-4a79-9381-800dc8305a25

📥 Commits

Reviewing files that changed from the base of the PR and between 4a7fc08 and 7db9620.

⛔ Files ignored due to path filters (2)
  • dist/index.js is excluded by !**/dist/**
  • dist/index.js.map is excluded by !**/dist/**, !**/*.map
📒 Files selected for processing (6)
  • action.yml
  • src/model/build-parameters.test.ts
  • src/model/build-parameters.ts
  • src/model/docker.ts
  • src/model/input.test.ts
  • src/model/input.ts

Comment on lines +21 to 24
- 2021.3.45f2
- 2022.3.62f3
- 2023.2.22f1
targetPlatform:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

macos-latest with the latest Xcode was struggling trying to compile with old Unity Versions. I took the opportunity to update these.

Running in my repo actions:

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.

1 participant