-
Notifications
You must be signed in to change notification settings - Fork 1
285 lines (270 loc) · 12.7 KB
/
build-and-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
name: Build the project and run Olympus test suites
run-name: Testing runtime ${{ inputs.runtime }}
on:
push:
paths-ignore:
- "**.md"
tags:
- "*"
workflow_dispatch:
inputs:
runtime:
description: 'Target runtime'
required: false
runner:
description: 'Runner'
required: false
workflow_call:
inputs:
runtime:
description: 'Target runtime'
required: false
type: string
runner:
description: 'Runner'
required: false
type: string
permissions:
contents: write
env:
MATRIX_STRING: '[\"windows-latest\",\"ubuntu-latest\", \"macOS-latest\"]'
RAW_TEST_RESULT_FILE_NAME: 'ganary.raw.olympus.json'
TEST_RESULT_FILE_NAME: 'result.json'
jobs:
# By default, this workflow will run on Windows, Ubuntu, and MacOS runners, making and testing the Windows, Android, and iOS builds. However, this job checks for the manual input of `runner` to override the default, so we can manually run the workflow on a specific runner instead of all three.
runner:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- if: ${{ inputs.runner }}
run: echo "MATRIX_STRING=[\\\"${{ github.event.inputs.runner }}\\\"]" >> $GITHUB_ENV
- id: set-matrix
run: echo "matrix=${{ env.MATRIX_STRING }}" >> $GITHUB_OUTPUT
test:
needs: runner
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ${{ fromJSON(needs.runner.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
with:
lfs: true
#region Get the version from the yyp file
- name: Get the version from the yyp file for Linux
if: runner.os == 'Linux'
run: |
echo "YYP_VERSION=$(grep -oP '(?<=IDEVersion":")(\d+\.\d+\.\d+\.\d+)(?=")' ${{ github.workspace }}/Ganary/Ganary.yyp)" >> $GITHUB_ENV
- name: Get the version from the yyp file for MacOS
if: runner.os == 'macOS'
run: |
echo "YYP_VERSION=$(egrep -o 'IDEVersion":"([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)' ${GITHUB_WORKSPACE}/Ganary/Ganary.yyp | cut -d '"' -f 3)" >> $GITHUB_ENV
- name: Get the version from the yyp file for Windows
if: runner.os == 'Windows'
run: |
$yypVersion = Select-String -Path "${env:GITHUB_WORKSPACE}\Ganary\Ganary.yyp" -Pattern 'IDEVersion":"(\d+\.\d+\.\d+\.\d+)' -AllMatches | ForEach-Object { $_.Matches.Groups[1].Value }
"YYP_VERSION=$yypVersion" | Out-File -Append -FilePath $env:GITHUB_ENV
#endregion
#region Android setup
- name: Create the keystore file from secrets
id: write_file
if: runner.os == 'Linux'
uses: timheuer/[email protected]
with:
fileName: 'myTemporaryFile.keystore'
encodedString: ${{ secrets.KEYSTORE_BASE64 }}
- name: Create the local-settings-override-file for igor-setup
if: runner.os == 'Linux'
run: |
echo "{
\"machine.Platform Settings.Android.Keystore.filename\": \"${{ steps.write_file.outputs.filePath }}\",
\"machine.Platform Settings.Android.Keystore.keystore_password\": \"${{ secrets.KEYSTORE_PASSWORD }}\",
\"machine.Platform Settings.Android.Keystore.keystore_alias_password\": \"${{ secrets.KEYSTORE_PASSWORD }}\",
\"machine.Platform Settings.Android.Keystore.alias\": \"${{ secrets.KEYSTORE_USERNAME }}\",
\"machine.Platform Settings.Android.Paths.jdk_location\": \"$JAVA_HOME_17_X64\"
}" > local_settings.json
- name: Set up ffmpeg # This step may be removed when https://github.com/YoYoGames/GameMaker-Bugs/issues/4977 is fixed
uses: FedericoCarboni/setup-ffmpeg@v3
with:
ffmpeg-version: '6.1.0'
if: runner.os == 'Linux'
- name: Set Up Android SDK's platform-tools # The default Android SDK does not include platform-tools and its component `adb`, which is required by Igor for the Android build
if: runner.os == 'Linux'
run: |
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager \
--sdk_root=$ANDROID_SDK_ROOT \
"platform-tools"
#endregion
- name: use Igor Setup
uses: bscotch/igor-setup@develop
with:
access-key: ${{ secrets.ACCESS_KEY }}
target-yyp: ${{ github.workspace }}/Ganary/Ganary.yyp
local-settings-override-file: ${{ github.workspace }}/local_settings.json
runtime-version: ${{ inputs.runtime }}
cache: true
id: igor
- name: use Igor build
uses: bscotch/igor-build@main
id: build
timeout-minutes: 30
with:
yyp-path: ${{ github.workspace }}/Ganary/Ganary.yyp
user-dir: ${{ steps.igor.outputs.user-dir }}
# region Build for iOS through Fastlane
- if: runner.os == 'MacOS'
name: Set up the Fastlane fast file and build the XCode project
timeout-minutes: 30
working-directory: ${{ steps.build.outputs.out-dir }}
env:
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} # This is the password for the match repo, see https://docs.fastlane.tools/actions/match/#:~:text=for%20each%20app.-,Passphrase,-Git%20Repo%20storage
MATCH_GIT_BASIC_AUTHORIZATION: ${{ secrets.MATCH_GIT_BASIC_AUTHORIZATION }} # This is the basic authorization for the match repo, see https://docs.fastlane.tools/actions/match/#:~:text=MATCH_GIT_BASIC_AUTHORIZATION
run: |
# Create the fastlane/Fastfile with the following content
mkdir -p fastlane
cat << EOF > fastlane/Fastfile
lane :beta do
setup_ci
matchType = "appstore"
bundleId = "com.bscotch.ganary"
match(
type: matchType,
git_url:"https://github.com/bscotch/public-project-ios-match-files.git",
storage_mode: "git",
shallow_clone: "true",
app_identifier: bundleId,
readonly: "true",
)
update_code_signing_settings(
use_automatic_signing: false,
team_id: ENV["sigh_#{bundleId}_#{matchType}_team-id"],
profile_name: ENV["sigh_#{bundleId}_#{matchType}_profile-name"],
code_sign_identity: "iPhone Distribution"
)
build_app
sh("echo firebase-bin-name=#{lane_context[SharedValues::IPA_OUTPUT_PATH]} >> $GITHUB_ENV")
end
EOF
# Run fastlane beta
fastlane beta
echo firebase-test-type=ios >> $GITHUB_ENV
- name: upload build as artifact
uses: actions/upload-artifact@v4
with:
name: igor-build-${{ matrix.os }}
path: ${{ steps.build.outputs.out-dir }}
# endregion
# region Windows testing
- if: runner.os == 'Windows'
name: Run Olympus test
timeout-minutes: 10
shell: pwsh
working-directory: ${{ steps.build.outputs.out-dir }}
run: |
$baseName = "Ganary"
Expand-Archive -Path ${{ steps.build.outputs.out-dir }}/$baseName.zip -Destination ${{ steps.build.outputs.out-dir }}
$saveDataDir = Join-Path $env:LOCALAPPDATA $baseName
$executableName = "Ganary"
$exeDir = Resolve-Path "$executableName.exe"
if (-not (Test-Path $exeDir)) {
throw "$exeDir does not exist"
}
$logFile = "runLog.txt"
if ((Test-Path $logFile)) {
Remove-Item $logFile -Force
}
New-Item -Path $logFile -ItemType File -Force
$logFile = Resolve-Path $logFile
Write-Host "Running $exeDir"
$process = Start-Process -FilePath $exeDir -ArgumentList "--olympus_headless","-output","$logFile","-debugoutput","$logFile" -PassThru -NoNewWindow
if ((Test-Path $saveDataDir)) {
Remove-Item $saveDataDir -Recurse -Force
}
$process.WaitForExit()
$success = $true
$olympusResultDir = Join-Path $saveDataDir "Olympus_records/internal/${{ env.RAW_TEST_RESULT_FILE_NAME }}"
$resultDir = Join-Path ${{ github.workspace }} "${{ env.TEST_RESULT_FILE_NAME }}"
Write-Host "Copying $olympusResultDir to $resultDir"
cp $olympusResultDir $resultDir
# endregion
# region Mobile testing on Firebase Test Lab https://firebase.google.com/docs/test-lab
- if: runner.os == 'Linux'
name: Set firebase test type and artifact name
run: |
echo firebase-bin-name=${{ steps.build.outputs.out-dir }}/${{ steps.build.outputs.out-name }} >> $GITHUB_ENV
echo firebase-test-type=android >> $GITHUB_ENV
- uses: google-github-actions/auth@v2
if: runner.os == 'Linux'|| runner.os == 'macOS'
with:
credentials_json: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_JSON }} # This service account should have the editor role for the project, and the Google Cloud Testing API and Cloud Tool Results API should be enabled. See https://firebase.google.com/docs/test-lab/android/continuous#:~:text=Create%20and%20authorize%20a%20service%20account
- name: Set up Cloud SDK
if: runner.os == 'Linux'|| runner.os == 'macOS'
uses: google-github-actions/setup-gcloud@v2
with:
install_components: beta
project_id: ganary-fd9e0
- name: Use gcloud CLI to run the game loop test and output result to a file #For more options of gcloud CLI, see https://firebase.google.com/docs/test-lab/android/command-line
if: runner.os == 'Linux'|| runner.os == 'macOS'
run: |
gcloud beta firebase test ${{ env.firebase-test-type }} run \
--type game-loop \
--app ${{ env.firebase-bin-name }} \
--timeout 5m \
--scenario-numbers=1 \
--client-details=matrixLabel="${{ runner.os }}-${{ env.YYP_VERSION }}-${{ inputs.runtime}}" \
--format="text(axis_value)" 2>&1 | tee test_output.txt
- name: Parse the output to get the GCS bucket and axis value
if: runner.os == 'Linux'|| runner.os == 'macOS'
run: |
gcs_url_part=$(cat test_output.txt | grep -o 'https://console.developers.google.com/storage/browser/\S*')
# Extract the unique part from the GCS bucket URL
unique_part=$(echo "$gcs_url_part" | sed 's/https:\/\/console.developers.google.com\/storage\/browser\///g')
# Remove the trailing bracket
unique_part=$(echo "$unique_part" | sed 's/]//g')
echo "The unique part of the GCS bucket URL is: $unique_part"
echo "GCS_BUCKET_URL=$unique_part" >> $GITHUB_ENV
# Get the axis_value
axis_value=$(grep "axis_value:" test_output.txt | awk -F': ' '{print $2}')
echo "The AXIS_VALUE is $axis_value"
echo "AXIS_VALUE=$axis_value" >> $GITHUB_ENV
- name: Get the results json from GSC bucket for Android
if: runner.os == 'Linux'
run: |
gcloud storage cp gs://${{env.GCS_BUCKET_URL}}${{env.AXIS_VALUE}}/game_loop_results/results_scenario_1.json ${{ env.TEST_RESULT_FILE_NAME }}
- name: Get the results json from GSC bucket for iOS
if: runner.os == 'macOS'
run: |
gcloud storage cp gs://${{env.GCS_BUCKET_URL}}${{env.AXIS_VALUE}}/CustomResults/${{env.RAW_TEST_RESULT_FILE_NAME}} ${{ env.TEST_RESULT_FILE_NAME }}
- name: upload test result as artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-test-result
path: ${{ env.TEST_RESULT_FILE_NAME }}
- name: Parse the results json in powershell
shell: pwsh
run: |
$success = $true
$filePath="${{ env.TEST_RESULT_FILE_NAME }}"
$json = Get-Content $filePath | ConvertFrom-Json
$suiteName = $json.name
if ($json.status -ne "completed") {
$failMessage = "$suiteName : this suite did not complete."
Write-Host $failMessage
$success = $false
}
foreach ($test in $json.tests) {
if ($test.status -eq "failed" -or $test.status -eq "crashed") {
$failMessage = "$($test.name): $($test.status)"
Write-Host $failMessage
$success = $false
}
}
if ($success) {
Write-Host "Olympus test completed with no failure or crashes."
exit 0
} else {
exit 1
}
# endregion