Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
c6604b8
Initial BK setup, generated step and definition files.
ieva-improbable Sep 9, 2019
c540bc8
Add build description, set the default branch and correct permissions.
ieva-improbable Sep 11, 2019
bf39273
Update the build steps to run the setup and build script and upload l…
ieva-improbable Sep 12, 2019
324ffec
Adding scripts to build example project and start a deployment.
ieva-improbable Sep 12, 2019
3cad5a5
Fix indentation.
ieva-improbable Sep 12, 2019
1603f79
Updating the queue to match my canary.
ieva-improbable Sep 12, 2019
384b66f
Another attempt at updating queue to pick up the canary.
ieva-improbable Sep 12, 2019
6607f1f
Updating the queue name yet again.
ieva-improbable Sep 12, 2019
f7f4137
Update the way that Unreal Engine association is set for the project.
ieva-improbable Sep 12, 2019
ffcce70
Try running ue4 version selector to set engine association.
ieva-improbable Sep 13, 2019
9b77584
Fix path to engine for setting engine associations.
ieva-improbable Sep 13, 2019
7bbe760
Use GDKs engine setup script to cache Engine, specify that engine ofl…
ieva-improbable Sep 16, 2019
589a15b
Pass in the location of Engine symlink to Engine setup script.
ieva-improbable Sep 16, 2019
dbb2a73
Allow specifying GDK branch through environment variables when kickin…
ieva-improbable Sep 16, 2019
ca2068c
Probably don't actually need to pass the variable in.
ieva-improbable Sep 16, 2019
b6bc5b9
Updating the bk queue to test on the new canary.
ieva-improbable Sep 16, 2019
b835d26
Change the way custom environment variables from build kite are parse…
ieva-improbable Sep 16, 2019
e45a94f
Update to use the new caanry.
ieva-improbable Sep 17, 2019
121d01a
Move engine cache outside of build directories, fix unreal version se…
ieva-improbable Sep 17, 2019
9b6fe4a
A change has been made to allow map overrides in shipping by default …
ieva-improbable Sep 18, 2019
47ee0f6
Update to use the new canary.
ieva-improbable Sep 18, 2019
ad90d35
Updating to yet another canary.
ieva-improbable Sep 18, 2019
c24d126
Updating to yet another canary, they die so young.
ieva-improbable Sep 18, 2019
7353d90
Resolve merge conflict
ieva-improbable Sep 18, 2019
6af415a
Pass in project name to assembly upload.
ieva-improbable Sep 19, 2019
b8d15ba
Adding error handling for deployment launch.
ieva-improbable Sep 19, 2019
7429f88
Append date and time to deployment and assembly name.
ieva-improbable Sep 19, 2019
29602d7
Removing template comments.
ieva-improbable Sep 19, 2019
9f7ff3d
Update the default project where the deployment gets uploaded to one …
ieva-improbable Sep 19, 2019
ebae116
Update bk definition to use master branch by default.
ieva-improbable Sep 19, 2019
fd13a00
Update to use the Unreal build queue.
ieva-improbable Sep 20, 2019
ee4debf
Rename game_home to exampleproject_home
ieva-improbable Sep 24, 2019
4f77365
Set ms build variable directly in GDK`s setup gdk script.
ieva-improbable Sep 24, 2019
ad1451a
Fix a typo
ieva-improbable Sep 24, 2019
c374509
No need to specifically set Engine associations, as it looks for the …
ieva-improbable Sep 24, 2019
12d122c
Merge branch 'feature/ci' of github.com:spatialos/UnrealGDKExamplePro…
ieva-improbable Sep 24, 2019
e445393
Update agent to cnaary for testing out changes.
ieva-improbable Sep 24, 2019
f7e09fc
Do not launch deployments by default but add option to do it.
ieva-improbable Sep 24, 2019
7aa5860
Adding back code to do Engine association, as it does not happen auto…
ieva-improbable Sep 24, 2019
fab5ef5
Adding Slack notifications for successful deployments.
ieva-improbable Sep 24, 2019
dcec09f
Updating Slack webhook secret name.
ieva-improbable Sep 24, 2019
c3752b2
Need to extract the actual URL from the secret.
ieva-improbable Sep 25, 2019
21f63ce
Fix a typo
ieva-improbable Sep 25, 2019
8cd9424
Removed the need to pass in engine cache directory
ieva-improbable Sep 25, 2019
9171be5
Fix typo in variable name
ieva-improbable Sep 25, 2019
9ea17e5
Fix spacing and capitalisation
ieva-improbable Sep 25, 2019
297bc99
Update button name
ieva-improbable Sep 25, 2019
74c543e
Update button name
ieva-improbable Sep 25, 2019
0d79475
Change event names for consistency.
ieva-improbable Sep 25, 2019
75aba40
Merge branch 'feature/ci' of github.com:spatialos/UnrealGDKExamplePro…
ieva-improbable Sep 25, 2019
6c84b91
Update the agent name to use Unreal build queue.
ieva-improbable Sep 25, 2019
ee3a744
Switch to launch deployments by default, add a ttl_1_hours tag to onl…
ieva-improbable Sep 25, 2019
1951246
Switch to the new queue (has a fix for git checkout timeout issue).
ieva-improbable Sep 26, 2019
12c9dac
Adding scaler version and agent count.
ieva-improbable Sep 26, 2019
972d541
Updating machine type.
ieva-improbable Sep 26, 2019
9a765ea
Disambiguating some variable naming and parameters, adding a comment …
ieva-improbable Sep 26, 2019
e84ba88
Added a ticket number to todo.
ieva-improbable Sep 26, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .buildkite/nightly.definition.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
agent_queue_id: trigger-pipelines
description: Nightly build and deployment of Unreal Example project
github:
branch_configuration: []
default_branch: master
pull_request_branch_filter_configuration: []
teams:
- name: Everyone
permission: BUILD_AND_READ
- name: gbu/develop/unreal
permission: MANAGE_BUILD_AND_READ
25 changes: 25 additions & 0 deletions .buildkite/nightly.steps.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
common: &common
agents:
- "agent_count=1"
- "capable_of_building=gdk-for-unreal"
- "environment=production"
- "machine_type=quad"
- "permission_set=builder"
- "platform=windows"
- "scaler_version=2"
- "queue=${CI_WINDOWS_BUILDER_QUEUE:-v3-1569490589-f9345a43b21a6cec-------z}"
timeout_in_minutes: 60 # TODO(ENG-548): reduce timeout once agent-cold-start is optimised.
retry:
automatic:
# This is designed to trap and retry failures because agent lost connection. Agent exits with -1 in this case.
- exit_status: -1
limit: 3
plugins:
Copy link
Collaborator

Choose a reason for hiding this comment

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

These queues are setup to run on the same agents as our GDK premerge job, I assume they get checked out to different working directories. Do you know if that's the case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm almost sure that that is the case. I think we have it set up so that each different git repo gets checked out in its own directory.

We also reuse the same agents for GDK and Engine premerge jobs, and that is fine, so I wouldn't expect this to cause any issues.

But I can ask EV and do a little experimenting on a canary if you want to double-check.

Choose a reason for hiding this comment

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

The build happens in it's own newly cloned directory at f:/b/ right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, that's what I have observed too.

- ca-johnson/taskkill#v4.1: ~

steps:
- label: "build-and-deploy-:windows:"
command: powershell -NoProfile -NonInteractive -InputFormat Text -Command ./ci/setup-and-build.ps1
<<: *common # This folds the YAML named anchor into this step. Overrides, if any, should follow, not precede.
artifact_paths:
- "UnrealEngine/Engine/Programs/AutomationTool/Saved/Logs/*"
2 changes: 0 additions & 2 deletions Game/Source/GDKShooter.Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,5 @@ public GDKShooterTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Game;
ExtraModuleNames.Add("GDKShooter");
// TODO: UNR-1791 for long-term fix
GlobalDefinitions.Add("UE_ALLOW_MAP_OVERRIDE_IN_SHIPPING=1");
}
}
58 changes: 58 additions & 0 deletions ci/common.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
function Write-Log() {
param(
[string] $msg,
[Parameter(Mandatory=$false)] [bool] $expand = $false
)
if ($expand) {
Write-Output "+++ $($msg)"
} else {
Write-Output "--- $($msg)"
}
}

function Start-Event() {
param(
[string] $event_name,
[string] $event_parent
)

# Start this tracing span.
Start-Process -NoNewWindow "imp-ci" -ArgumentList @(`
"events", "new", `
"--name", "$($event_name)", `
"--child-of", "$($event_parent)"
) | Out-Null

