Skip to content

Commit add67d2

Browse files
mironecjessicafalk
andauthored
Better branch detection for CI in the example project (#185)
* Update CI to look for corresponding GDK branch * Try to infer branch even more * Fix relative directory path to UnrealGDKVersion * Add comment explanation * Update ci/generate-pipeline-steps.sh Co-authored-by: jessicafalk <31853332+jessicafalk@users.noreply.github.com> * Update ci/generate-pipeline-steps.sh Co-authored-by: jessicafalk <31853332+jessicafalk@users.noreply.github.com> * Update ci/generate-pipeline-steps.sh Co-authored-by: jessicafalk <31853332+jessicafalk@users.noreply.github.com> * Update ci/generate-pipeline-steps.sh Co-authored-by: jessicafalk <31853332+jessicafalk@users.noreply.github.com> * Update ci/generate-pipeline-steps.sh Co-authored-by: jessicafalk <31853332+jessicafalk@users.noreply.github.com> * Update ci/generate-pipeline-steps.sh * Switch to grep for finding substring * Fix wrong version of the branch to use * Actually use the GDK_BRANCH in subsequent steps Co-authored-by: jessicafalk <31853332+jessicafalk@users.noreply.github.com>
1 parent c3d1142 commit add67d2

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

ci/generate-pipeline-steps.sh

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,27 @@ else
1111
REPLACE_STRING="s|BUILKDITE_AGENT_PLACEHOLDER|windows|g"
1212
fi
1313

14-
# 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
14+
# 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.
1515
# 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
16-
# which would be our other option for downloading a single file
17-
GDK_BRANCH_LOCAL="${GDK_BRANCH:-master}"
16+
# which would be our other option for downloading a single file.
17+
# Also resolve the GDK branch to run against. The order of priority is:
18+
# GDK_BRANCH envvar > same-name branch as the branch we are currently on > UnrealGDKVersion.txt > "master".
19+
GDK_BRANCH_LOCAL="${GDK_BRANCH:-}"
20+
if [ -z "${GDK_BRANCH_LOCAL}" ]; then
21+
GDK_REPO_HEADS=$(git ls-remote --heads "git@github.com:spatialos/UnrealGDK.git" "${BUILDKITE_BRANCH}")
22+
EXAMPLEPROJECT_REPO_HEAD="refs/heads/${BUILDKITE_BRANCH}"
23+
if echo "${GDK_REPO_HEADS}" | grep -qF "${EXAMPLEPROJECT_REPO_HEAD}"; then
24+
GDK_BRANCH_LOCAL="${BUILDKITE_BRANCH}"
25+
else
26+
GDK_VERSION=$(cat UnrealGDKVersion.txt)
27+
if [ -z "${GDK_VERSION}" ]; then
28+
GDK_BRANCH_LOCAL="master"
29+
else
30+
GDK_BRANCH_LOCAL="${GDK_VERSION}"
31+
fi
32+
fi
33+
fi
34+
1835
NUMBER_OF_TRIES=0
1936
while [ $NUMBER_OF_TRIES -lt 5 ]; do
2037
CURL_TIMEOUT=$((10<<NUMBER_OF_TRIES))
@@ -43,6 +60,7 @@ if [ -z "${ENGINE_VERSION}" ]; then
4360

4461
export ENGINE_COMMIT_HASH="${COMMIT_HASH}"
4562
export STEP_NUMBER
63+
export GDK_BRANCH="${GDK_BRANCH_LOCAL}"
4664
sed $REPLACE_STRING "${BUILDKITE_TEMPLATE_FILE}" | buildkite-agent pipeline upload
4765
STEP_NUMBER=$((STEP_NUMBER+1))
4866
done
@@ -51,7 +69,8 @@ if [ -z "${ENGINE_VERSION}" ]; then
5169
STEP_NUMBER=$((STEP_NUMBER-1))
5270
buildkite-agent meta-data set "engine-version-count" "${STEP_NUMBER}"
5371
else
54-
echo "Generating steps for the specified engine version: $ENGINE_VERSION"
55-
export ENGINE_COMMIT_HASH=${ENGINE_VERSION}
72+
echo "Generating steps for the specified engine version: ${ENGINE_VERSION}"
73+
export ENGINE_COMMIT_HASH="${ENGINE_VERSION}"
74+
export GDK_BRANCH="${GDK_BRANCH_LOCAL}"
5675
sed $REPLACE_STRING "${BUILDKITE_TEMPLATE_FILE}" | buildkite-agent pipeline upload
5776
fi

ci/nightly.template.steps.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,5 @@ steps:
6161
env:
6262
ENGINE_COMMIT_HASH: "${ENGINE_COMMIT_HASH}"
6363
STEP_NUMBER: "${STEP_NUMBER}"
64+
GDK_BRANCH: "${GDK_BRANCH}"
6465
UE-SharedDataCachePath: "\\\\gdk-for-unreal-cache.${CI_ENVIRONMENT}-intinf-eu1.i8e.io\\samba\\ddc"

0 commit comments

Comments
 (0)