forked from electronicarts/CnC_Generals_Zero_Hour
-
Notifications
You must be signed in to change notification settings - Fork 89
ci: Implement Replay Checker #1366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+329
−5
Merged
Changes from 71 commits
Commits
Show all changes
94 commits
Select commit
Hold shift + click to select a range
7c2b950
feat(ci): validate replays for mismatches
Skaronator ad823d1
fix(ci): Move replay files to correct location, adjust exe call
Skaronator 21ea5c1
fix(ci): Make sure to pass -replay to the generalszh.exe
Skaronator 0d1a5e3
Make game compile in VS2019
helmutbuhler 32354e0
Simplify typename hack
helmutbuhler 86668c8
Disable Generalsbuild, reenable VC6
helmutbuhler 51350c3
disable vs22 builds
helmutbuhler 6b3322c
Fix variable in CI
helmutbuhler 48a6696
Add gamedata download to CI
helmutbuhler 2a7b48c
Fix syntax
helmutbuhler 458e0e1
add hack
helmutbuhler f94ba14
more hacks
helmutbuhler 6f99ce5
fix syntax
helmutbuhler 5f7df8f
Add timeout and log output
helmutbuhler 1ca180d
change name and improve log output
helmutbuhler b3e8593
Fix +t+e
helmutbuhler 0b90964
upload log
helmutbuhler a05d139
always List All Files
helmutbuhler d2616eb
move gamedata subfolders
helmutbuhler f98107b
make debug build with opt
helmutbuhler da0ec33
fix order
helmutbuhler 1588493
Update Run Replay Compatibility Tests
helmutbuhler 8b44241
add stdout.log upload
helmutbuhler b8bcfcb
Merge remote-tracking branch 'remotes/hb/VS2019_compat' into ci-replays
helmutbuhler 6ec3210
Disable InsertCDMessage messagebox in headless mode
helmutbuhler e78a948
Update gamedata to include generals data
helmutbuhler cea43aa
Use Current User for registry
helmutbuhler 51d3d55
add registry logging
helmutbuhler b25690e
update slash in path
helmutbuhler 4b34215
fix replay moving and change exitcode detection
helmutbuhler 355c9ed
dummy
helmutbuhler c39b8bb
fix replay path
helmutbuhler 53ab2a5
dummy
helmutbuhler 124be98
add vc6-releaselog config
helmutbuhler 6a83c69
update buildPresets
helmutbuhler d9eeb11
fix gamedata copy
helmutbuhler 6d267dc
Increase timeout
helmutbuhler 57b5d6c
Restructure replays and add maps
helmutbuhler f787c8c
Handle maps in CI
helmutbuhler bdaaad3
Fix move and comments
helmutbuhler 0b09452
comments
helmutbuhler 1ed3877
fix warning and try out jobs
helmutbuhler dc33dc6
Rename ReplayCheck folder to Test
helmutbuhler 74454c4
check crashing mismatch
helmutbuhler 93af880
Delete debug code
helmutbuhler fdd4fe0
Revert "check crashing mismatch"
helmutbuhler dc82800
Remove Hello CI
helmutbuhler f048dc7
Use 2 jobs
helmutbuhler d72f44c
Rename Golden Replay #1.rep
helmutbuhler add354e
Remove hacks
helmutbuhler 9550d2f
3 jobs
helmutbuhler 85f4929
4 jobs
helmutbuhler b4ae422
Rename !Golden Replay #1.rep
helmutbuhler 2cf638e
comment and 5 jobs
helmutbuhler 17ee34a
set jobs and timeout
helmutbuhler a74dcce
put check replays ci stuff into own file
helmutbuhler 1027157
fix name
helmutbuhler 619c80f
adjust timeout and name in build-toolchain
helmutbuhler 0b51d18
enable other buildconfigs again
helmutbuhler f25646d
enable old mismatch for testing
helmutbuhler 3edba8f
fix indent
helmutbuhler 0a253cd
build-generalsmd is split into two jobs for vc6 and win32
helmutbuhler 1a08e85
Revert "enable old mismatch for testing"
helmutbuhler 8e92e58
add comment
helmutbuhler 73f4cf3
Add headless check in Generals
helmutbuhler 9095c5f
remove old code
helmutbuhler 0ef4b05
Remove temp url
helmutbuhler 658a71f
add readme
helmutbuhler 7846e4d
make sure no crash messagebox appears in headless mode
helmutbuhler 41e41ab
Merge branch 'main' of https://github.com/TheSuperHackers/GeneralsGam…
helmutbuhler 481f023
add errormessage if envs are missing
helmutbuhler 08bb4b9
Refactor ignoringAsserts()
helmutbuhler 403c8c4
Use %USERPROFILE% in readme
helmutbuhler 605b936
Mention Generals 1.08 and Generals Zero Hour 1.04 in check-replays.yml
helmutbuhler 4c3591d
Merge branch 'main' of https://github.com/TheSuperHackers/GeneralsGam…
helmutbuhler 61338bb
Replay Check GeneralsMD
helmutbuhler 90ab1ad
Merge remote-tracking branch 'remotes/sh/main' into ci-replays
helmutbuhler 627a2d7
chore(submodule): Add 'GeneralsReplays' submodule
xezon e412623
Delete replays and maps in Code git
helmutbuhler 2c15164
Update S3 filenames
helmutbuhler ca5c6b9
add filename logging
helmutbuhler 0bf0abc
Adjust path for replays
helmutbuhler be6b9f1
Merge branch 'main' of https://github.com/TheSuperHackers/GeneralsGam…
helmutbuhler 1c42f49
Update comment
helmutbuhler a6ca81c
Remove debug logging
helmutbuhler d42d343
Move Test readme
helmutbuhler c39f6bf
Update testing readme
helmutbuhler f0ff46c
Update comment
helmutbuhler 264221c
Use variables for C:\GameData and subfolders
helmutbuhler c378d4b
fix spelling
helmutbuhler f927703
Change logging
helmutbuhler b411250
rename job input gamedata to userdata
helmutbuhler 68e1f8e
Try out envs in job
helmutbuhler a2cb477
Merge branch 'main' of https://github.com/TheSuperHackers/GeneralsGam…
helmutbuhler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,206 @@ | ||
name: check-replays | ||
|
||
permissions: | ||
contents: read | ||
pull-requests: write | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
game: | ||
required: true | ||
type: string | ||
description: "Game to check (only GeneralsMD for now)" | ||
preset: | ||
required: true | ||
type: string | ||
description: "CMake preset" | ||
|
||
jobs: | ||
build: | ||
name: ${{ inputs.preset }} | ||
runs-on: windows-latest | ||
timeout-minutes: 15 | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Download Game Artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ inputs.game }}-${{ inputs.preset }} | ||
path: build | ||
|
||
- name: Cache Game Data | ||
id: cache-gamedata | ||
uses: actions/cache@v4 | ||
with: | ||
path: C:\GameData | ||
key: gamedata-permanent-cache-v2 | ||
|
||
- name: Download Game Data from Cloudflare R2 | ||
if: ${{ steps.cache-gamedata.outputs.cache-hit != 'true' }} | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} | ||
AWS_ENDPOINT_URL: ${{ secrets.R2_ENDPOINT_URL }} | ||
EXPECTED_HASH: "3BE86F84B1E771BEA01BD2DBA39442683381AE4401716E9AE9D4AD95C8F45372" | ||
shell: pwsh | ||
run: | | ||
# Download trimmed gamedata of both ZH and Generals. This data cannot be used for playing because it's | ||
# missing textures, audio and gui files. But it's enough for replay checking. | ||
# It's also encrypted because it's not allowed to distribute these files. | ||
# The archive contains these files: | ||
# Generals\BINKW32.DLL | ||
# Generals\English.big | ||
# Generals\INI.big | ||
# Generals\Maps.big | ||
# Generals\mss32.dll | ||
# Generals\W3D.big | ||
# Generals\Data\Scripts\MultiplayerScripts.scb | ||
# Generals\Data\Scripts\SkirmishScripts.scb | ||
# GeneralsMD\BINKW32.DLL | ||
# GeneralsMD\INIZH.big | ||
# GeneralsMD\MapsZH.big | ||
# GeneralsMD\mss32.dll | ||
# GeneralsMD\W3DZH.big | ||
# GeneralsMD\Data\Scripts\MultiplayerScripts.scb | ||
# GeneralsMD\Data\Scripts\Scripts.ini | ||
# GeneralsMD\Data\Scripts\SkirmishScripts.scb | ||
|
||
if (-not $env:AWS_ACCESS_KEY_ID -or -not $env:AWS_SECRET_ACCESS_KEY -or -not $env:AWS_ENDPOINT_URL) { | ||
$ok1 = [bool]$env:AWS_ACCESS_KEY_ID | ||
$ok2 = [bool]$env:AWS_SECRET_ACCESS_KEY | ||
$ok3 = [bool]$env:AWS_ENDPOINT_URL | ||
Write-Host "One or more required secrets are not set or are empty. R2_ACCESS_KEY_ID: $ok1, R2_SECRET_ACCESS_KEY: $ok2, R2_ENDPOINT_URL: $ok3" | ||
exit 1 | ||
} | ||
Write-Host "Downloading GameData" -ForegroundColor Cyan | ||
aws s3 cp s3://github-ci/gen_gamedata_trimmed.7z gen_gamedata_trimmed.7z --endpoint-url $env:AWS_ENDPOINT_URL | ||
helmutbuhler marked this conversation as resolved.
Show resolved
Hide resolved
helmutbuhler marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Write-Host "Verifying File Integrity" -ForegroundColor Cyan | ||
$fileHash = (Get-FileHash -Path gen_gamedata_trimmed.7z -Algorithm SHA256).Hash | ||
Write-Host "Downloaded file SHA256: $fileHash" | ||
Write-Host "Expected file SHA256: $env:EXPECTED_HASH" | ||
if ($fileHash -ne $env:EXPECTED_HASH) { | ||
Write-Error "Hash verification failed! File may be corrupted or tampered with." | ||
exit 1 | ||
} | ||
|
||
Write-Host "Extracting Archive" -ForegroundColor Cyan | ||
& 7z x gen_gamedata_trimmed.7z -oC:\GameData | ||
Remove-Item gen_gamedata_trimmed.7z -Verbose | ||
|
||
- name: Set Up Game Data | ||
shell: pwsh | ||
run: | | ||
$source = "C:\GameData\${{ inputs.game }}" | ||
$destination = "build" | ||
Copy-Item -Path $source\* -Destination $destination -Recurse -Force | ||
|
||
- name: Set Generals InstallPath in Registry | ||
shell: pwsh | ||
run: | | ||
# Zero Hour loads some Generals files and needs this registry key to find the | ||
# Generals data files. | ||
|
||
$regPath = "HKCU:\SOFTWARE\Electronic Arts\EA Games\Generals" | ||
$installPath = "C:\GameData\Generals\" | ||
helmutbuhler marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Ensure the key exists | ||
if (-not (Test-Path $regPath)) { | ||
New-Item -Path $regPath -Force | Out-Null | ||
} | ||
|
||
# Set the InstallPath value | ||
Set-ItemProperty -Path $regPath -Name InstallPath -Value $installPath -Type String | ||
Write-Host "Registry key set: $regPath -> InstallPath = $installPath" | ||
|
||
- name: Move Replays and Maps to User Dir | ||
shell: pwsh | ||
run: | | ||
# These files are expected in the user dir, so we move them here. | ||
|
||
$source = "${{ inputs.game }}\Test\Replays" | ||
$destination = "$env:USERPROFILE\Documents\Command and Conquer Generals Zero Hour Data\Replays" | ||
Write-Host "Move replays to $destination" | ||
New-Item -ItemType Directory -Path $destination -Force | Out-Null | ||
Move-Item -Path "$source\*" -Destination $destination -Force | ||
|
||
$source = "${{ inputs.game }}\Test\Maps" | ||
$destination = "$env:USERPROFILE\Documents\Command and Conquer Generals Zero Hour Data\Maps" | ||
Write-Host "Move maps to $destination" | ||
New-Item -ItemType Directory -Path $destination -Force | Out-Null | ||
Move-Item -Path "$source\*" -Destination $destination -Force | ||
|
||
- name: Run Replay Compatibility Tests | ||
shell: pwsh | ||
run: | | ||
$exePath = "build/generalszh.exe" | ||
$arguments = "-jobs 4 -headless -replay *.rep" | ||
$timeoutSeconds = 10*60 | ||
$stdoutPath = "stdout.log" | ||
$stderrPath = "stderr.log" | ||
|
||
if (-not (Test-Path $exePath)) { | ||
Write-Host "ERROR: Executable not found at $exePath" | ||
exit 1 | ||
} | ||
|
||
# Note that the game is a gui application. That means we need to redirect console output to a file | ||
# in order to retrieve it. | ||
# Clean previous logs | ||
Remove-Item $stdoutPath, $stderrPath -ErrorAction SilentlyContinue | ||
|
||
# Start the process | ||
Write-Host "Run $exePath $arguments" | ||
$process = Start-Process -FilePath $exePath ` | ||
-ArgumentList $arguments ` | ||
-RedirectStandardOutput $stdoutPath ` | ||
-RedirectStandardError $stderrPath ` | ||
-PassThru | ||
|
||
# Wait with timeout | ||
$exited = $process.WaitForExit($timeoutSeconds * 1000) | ||
|
||
if (-not $exited) { | ||
Write-Host "ERROR: Process still running after $timeoutSeconds seconds. Killing process..." | ||
Stop-Process -Id $process.Id -Force | ||
} | ||
|
||
# Read output | ||
Write-Host "=== STDOUT ===" | ||
Get-Content $stdoutPath | ||
|
||
if ((Test-Path $stderrPath) -and (Get-Item $stderrPath).Length -gt 0) { | ||
Write-Host "`n=== STDERR ===" | ||
Get-Content $stderrPath | ||
} | ||
|
||
if (-not $exited) { | ||
exit 1 | ||
} | ||
|
||
# Check exit code | ||
$exitCode = $process.ExitCode | ||
|
||
# The above doesn't work on all Windows versions. If not, try this: (see https://stackoverflow.com/a/16018287) | ||
#$process.HasExited | Out-Null # Needs to be called for the command below to work correctly | ||
#$exitCode = $process.GetType().GetField('exitCode', 'NonPublic, Instance').GetValue($process) | ||
#Write-Host "exit code $exitCode" | ||
|
||
if ($exitCode -ne 0) { | ||
Write-Host "ERROR: Process failed with exit code $exitCode" | ||
exit $exitCode | ||
} | ||
|
||
Write-Host "Success!" | ||
|
||
- name: Upload Debug Log | ||
if: always() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: Replay-Debug-Log-${{ inputs.preset }} | ||
path: build/DebugLogFile*.txt | ||
retention-days: 30 | ||
if-no-files-found: ignore |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
helmutbuhler marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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
Binary file added
BIN
+159 KB
GeneralsMD/Test/Maps/[RANK] Arctic Arena ZH v1/[RANK] Arctic Arena ZH v1.map
Binary file not shown.
Binary file added
BIN
+64 KB
GeneralsMD/Test/Maps/[RANK] Arctic Arena ZH v1/[RANK] Arctic Arena ZH v1.tga
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.