Skip to content

Commit f42e906

Browse files
authored
Add parallel execution of tests and builds example + improved no space left on device (#427)
* Add parallel execution of tests and builds * Add link to parallel example * Simplify wording a bit
1 parent 9154b36 commit f42e906

File tree

2 files changed

+120
-9
lines changed

2 files changed

+120
-9
lines changed

docs/03-github/01-getting-started.mdx

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ It is **recommended** to start from the
6060

6161
### Simple example
6262

63-
This example tests your project then builds it for a single target (WebGL in this case).
63+
This example tests your project then builds it for a single target (WebGL in this case). It will run
64+
sequentially.
6465

6566
This example assumes that your Unity project is in the root of your repository.
6667

@@ -183,6 +184,80 @@ jobs:
183184
path: build
184185
```
185186
187+
### Parallel execution of Tests and Builds
188+
189+
This will run tests in parallel with the Build, in this case for Windows 64bit.
190+
191+
This example assumes that your Unity project is in the root of your repository.
192+
193+
```yaml
194+
name: Actions 😎
195+
196+
on: [push, pull_request]
197+
198+
jobs:
199+
test:
200+
name: Test my project 🧪
201+
runs-on: ubuntu-latest
202+
steps:
203+
# Checkout
204+
- name: Checkout repository
205+
uses: actions/checkout@v3
206+
with:
207+
lfs: true
208+
209+
# Cache
210+
- uses: actions/cache@v3
211+
with:
212+
path: Library
213+
key: Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
214+
restore-keys: |
215+
Library-
216+
217+
# Test
218+
- name: Run tests
219+
uses: game-ci/unity-test-runner@v3
220+
env:
221+
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
222+
with:
223+
githubToken: ${{ secrets.GITHUB_TOKEN }}
224+
225+
build:
226+
name: Build my project ✨
227+
runs-on: ubuntu-latest
228+
steps:
229+
# Checkout
230+
- name: Checkout repository
231+
uses: actions/checkout@v3
232+
with:
233+
lfs: true
234+
235+
# Cache
236+
- uses: actions/cache@v3
237+
with:
238+
path: Library
239+
key: Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
240+
restore-keys: |
241+
Library-
242+
243+
# Build
244+
- name: Build project
245+
uses: game-ci/unity-builder@v3
246+
env:
247+
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
248+
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
249+
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
250+
with:
251+
targetPlatform: StandaloneWindows64
252+
allowDirtyBuild: true
253+
254+
# Output
255+
- uses: actions/upload-artifact@v3
256+
with:
257+
name: Build
258+
path: build
259+
```
260+
186261
### Advanced IL2CPP example
187262
188263
This example leverages the powerful Github Actions construct called a

docs/09-troubleshooting/common-issues.mdx

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,20 +237,56 @@ There are 2 possible solutions:
237237

238238
#### Error
239239

240+
Example when downloading an android docker image:
241+
240242
```plaintext
241243
docker: failed to register layer: ApplyLayer exit status 1 stdout: stderr: write /opt/unity/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/9.0.8/lib/linux/x86_64/libFuzzer.a: no space left on device.
242244
```
243245

246+
or when it's downloading a docker image for the windows target platform:
247+
248+
```plaintext
249+
[...]
250+
6fad6f1176e0: Verifying Checksum
251+
6fad6f1176e0: Download complete
252+
docker: failed to register layer: write /opt/unity/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.visualeffectgraph/Documentation~/Images/EventContexts.png: no space left on device.
253+
```
254+
255+
#### Explanation
256+
257+
When executing multiple jobs sequentially in the same workflow, there can be potential disk space
258+
issues. For instance, if your workflow first executes tests on one docker image, such as
259+
`unityci/editor:ubuntu-2022.3.4f1-linux-il2cpp-2`, and subsequently runs a build on another target
260+
platform, e.g., `unityci/editor:ubuntu-2022.3.4f1-windows-mono-2`, it might run out of space during
261+
the build phase.
262+
263+
This happens because each job might be downloading and using its separate docker image, which can
264+
collectively consume a significant amount of disk space.
265+
244266
#### Solution
245267

246-
The GitHub-hosted runners often do not have enough disk space for game dev projects. To work around
247-
this limitation, you could try to use the
248-
[Free Disk Space (Ubuntu)](https://github.com/marketplace/actions/free-disk-space-ubuntu) action at
249-
the start of your workflow. If you still require additional disk space for your project, you could
250-
try using
251-
[Self-hosted Runners](https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/about-self-hosted-runners)
252-
or using
253-
[Cloud Runners](https://game.ci/docs/github-cloud-runner/game-ci-vs-cloud-runner#large-github-projects).
268+
1. **Parallel Execution**: A straightforward workaround is to execute the tests and builds in
269+
parallel rather than sequentially. This ensures that each runner (or CI job) utilizes its own
270+
docker image, thereby avoiding cumulative disk usage. By structuring your CI workflow to execute
271+
these jobs concurrently, each job can independently manage its disk space. You can refer to
272+
[our Github 'Parallel execution of Tests and Builds' example](/docs/github/getting-started#parallel-execution-of-tests-and-builds).
273+
274+
2. **Free Up Disk Space**: Use the
275+
[Free Disk Space (Ubuntu)](https://github.com/marketplace/actions/free-disk-space-ubuntu) action
276+
at the start of your workflow to clear some space on the GitHub-hosted runner. This action can be
277+
especially useful if only a small amount of additional space is needed.
278+
279+
3. **Use Self-Hosted or Cloud Runners**: If your project inherently requires more disk space than
280+
what GitHub-hosted runners provide, consider switching to
281+
[Self-hosted Runners](https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/about-self-hosted-runners)
282+
or
283+
[Cloud Runners](https://game.ci/docs/github-cloud-runner/game-ci-vs-cloud-runner#large-github-projects).
284+
This would give you more control over the resources and disk space.
285+
286+
---
287+
288+
This revised section provides a clearer understanding of the issue and offers more directed
289+
solutions.
254290

255291
## General tips
256292

0 commit comments

Comments
 (0)