Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
34 changes: 29 additions & 5 deletions .buildkite/nightly.steps.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
script_runner: &script_runner
agents:
- "agent_count=8"
- "capable_of_building=platform"
- "environment=production"
- "machine_type=quarter"
- "permission_set=builder"
- "platform=linux"
- "queue=${CI_LINUX_BUILDER_QUEUE:-v3-1572524284-e64831bf1e88b227-------z}"
- "scaler_version=2"
- "working_hours_time_zone=london"

common: &common
agents:
- "agent_count=1"
Expand All @@ -7,7 +19,7 @@ common: &common
- "permission_set=builder"
- "platform=windows"
- "scaler_version=2"
- "queue=${CI_WINDOWS_BUILDER_QUEUE:-v3-1569490589-f9345a43b21a6cec-------z}"
- "queue=${CI_WINDOWS_BUILDER_QUEUE:-v4-2019-11-07-bk3700-fbffad576b9676d7}" # Has FASTbuild disabled
timeout_in_minutes: 60 # TODO(ENG-548): reduce timeout once agent-cold-start is optimised.
retry:
automatic:
Expand All @@ -17,9 +29,21 @@ common: &common
plugins:
- ca-johnson/taskkill#v4.1: ~

# NOTE: step labels turn into commit-status names like {org}/{repo}/{pipeline}/{step-label}, lower-case and hyphenated.
# These are then relied on to have stable names by other things, so once named, please beware renaming has consequences.

steps:
- label: "build-and-deploy-:windows:"
command: powershell -NoProfile -NonInteractive -InputFormat Text -Command ./ci/setup-and-build.ps1
- label: "generate-pipeline-steps"
commands:
- "chmod -R +rwx ci"
- "ci/generate-pipeline-steps.sh"
env:
ENGINE_VERSION: "${ENGINE_VERSION}"
<<: *script_runner

- wait

- label: "slack-notify"
if: build.env("SLACK_NOTIFY") == "true" || build.branch == "master"
command: "powershell -NoProfile -NonInteractive -InputFormat Text -Command ./ci/slack-notify.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/*"
Binary file modified Game/Content/Controllers/BP_GDK_PlayerController.uasset
Binary file not shown.
Binary file modified Game/Content/GameMode/BP_DeathmatchGameState.uasset
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ void AGDKPlayerController::BeginPlay()

void AGDKPlayerController::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);

if (GetPawn())
{
LatestPawnYaw = GetPawn()->GetActorRotation().Yaw;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class GDKSHOOTER_API UDeathmatchSpawnerComponent : public UActorComponent
UFUNCTION(BlueprintCallable)
void DisableSpawning() { bSpawningEnabled = false; }

UFUNCTION(BlueprintCallable)
bool IsSpawningEnabled() { return bSpawningEnabled; }

protected:
AActor* GetSpawnPoint(APlayerController* Controller);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class GDKSHOOTER_API UTimerComponent : public UActorComponent
UPROPERTY(EditDefaultsOnly)
bool bAutoStart = false;
UPROPERTY(EditDefaultsOnly)
int32 DefaultTimerDuration = 300;
int32 DefaultTimerDuration = 7200;

UPROPERTY(Replicated, BlueprintReadOnly)
bool bIsTimerRunning = false;
Expand Down
67 changes: 7 additions & 60 deletions ci/deploy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ param(
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)"
$deployment_name = "exampleproject$($env:STEP_NUMBER)_${date_and_time}_$($gdk_commit_hash)"
$assembly_name = "$($deployment_name)_asm"

pushd "spatial"
Expand Down Expand Up @@ -66,74 +66,21 @@ pushd "spatial"
"--snapshot=$deployment_snapshot_path", `
"--cluster_region=$deployment_cluster_region", `
"--log_level=debug", `
"--tags=ttl_1_hours"
"--tags=ttl_1_hours", `
"--deployment_description=`"Engine commit: $($env:ENGINE_COMMIT_HASH)`"" `
)

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"
$gdk_commit_url = "https://github.com/spatialos/UnrealGDK/tree/${gdk_commit_hash}"
$build_url = "$env:BUILDKITE_BUILD_URL"

