diff --git a/.buildkite/nightly.steps.yaml b/.buildkite/nightly.steps.yaml index d5c97496..6700940f 100644 --- a/.buildkite/nightly.steps.yaml +++ b/.buildkite/nightly.steps.yaml @@ -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" @@ -7,7 +19,7 @@ common: &common - "permission_set=builder" - "platform=windows" - "scaler_version=2" - - "queue=${CI_WINDOWS_BUILDER_QUEUE:-v3-1572610922-3d03d5c2f13b7fa4-------z}" # Has FASTbuild disabled + - "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: @@ -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/*" diff --git a/ci/deploy.ps1 b/ci/deploy.ps1 index 10e06720..0572c075 100644 --- a/ci/deploy.ps1 +++ b/ci/deploy.ps1 @@ -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" @@ -66,96 +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" } + + 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." } - - if ($env:BUILDKITE_BRANCH -eq "master" -or $env:BUILDKITE_SLACK_NOTIFY -eq "true") { - # Send a Slack notification with a link to the new deployment and to the build. - - # 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} - - $deployment_url = "https://console.improbable.io/projects/${project_name}/deployments/${deployment_name}/overview" - $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 and potential deployment here: $deployment_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") { - $deployment_button = @{ - type = "button" - text = ":cloud: Deployment" - 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 "launch-deployment" "deploy-unreal-gdk-example-project-:windows:" popd diff --git a/ci/generate-pipeline-steps.sh b/ci/generate-pipeline-steps.sh new file mode 100644 index 00000000..fd65e57f --- /dev/null +++ b/ci/generate-pipeline-steps.sh @@ -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<