Skip to content

Commit bb912f1

Browse files
committed
builder job
1 parent 9382bd8 commit bb912f1

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{% metadata_file .yamato/project-builders/builder.metafile %}
2+
---
3+
# The above line corresponds to https://internaldocs.unity.com/yamato_continuous_integration/usage/templating/
4+
5+
# Yamato paths disclaimer:
6+
# Note that artifacts can get only local paths and since cloned project is in different location, you need to be careful with paths
7+
# All artifact paths are defined relative to the Yamato source directory (YAMATO_SOURCE_DIR) and are case-sensitive.
8+
# !!! important “Artifact directory locations” All artifact globs are defined relative to the source directory (YAMATO_SOURCE_DIR). Yamato can’t capture artifacts from outside this directory, so if you need files from elsewhere, you should copy them into your source directory as part of job commands.
9+
10+
# Those jobs were created in order to (in most cases) speed up playtesting and development time.
11+
# The aim is to collect all possible projects that use Netcode for Entities and create a job that will build the project with the given version of N4E package.
12+
# The package is taken directly from the branch from which the job was triggered. So image triggering the job from release/2.0.0 and release/2.1.0 branch to compare differences
13+
# Example use case would be to trigger the build job on Sunday so by Monday morning all builds are ready for playtesting. This limits the time a dev/QA has to spend building projects for different configurations (win, mac, Android, scripting backends, burst etc) or simply time necessary for building huge projects (Megacity).
14+
15+
# This job takes parameters as scriptable backend configuration, burst compilation, unity editor version and platform.
16+
# Since Yamato variables can't be restricted to only specific values, the job will validate the parameters passed to it and fail quickly if those are incorrect. In order to see what options are available, please look at the variable name.
17+
18+
# Note that for now all of those builds are being made on Windows machine (so for example combination of macOS + il2cpp is expected to fail)
19+
# TODO: for now all builds are being made on Windows machine, but it would be nice to have a Mac build as well.
20+
# TODO: add iOS support
21+
{% for netcodeProject in NetcodeProjects -%}
22+
build_{{ netcodeProject[0] }}_project:
23+
name: {{ netcodeProject[0] }}
24+
agent:
25+
type: Unity::VM
26+
image: package-ci/win10:v4
27+
flavor: b1.xlarge
28+
variables:
29+
UNITY_VERSION: trunk
30+
SCRIPTING_BACKEND_IL2CPP_MONO: il2cpp
31+
BURST_ON_OFF: on
32+
PLATFORM_WIN64_MAC_ANDROID: win64
33+
commands:
34+
# Validate inputs passed via Yamato variables
35+
- python Tools/CI/scripts/BuildAutomation/validate_params.py
36+
- echo Building {{ netcodeProject[0] }} project with Unity version of %UNITY_VERSION%, Scripting backend %SCRIPTING_BACKEND_IL2CPP_MONO%, Burst %BURST_ON_OFF% for platform %PLATFORM_WIN64_MAC_ANDROID%
37+
38+
# Clone the external project repository into a specific directory. Notice that branch is also specified.
39+
- git clone --single-branch --branch {{ netcodeProject[1].branch }} {{ netcodeProject[1].GithubRepo }} C:/ClonedProject
40+
41+
# Modify the external project's manifest to use the local N4E package from current branch on which this Yamato job is running. (requires python that should be preinstalled in the image)
42+
- python Tools/CI/scripts/BuildAutomation/manifest_update.py --manifest-path C:/ClonedProject/{{ netcodeProject[1].manifestPath }} --local-package-path %YAMATO_SOURCE_DIR%/Packages/com.unity.netcode
43+
44+
# Run python script to update ProjectSettings.asset in order to connect the project to Unity Services/set proper values.
45+
# Notice that if a project has this already set up then in theory we don't need to run this script.
46+
- python Tools/CI/scripts/BuildAutomation/connect_services.py --project-settings-path C:/ClonedProject/{{ netcodeProject[1].projectPath }}/ProjectSettings/ProjectSettings.asset
47+
48+
# Enable or disable Burst compilation. This step is specific to Netcode package (or any package that uses Burst)
49+
- IF "%BURST_ON_OFF%"=="on" (python Tools/CI/scripts/BuildAutomation/disable-enable-burst.py --enable-burst --project-path C:/ClonedProject/{{ netcodeProject[1].projectPath }})
50+
ELSE (python Tools/CI/scripts/BuildAutomation/disable-enable-burst.py --disable-burst --project-path C:/ClonedProject/{{ netcodeProject[1].projectPath }})
51+
52+
# Download the Unity Editor version specified in the UNITY_VERSION variable. Il2cpp component is downloaded only if the SCRIPTING_BACKEND_IL2CPP_MONO is set to "il2cpp".
53+
# TODO: we could download components only if needed
54+
- unity-downloader-cli --fast --wait -u %UNITY_VERSION% -p C:/TestingEditor -c Editor -c il2cpp -c Android -c macOS
55+
56+
# Add BuilderScript.cs to the project so we can modify and build the project using Unity Editor.
57+
# This is a bit tricky step, notice that we also need to include proper assembly definition in order for those scripts to compile properly.
58+
# TODO: the asmdef file can be simplified
59+
- python -c "import os; os.makedirs('C:/ClonedProject/{{ netcodeProject[1].projectPath }}/Assets/Scripts/Editor', exist_ok=True)" # --> Create the directory if it doesn't exist
60+
- python -c "import shutil; shutil.copy('Tools/CI/scripts/BuildAutomation/Unity.ProjectBuild.Editor.asmdef', 'C:/ClonedProject/{{ netcodeProject[1].projectPath }}/Assets/Scripts/Editor/')" # --> Copy the asmdef file to the directory
61+
- python -c "import shutil; shutil.copy('Tools/CI/scripts/BuildAutomation/BuilderScripts.cs', 'C:/ClonedProject/{{ netcodeProject[1].projectPath }}/Assets/Scripts/Editor/')" # --> Copy the BuilderScripts.cs file to the directory (for build configuration setup)
62+
63+
# Build the project using Unity Editor. This will call the given static BuilderScripts method.
64+
# Ideally, it would be nice to parametrize the BuilderScripts (for example to pass scripting backend as parameter) but -executeMethod only calls static methods without parameters so for now we will have multiple configurations
65+
# Notice that for Android platform even if mono is selected, il2cpp will be used since mono is not supported for Android builds.
66+
- IF "%PLATFORM_WIN64_MAC_ANDROID%"=="win64" (
67+
IF "%SCRIPTING_BACKEND_IL2CPP_MONO%"=="il2cpp" (
68+
C:/TestingEditor/Unity.exe -projectPath C:/ClonedProject/{{ netcodeProject[1].projectPath }} -buildTarget win64 -executeMethod BuilderScripts.BuildWinIl2cpp -batchmode -logFile ./artifacts/UnityLog.txt -automated -crash-report-folder ./artifacts/CrashArtifacts -quit
69+
) ELSE (
70+
C:/TestingEditor/Unity.exe -projectPath C:/ClonedProject/{{ netcodeProject[1].projectPath }} -buildTarget win64 -executeMethod BuilderScripts.BuildWinMono -batchmode -logFile ./artifacts/UnityLog.txt -automated -crash-report-folder ./artifacts/CrashArtifacts -quit
71+
)
72+
)
73+
ELSE IF "%PLATFORM_WIN64_MAC_ANDROID%"=="mac" (
74+
IF "%SCRIPTING_BACKEND_IL2CPP_MONO%"=="il2cpp" (
75+
C:/TestingEditor/Unity.exe -projectPath C:/ClonedProject/{{ netcodeProject[1].projectPath }} -buildTarget osx -executeMethod BuilderScripts.BuildMacIl2cpp -batchmode -logFile ./artifacts/UnityLog.txt -automated -crash-report-folder ./artifacts/CrashArtifacts -quit
76+
) ELSE (
77+
C:/TestingEditor/Unity.exe -projectPath C:/ClonedProject/{{ netcodeProject[1].projectPath }} -buildTarget osx -executeMethod BuilderScripts.BuildMacMono -batchmode -logFile ./artifacts/UnityLog.txt -automated -crash-report-folder ./artifacts/CrashArtifacts -quit
78+
)
79+
)
80+
ELSE IF "%PLATFORM_WIN64_MAC_ANDROID%"=="android" (
81+
C:/TestingEditor/Unity.exe -projectPath C:/ClonedProject/{{ netcodeProject[1].projectPath }} -buildTarget android -executeMethod BuilderScripts.BuildAndroidIl2cpp -batchmode -logFile ./artifacts/UnityLog.txt -automated -crash-report-folder ./artifacts/CrashArtifacts -quit
82+
)
83+
84+
# Because of this we need to ensure that all files are copied to the source directory.
85+
# TODO: this can be omitted if I can somehow build the project in the source directory (YAMATO_SOURCE_DIR) instead of C:/CompetitiveAction
86+
- python -c "import os; os.makedirs('./build', exist_ok=True)" # --> Create the build directory if it doesn't exist
87+
- python -c "import shutil; shutil.copytree('C:/ClonedProject/{{ netcodeProject[1].projectPath }}/build', './build', dirs_exist_ok=True)" # --> Copy the build directory to the source directory (YAMATO_SOURCE_DIR). Remember to copy entire directory and not only exe file
88+
89+
artifacts:
90+
logs:
91+
paths:
92+
- '*.log'
93+
- '*.xml'
94+
- artifacts/**/*
95+
players:
96+
paths:
97+
- build/**/*
98+
{% endfor -%}

0 commit comments

Comments
 (0)