-
Notifications
You must be signed in to change notification settings - Fork 1
266 lines (249 loc) · 10.1 KB
/
ci.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
name: CI
on:
push:
paths-ignore:
- "**.md"
tags:
- "*"
workflow_dispatch:
inputs:
runtime:
description: 'Target runtime'
required: false
runner:
description: 'Runner'
required: false
default: 'macOS-latest'
workflow_call:
inputs:
runtime:
description: 'Target runtime'
required: false
type: string
runner:
description: 'Runner'
required: false
default: 'macOS-latest'
type: string
permissions:
contents: write
env:
MATRIX_STRING: '[\"windows-latest\",\"ubuntu-latest\", \"macOS-latest\"]'
jobs:
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 }}
# runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: ${{ fromJSON(needs.runner.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
with:
lfs: true
- 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
- uses: FedericoCarboni/setup-ffmpeg@v3
if: runner.os == 'Linux'
- name: Create the settings file
if: runner.os == 'Linux'
run: |
echo '{"machine.Platform Settings.Android.Keystore.filename": "${{ github.workspace }}/ascx.keystore", "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 }}"}' > local_settings.json
- name: Set Up Android tools (Linux only)
if: runner.os == 'Linux'
run: |
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager \
--sdk_root=$ANDROID_SDK_ROOT \
"platform-tools"
- uses: actions/cache@v4
with:
path: |
${{ github.workspace }}/bootstrapper
${{ github.workspace }}/runtimes
key: ${{ runner.os }}-${{ env.YYP_VERSION }}-${{ inputs.runtime}}
- name: use Igor Setup
uses: bscotch/igor-setup@main
with:
access-key: ${{ secrets.ACCESS_KEY }}
target-yyp: ${{ github.workspace }}/Ganary/Ganary.yyp
local-settings-override-file: ${{ github.workspace }}/local_settings.json
runtime: ${{ inputs.runtime }}
id: igor
- name: Read settings-dir and echo the json content
run: |
echo "UserDir: ${{ steps.igor.outputs.settings-dir }}"
# Read the json content
cat ${{ steps.igor.outputs.settings-dir }}
- 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 }}
- if: runner.os == 'MacOS'
name: Build the XCode project
timeout-minutes: 30
working-directory: ${{ steps.build.outputs.out-dir }}
env:
MATCH_PASSWORD: ${{ secrets.MATCH_PASSPHRASE }}
MATCH_GIT_BASIC_AUTHORIZATION: ${{ secrets.MATCH_REPO_ACCESS }}
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
uses: actions/upload-artifact@v4
with:
name: igor-build-${{ matrix.os }}
path: ${{ steps.build.outputs.out-dir }}
retention-days: 1
# region start: Windows testing
- if: runner.os == 'Windows'
name: Run Olympus test
timeout-minutes: 30
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()
$reader = [System.IO.StreamReader]::new($logFile)
try {
while (-not $reader.EndOfStream) {
$line = $reader.ReadLine()
# Process the line
Write-Output $line
}
}
finally {
$reader.Close()
}
$success = $true
$olympusResultDir = Join-Path $saveDataDir "Olympus_records/internal"
# Iterate through all the json files in the directory
$files = Get-ChildItem $olympusResultDir -Filter "*.json"
foreach ($file in $files) {
$filePath = $file.FullName
$json = Get-Content $filePath | ConvertFrom-Json
$suiteName = $json.name
if ($json.status -ne "completed") {
$failMessage = "$suiteName : this suite did not complete."
Write-Error $failMessage
Add-Content $logFile $failMessage
$success = $false
}
foreach ($test in $json.tests) {
if ($test.status -eq "failed" -or $test.status -eq "crashed") {
$failMessage = "$($test.name): $($test.status)"
Write-Error $failMessage
Add-Content $logFile $failMessage
$success = $false
}
}
}
if ($success) {
Write-Host "Olympus test completed with no failure or crashes."
exit 0
} else {
exit 1
}
# endregion
# region start Mobile testing
- 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 }}
- 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
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 1m \
--scenario-numbers=1 \
--client-details=matrixLabel="${{ runner.os }}-${{ env.YYP_VERSION }}-${{ inputs.runtime}}" | tee test_output.txt
- name: Parse the output and fail the run if the content does not contains the string `│ Passed │`
if: runner.os == 'Linux'|| runner.os == 'macOS'
run: |
if grep -q "│ Passed │" test_output.txt; then
echo "Game loop test passed"
else
echo "Game loop test failed"
exit 1
fi
# endregion