$json_message = [ordered]@{
text = "Example Project build created by $env:BUILDKITE_BUILD_CREATOR succeeded and a deployment has been launched."
attachments= @(
@{
fallback = "Find deployment here: $deployment_url and build here: $build_url"
color = "good"
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 GDK commit"
url = "$gdk_commit_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 {
buildkite-agent meta-data set "deployment-name-$($env:STEP_NUMBER)" "$deployment_name"
buildkite-agent meta-data set "project-name" "$project_name"
buildkite-agent meta-data set "gdk-commit-hash" "$gdk_commit_hash)"
} 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
Expand Down
39 changes: 39 additions & 0 deletions ci/generate-pipeline-steps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
set -euo pipefail

# Download the unreal-engine.version file from the GDK repo so we can run the example project builds on the same versions the GDK was run against
# This is not the pinnacle of engineering, as we rely on GitHub's web interface to download the file, but it seems like GitHub disallows git archive
# which would be our other option for downloading a single file
GDK_BRANCH_LOCAL="${GDK_BRANCH:-master}"
NUMBER_OF_TRIES=0
while [ $NUMBER_OF_TRIES -lt 5 ]; do
CURL_TIMEOUT=$((10<<NUMBER_OF_TRIES))
NUMBER_OF_TRIES=$((NUMBER_OF_TRIES+1))
echo "Trying to download unreal-engine.version from GitHub's UnrealGDK repository, try: $NUMBER_OF_TRIES, timeout: $CURL_TIMEOUT seconds ..."
curl -L -m $CURL_TIMEOUT https://raw.githubusercontent.com/spatialos/UnrealGDK/$GDK_BRANCH_LOCAL/ci/unreal-engine.version -o ci/unreal-engine.version
if [ $? -eq 0 ]; then
break
fi
done

# This script generates BuildKite steps for each engine version we want to test against.
# We retrieve these engine versions from the unreal-engine.version file in the UnrealGDK repository.
# The steps are based on the template in nightly.template.steps.yaml.

if [ -z "${ENGINE_VERSION}" ]; then
echo "Generating build steps for each engine version listed in unreal-engine.version"
STEP_NUMBER=1
IFS=$'\n'
for commit_hash in $(cat < ci/unreal-engine.version); do
REPLACE_STRING="s|ENGINE_COMMIT_HASH_PLACEHOLDER|$commit_hash|g; s|STEP_NUMBER_PLACEHOLDER|$STEP_NUMBER|g"
sed $REPLACE_STRING ci/nightly.template.steps.yaml | buildkite-agent pipeline upload
STEP_NUMBER=$((STEP_NUMBER+1))
done
# We generate one build step for each engine version, which is one line in the unreal-engine.version file.
# The number of engine versions we are dealing with is therefore the counting variable from the above loop minus one.
STEP_NUMBER=$((STEP_NUMBER-1))
buildkite-agent meta-data set "engine-version-count" "$STEP_NUMBER"
else
echo "Generating steps for the specified engine version: $ENGINE_VERSION"
sed "s|ENGINE_COMMIT_HASH_PLACEHOLDER|$ENGINE_VERSION|g" ci/nightly.template.steps.yaml | buildkite-agent pipeline upload
fi
28 changes: 28 additions & 0 deletions ci/nightly.template.steps.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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:-v4-2019-11-07-bk3700-fbffad576b9676d7}" # Has FASTbuild disabled
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:
- ca-johnson/taskkill#v4.1: ~

steps:
- label: "build-and-deploy-:windows:-ENGINE_COMMIT_HASH_PLACEHOLDER"
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/*"
env:
ENGINE_COMMIT_HASH: "ENGINE_COMMIT_HASH_PLACEHOLDER"
STEP_NUMBER: "STEP_NUMBER_PLACEHOLDER"
11 changes: 1 addition & 10 deletions ci/setup-and-build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pushd "$exampleproject_home"
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)
$gdk_commit_hash = (git rev-parse HEAD).Substring(0,6)
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:"
Expand All @@ -55,7 +55,6 @@ pushd "$exampleproject_home"

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"
Expand Down Expand Up @@ -104,14 +103,6 @@ pushd "$exampleproject_home"
"-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\*"
$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:"

Expand Down
89 changes: 89 additions & 0 deletions ci/slack-notify.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
. "$PSScriptRoot\common.ps1"

$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"
$engine_version_count = buildkite-agent meta-data get "engine-version-count"
$project_name = buildkite-agent meta-data get "project-name"
$gdk_commit_hash = buildkite-agent meta-data get "gdk_commit_hash"

# Send a Slack notification with a link to the new deployment and to the build.
Start-Event "slack-notify" "slack-notify"
# Build Slack text
if ($env:BUILDKITE_NIGHTLY_BUILD -eq "true") {
$slack_text = ":night_with_stars: Nightly build of *Example Project* succeeded."
} else {
$slack_text = "*Example Project* build by $env:BUILDKITE_BUILD_CREATOR succeeded."
}

# 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}

$gdk_commit_url = "https://github.com/spatialos/UnrealGDK/commit/${gdk_commit_hash}"
$project_commit_url = "https://github.com/spatialos/UnrealGDKExampleProject/commit/$env:BUILDKITE_COMMIT"
$build_url = "$env:BUILDKITE_BUILD_URL"
$json_message = [ordered]@{
text = "$slack_text"
attachments= @(
@{
fallback = "Find build here: $build_url."
color = "good"
fields = @(
@{
title = "Build Message"
value = "$env:BUILDKITE_MESSAGE".Substring(0, [System.Math]::Min(64, "$env:BUILDKITE_MESSAGE".Length))
short = "true"
}
@{
title = "Example Project branch"
value = "$env:BUILDKITE_BRANCH"
short = "true"
}
@{
title = "GDK branch"
value = "$gdk_branch_name"
short = "true"
}
)
actions = @(
@{
type = "button"
text = ":github: Project commit"
url = "$project_commit_url"
style = "primary"
}
@{
type = "button"
text = ":github: GDK commit"
url = "$gdk_commit_url"
style = "primary"
}
@{
type = "button"
text = ":buildkite: BK build"
url = "$build_url"
style = "primary"
}
)
}
)
}

if ($launch_deployment -eq "true") {
for ($i = 0; $i -lt $engine_version_count; $i++){
$deployment_name = buildkite-agent meta-data get "deployment-name-$($i+1)"
$deployment_url = "https://console.improbable.io/projects/${project_name}/deployments/${deployment_name}/overview"
$deployment_button = @{
type = "button"
text = ":cloud: Deployment $($i+1)"
url = "$deployment_url"
style = "primary"
}
$json_message["attachments"][0]["actions"] += ($deployment_button)
}
}

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

Invoke-WebRequest -UseBasicParsing "$slack_webhook_url" -ContentType "application/json" -Method POST -Body "$json_request"
Finish-Event "slack-notify" "slack-notify"
2 changes: 1 addition & 1 deletion spatial/default_launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{
"name": "bridge_soft_handover_enabled",
"value": "false"
},
}
],
"snapshots": {
"snapshot_write_period_seconds": 0
Expand Down