Testing runtime 2024.1100.0.682 #83
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
platform: | |
description: 'Platform' | |
required: false | |
workflow_call: | |
inputs: | |
runtime: | |
description: 'Target runtime' | |
required: false | |
type: string | |
runner: | |
description: 'Runner' | |
required: false | |
type: string | |
platform: | |
description: 'Platform' | |
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 | |
modules: ${{inputs.platform}} | |
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 }} | |
platform: ${{inputs.platform}} | |
# 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 |