Write-Log "--- $($event_name)"
}

function Finish-Event() {
param(
[string] $event_name,
[string] $event_parent
)

# Emit the end marker for this tracing span.
Start-Process -NoNewWindow "imp-ci" -ArgumentList @(`
"events", "new", `
"--name", "$($event_name)", `
"--child-of", "$($event_parent)"
) | Out-Null
}

## Checks whether the specified environment variable has been set. If it has, return its value. Else return the default value.
function Get-Env-Variable-Value-Or-Default() {
param(
[string] $environment_variable_name,
[string] $default_value
)

If (Test-Path env:$environment_variable_name) {
$environment_variable_value = Get-Content -Path env:$environment_variable_name
return $environment_variable_value
} Else {
return $default_value
}
}

$ErrorActionPreference = 'Stop'
132 changes: 132 additions & 0 deletions ci/deploy.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
param(
[string] $launch_deployment = "false",
[string] $gdk_branch_name = "master"
)

. "$PSScriptRoot\common.ps1"

Start-Event "deploy-game" "build-unreal-gdk-example-project-:windows:"
# Use the shortened commit hash gathered during GDK plugin clone and the current date and time to distinguish the deployment
$date_and_time = Get-Date -Format "MMdd_HHmm"
$deployment_name = "exampleproject_${date_and_time}_$($gdk_commit_hash)"
$assembly_name = "$($deployment_name)_asm"

pushd "spatial"

Start-Event "build-worker-configurations" "deploy-unreal-gdk-example-project-:windows:"
$build_configs_process = Start-Process -Wait -PassThru -NoNewWindow -FilePath "spatial" -ArgumentList @(`
"build", `
"build-config"
)

if ($build_configs_process.ExitCode -ne 0) {
Write-Log "Failed to build worker configurations for the project. Error: $($build_configs_process.ExitCode)"
Throw "Failed to build worker configurations"
}
Finish-Event "build-worker-configurations" "deploy-unreal-gdk-example-project-:windows:"

Start-Event "prepare-for-run" "deploy-unreal-gdk-example-project-:windows:"
$prepare_for_run_process = Start-Process -Wait -PassThru -NoNewWindow -FilePath "spatial" -ArgumentList @(`
"prepare-for-run", `
"--log_level=debug"
)

if ($prepare_for_run_process.ExitCode -ne 0) {
Write-Log "Failed to prepare for a Spatial cloud launch. Error: $($prepare_for_run_process.ExitCode)"
Throw "Spatial prepare for run failed"
}
Finish-Event "prepare-for-run" "deploy-unreal-gdk-example-project-:windows:"

Start-Event "upload-assemblies" "deploy-unreal-gdk-example-project-:windows:"
$upload_assemblies_process = Start-Process -Wait -PassThru -NoNewWindow -FilePath "spatial" -ArgumentList @(`
"cloud", `
"upload", `
"$assembly_name", `
"--project_name=$project_name", `
"--log_level=debug", `
"--force"
)

if ($upload_assemblies_process.ExitCode -ne 0) {
Write-Log "Failed to upload assemblies to cloud. Error: $($upload_assemblies_process.ExitCode)"
Throw "Failed to upload assemblies"
}
Finish-Event "upload-assemblies" "deploy-unreal-gdk-example-project-:windows:"

Start-Event "launch-deployment" "deploy-unreal-gdk-example-project-:windows:"
# Determine whether deployment should be launched (it will by default)
if ($launch_deployment -eq "true") {
$launch_deployment_process = Start-Process -Wait -PassThru -NoNewWindow -FilePath "spatial" -ArgumentList @(`
"cloud", `
"launch", `
"$assembly_name", `
"$deployment_launch_configuration", `
"$deployment_name", `
"--project_name=$project_name", `
"--snapshot=$deployment_snapshot_path", `
"--cluster_region=$deployment_cluster_region", `
"--log_level=debug", `
"--tags=ttl_1_hours"
)

if ($launch_deployment_process.ExitCode -ne 0) {
Write-Log "Failed to launch a Spatial cloud deployment. Error: $($launch_deployment_process.ExitCode)"
Throw "Deployment launch failed"
}

# Send a Slack notification with a link to the new deployment and to the build.
# Read Slack webhook secret from the vault and extract the Slack webhook URL from it.
$slack_webhook_secret = "$(imp-ci secrets read --environment=production --buildkite-org=improbable --secret-type=slack-webhook --secret-name=unreal-gdk-slack-web-hook)"
$slack_webhook_url = $slack_webhook_secret | ConvertFrom-Json | %{$_.url}

$deployment_url = "https://console.improbable.io/projects/${project_name}/deployments/${deployment_name}/overview"
$build_url = "$env:BUILDKITE_BUILD_URL"

$json_message = [ordered]@{
text = "Example Project build succeeded and a deployment has been launched."
attachments= @(
@{
fallback = "Find deployment here: $deployment_url and build here: $build_url"
fields= @(
@{
title = "GDK branch"
value = "$gdk_branch_name"
short = "true"
}
@{
title = "Example Project branch"
value = "$env:BUILDKITE_BRANCH"
short = "true"
}
)
actions= @(
@{
type = "button"
text = "Take me to the deployment"
url = "$deployment_url"
style = "primary"
}
@{
type = "button"
text = "Take me to the build"
url = "$build_url"
style = "primary"
}
)
}
)
}

$json_request = $json_message | ConvertTo-Json -Depth 10

Invoke-WebRequest -UseBasicParsing "$slack_webhook_url" -ContentType "application/json" -Method POST -Body "$json_request"

}
else {
Write-Log "Deployment will not be launched as you have passed in an argument specifying that it should not be (START_DEPLOYMENT=${launch_deployment}). Remove it to have your build launch a deployment."
}

Finish-Event "launch-deployment" "deploy-unreal-gdk-example-project-:windows:"

popd
Finish-Event "deploy-game" "build-unreal-gdk-example-project-:windows:"
151 changes: 151 additions & 0 deletions ci/setup-and-build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
param(
[string] $exampleproject_home = (get-item "$($PSScriptRoot)").parent.FullName, ## The root of the repo
[string] $gdk_repo = "git@github.com:spatialos/UnrealGDK.git",
[string] $gcs_publish_bucket = "io-internal-infra-unreal-artifacts-production/UnrealEngine",
[string] $deployment_launch_configuration = "one_worker_test.json",
[string] $deployment_snapshot_path = "snapshots/FPS-Start_Small.snapshot",
[string] $deployment_cluster_region = "eu",
[string] $project_name = "unreal_gdk"
)

. "$PSScriptRoot\common.ps1"

# When a build is launched custom environment variables can be specified.
# Parse them here to use the set value or the default.
$gdk_branch_name = Get-Env-Variable-Value-Or-Default -environment_variable_name "GDK_BRANCH" -default_value "master"
$launch_deployment = Get-Env-Variable-Value-Or-Default -environment_variable_name "START_DEPLOYMENT" -default_value "true"

$gdk_home = "${exampleproject_home}\Game\Plugins\UnrealGDK"

pushd "$exampleproject_home"
Start-Event "clone-gdk-plugin" "build-unreal-gdk-example-project-:windows:"
pushd "Game"
New-Item -Name "Plugins" -ItemType Directory -Force
pushd "Plugins"
Start-Process -Wait -PassThru -NoNewWindow -FilePath "git" -ArgumentList @(`
"clone", `
"$gdk_repo", `
"--depth 1", `
"-b $gdk_branch_name"
)
popd
popd
Finish-Event "clone-gdk-plugin" "build-unreal-gdk-example-project-:windows:"

Start-Event "get-gdk-head-commit" "build-unreal-gdk-example-project-:windows:"
pushd $gdk_home
# Get the short commit hash of this gdk build for later use in assembly name
$gdk_commit_hash = (git rev-parse HEAD).Substring(0,7)
Write-Log "GDK at commit: $gdk_commit_hash on branch $gdk_branch_name"
popd
Finish-Event "get-gdk-head-commit" "build-unreal-gdk-example-project-:windows:"

Start-Event "set-up-gdk-plugin" "build-unreal-gdk-example-project-:windows:"
pushd $gdk_home
# Invoke the GDK's setup script
&"$($gdk_home)\ci\setup-gdk.ps1"
popd
Finish-Event "set-up-gdk-plugin" "build-unreal-gdk-example-project-:windows:"

# Use the cached engine version or set it up if it has not been cached yet.
Start-Event "set-up-engine" "build-unreal-gdk-example-project-:windows:"

$engine_directory = "${exampleproject_home}\UnrealEngine"
&"$($gdk_home)\ci\get-engine.ps1" -unreal_path "$engine_directory"

Finish-Event "set-up-engine" "build-unreal-gdk-example-project-:windows:"


Start-Event "associate-uproject-with-engine" "build-unreal-gdk-example-project-:windows:"
pushd $engine_directory
$unreal_version_selector_path = "Engine\Binaries\Win64\UnrealVersionSelector.exe"

$find_engine_process = Start-Process -Wait -PassThru -NoNewWindow -FilePath $unreal_version_selector_path -ArgumentList @(`
"-switchversionsilent", `
"${exampleproject_home}\Game\GDKShooter.uproject", `
"$engine_directory"
)

if ($find_engine_process.ExitCode -ne 0) {
Write-Log "Failed to set Unreal Engine association for the project. Error: $($find_engine_process.ExitCode)"
Throw "Failed to set Engine association"
}
popd
Finish-Event "associate-uproject-with-engine" "build-unreal-gdk-example-project-:windows:"


$build_script_path = "$($gdk_home)\SpatialGDK\Build\Scripts\BuildWorker.bat"

Start-Event "build-editor" "build-unreal-gdk-example-project-:windows:"
# Build the project editor to allow the snapshot and schema commandlet to run
$build_editor_proc = Start-Process -PassThru -NoNewWindow -FilePath $build_script_path -ArgumentList @(`
"GDKShooterEditor", `
"Win64", `
"Development", `
"GDKShooter.uproject"
)

# Explicitly hold on to the process handle.
# This works around an issue whereby Wait-Process would fail to find build_editor_proc
$build_editor_handle = $build_editor_proc.Handle

Wait-Process -Id (Get-Process -InputObject $build_editor_proc).id
if ($build_editor_proc.ExitCode -ne 0) {
Write-Log "Failed to build Win64 Development Editor. Error: $($build_editor_proc.ExitCode)"
Throw "Failed to build Win64 Development Editor"
}
Finish-Event "build-editor" "build-unreal-gdk-example-project-:windows:"

# Invoke the GDK commandlet to generate schema and snapshot. Note: this needs to be run prior to cooking
Start-Event "generate-schema" "build-unreal-gdk-example-project-:windows:"
pushd "UnrealEngine/Engine/Binaries/Win64"
Start-Process -Wait -PassThru -NoNewWindow -FilePath ((Convert-Path .) + "\UE4Editor.exe") -ArgumentList @(`
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will have to be changed soon when @mattyoung-improbable schema gen work goes in.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, we should keep that in mind. Can you link me the relevant ticket so that I can add a note to update CIs?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Work is detailed in UNR-2000. This is a non-breaking change for now, we'll update it when that changes.

"$($exampleproject_home)/Game/GDKShooter.uproject", `
"-run=GenerateSchemaAndSnapshots", `
"-MapPaths=`"/Maps/FPS-Start_Small`""
)

# TODO (GV-29) this is also being done as part of setup.bat. We should look into calling setup.bat instead of this, but need to make sure it doesn't brake if called after setup-gdk.ps1
$core_gdk_schema_path = "$($gdk_home)\SpatialGDK\Extras\schema\*"
Copy link
Collaborator

Choose a reason for hiding this comment

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

These schema copying steps are done within setup.bat/setup.sh. Is there a reason we aren't using that script here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a comment to fix this in future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ticket number: GV-29

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, thanks @mironec ! I'll link that.

$schema_std_lib_path = "$($gdk_home)\SpatialGDK\Binaries\ThirdParty\Improbable\Programs\schema\*"
New-Item -Path "$($exampleproject_home)\spatial\schema\unreal" -Name "gdk" -ItemType Directory -Force
New-Item -Path "$($exampleproject_home)\spatial" -Name "\build\dependencies\schema\standard_library" -ItemType Directory -Force
Copy-Item "$($core_gdk_schema_path)" -Destination "$($exampleproject_home)\spatial\schema\unreal\gdk" -Force -Recurse
Copy-Item "$($schema_std_lib_path)" -Destination "$($exampleproject_home)\spatial\build\dependencies\schema\standard_library" -Force -Recurse
popd
Finish-Event "generate-schema" "build-unreal-gdk-example-project-:windows:"

Start-Event "build-win64-client" "build-unreal-gdk-example-project-:windows:"
$build_client_proc = Start-Process -PassThru -NoNewWindow -FilePath $build_script_path -ArgumentList @(`
"GDKShooter", `
"Win64", `
"Development", `
"GDKShooter.uproject"
)
$build_client_handle = $build_client_proc.Handle
Wait-Process -Id (Get-Process -InputObject $build_client_proc).id
if ($build_client_proc.ExitCode -ne 0) {
Write-Log "Failed to build Win64 Development Client. Error: $($build_client_proc.ExitCode)"
Throw "Failed to build Win64 Development Client"
}
Finish-Event "build-win64-client" "build-unreal-gdk-example-project-:windows:"

Start-Event "build-linux-worker" "build-unreal-gdk-example-project-:windows:"
$build_server_proc = Start-Process -PassThru -NoNewWindow -FilePath $build_script_path -ArgumentList @(`
"GDKShooterServer", `
"Linux", `
"Development", `
"GDKShooter.uproject"
)
$build_server_handle = $build_server_proc.Handle
Wait-Process -Id (Get-Process -InputObject $build_server_proc).id

if ($build_server_proc.ExitCode -ne 0) {
Write-Log "Failed to build Linux Development Server. Error: $($build_server_proc.ExitCode)"
Throw "Failed to build Linux Development Server"
}
Finish-Event "build-linux-worker" "build-unreal-gdk-example-project-:windows:"

# Deploy the project to SpatialOS
&$PSScriptRoot"\deploy.ps1" -launch_deployment "$launch_deployment" -gdk_branch_name "$gdk_branch_name"
popd