Skip to content

[GITHUB][ZH] Validate replays for mismatches in CI #1239

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

Closed
wants to merge 3 commits into from

Conversation

Skaronator
Copy link

@Skaronator Skaronator commented Jul 7, 2025

I'm implementing #1201. I cannot test everything in my fork due to missing secrets for R2 in order to install VC6. So please just approve CI workflow here in order for me to finish this work :)


I also have no clue about C++ development so @helmutbuhler could you check how/if your wish was correctly implemented:

I'd also like to see another build configuration added where DEBUG_LOGGING and DEBUG_CRASHING are enabled (but not RTS_DEBUG or RTS_INTERNAL). That configuration should also be checked for compatibility.

@Skaronator Skaronator marked this pull request as draft July 7, 2025 16:24
@Skaronator Skaronator changed the title [ZH] Validate replays for mismatches in CI [GITHUB][ZH] Validate replays for mismatches in CI Jul 7, 2025
@roossienb
Copy link

Doesn't headless only check the $Documents./Command and Conquerer Generals Zero Hour/Replays folder? Such a folder will never be found in CI. This PR may need to be preceded by an option to define an actual path to the replay

@Skaronator
Copy link
Author

I was assuming that this is already the case, but I didn't actually check the source code. I can move the files to the Documents folder, so this isn't blocked.

Any idea why the generalszh.exe doesn't return an exit code? I do this kind of stuff in my day job, but we only have linux stuff. So everything powershell related is mostly AI generated.

@aliendroid1
Copy link

I'm implementing #1201. I cannot test everything in my fork due to missing secrets for R2 in order to install VC6. So please just approve CI workflow here in order for me to finish this work :)

I also have no clue about C++ development so @helmutbuhler could you check how/if your wish was correctly implemented:

I'd also like to see another build configuration added where DEBUG_LOGGING and DEBUG_CRASHING are enabled (but not RTS_DEBUG or RTS_INTERNAL). That configuration should also be checked for compatibility.

You can use cmake gui options to select debug logging etc without rts debug etc. Check pr #931 regarding the vc6 secret stuff

@helmutbuhler
Copy link

Thanks for trying to implement this!

I was assuming that this is already the case, but I didn't actually check the source code. I can move the files to the Documents folder, so this isn't blocked.

Yeah, specifying non-replay folder paths isn't possible right now and not so easy to implement. I was hoping we could just copy the replays in CI into there.

Any idea why the generalszh.exe doesn't return an exit code? I do this kind of stuff in my day job, but we only have linux stuff. So everything powershell related is mostly AI generated.

It probably has to do with generals being a gui application. Those run in background in Windows by default when run from cmd. You can try this:

$rc = (Start-Process ... -Wait -PassThru).ExitCode
if ($rc -ne 0) {
    "Handle accordingly here"
}

(from https://www.reddit.com/r/PowerShell/comments/r1f02u/what_am_i_doing_wrong_here_the_lastexitcode_is/)

@helmutbuhler
Copy link

It would also be nice if the console output was uploaded. ChatGPT suggests something like this:

- name: Run Replay Compatibility Tests
  shell: pwsh
  run: |
    $exePath = "build\generalszh.exe"
    $logPath = "replay_test_output.txt"
    Write-Host "Checking if executable exists at: $exePath"
    if (-not (Test-Path $exePath)) {
        Write-Host "ERROR: Executable not found at $exePath"
        exit 1
    }

    Write-Host "Starting executable and redirecting output to $logPath"
    $startInfo = New-Object System.Diagnostics.ProcessStartInfo
    $startInfo.FileName = $exePath
    $startInfo.Arguments = "-jobs 2 -headless -replay *.rep"
    $startInfo.RedirectStandardOutput = $true
    $startInfo.RedirectStandardError = $true
    $startInfo.UseShellExecute = $false

    $process = New-Object System.Diagnostics.Process
    $process.StartInfo = $startInfo

    $process.Start() | Out-Null

    $stdout = $process.StandardOutput.ReadToEnd()
    $stderr = $process.StandardError.ReadToEnd()

    $process.WaitForExit()
    $exitCode = $process.ExitCode

    $stdout | Out-File -FilePath $logPath -Encoding utf8
    if ($stderr) {
        "`n=== STDERR ===`n" | Out-File -FilePath $logPath -Append -Encoding utf8
        $stderr | Out-File -FilePath $logPath -Append -Encoding utf8
    }

    if ($exitCode -ne 0) {
        Write-Host "Executable failed with exit code $exitCode"
        exit $exitCode
    }
- name: Upload Replay Test Log
  if: always()
  uses: actions/upload-artifact@v4
  with:
    name: Replay-Test-Log-${{ matrix.preset }}
    path: replay_test_output.txt

@helmutbuhler
Copy link

Hm, the Compatibility Test is running for 2 hours now. My guess is it's displaying an error with MessageBox.

Are the game files in the CI environment?

@Skaronator
Copy link
Author

Ah, yes - that could be the reason. I suspect the game files are missing due to copyright issues.

One solution might be to buy Generals using a new Steam account and then run steamcmd within the pipeline to Install the game - but that would be way too slow.

Another option would be to use a self-hosted CI runner. That would also be the fastest CI solution, since we wouldn't need to install the game every time.

And ultimately - though probably not entirely legal - we could either cache the game files in GitHub Actions, or, if we're okay with running the replays in a Linux environment, build a Docker container that includes all the game files.

@helmutbuhler
Copy link

@tintinhamans once mentioned that we can put the gamefiles into an s3 bucket. No idea how that works though...

@aliendroid1
Copy link

aliendroid1 commented Jul 8, 2025

One solution might be to buy Generals using a new Steam account and then run steamcmd within the pipeline to Install the game - but that would be way too slow.

Since we'd be using headless mode, we can cut down on a lot of stuff

  • We don't need bink or any video files because we don't need play videos
  • We don't need miles or any audio files because we won't be using audio
  • We don't need textures because those are purely visual
  • We don't need any of the gui like command bar etc
  • We shouldn't need w3d models but maybe we might need to extract the dimensions from them if those are stored directly in the models.
  • EA already released the maps. We can pull those from here https://github.com/electronicarts/CnC_Modding_Support/tree/main/Zero%20Hour/Maps/official

I think the only thing left is the ini files

@aliendroid1
Copy link

aliendroid1 commented Jul 8, 2025

@helmutbuhler do you think it's possible to make the headless mode work with just the ini files, replay saves, maps, and map scripts?

@aliendroid1
Copy link

It would also be nice if the console output was uploaded. ChatGPT suggests something like this:

- name: Run Replay Compatibility Tests
  shell: pwsh
  run: |
 ....

Maybe try download the ci image or setup something similar to it and run it as a local vm and see if you can stuff to work correctly that way first. Should be a lot faster and easier to debug than waiting for actions to run every time.

@helmutbuhler
Copy link

@helmutbuhler do you think it's possible to make the headless mode work with just the ini files, replay saves, maps, and map scripts?

We probably can easily get rid of the videos and sound files. Other than those it will be difficult. Gamelogic depends on the models (even though it shouldn't). But in my opinion we can just dump all the game files into an encrypted s3 bucket and use it. As long as it's not publicly downloadable we should be fine. That's how the VC6 compiler is currently set up.

@aliendroid1
Copy link

@helmutbuhler do you think it's possible to make the headless mode work with just the ini files, replay saves, maps, and map scripts?

We probably can easily get rid of the videos and sound files. Other than those it will be difficult. Gamelogic depends on the models (even though it shouldn't). But in my opinion we can just dump all the game files into an encrypted s3 bucket and use it. As long as it's not publicly downloadable we should be fine. That's how the VC6 compiler is currently set up.

Yeah except our vc6 compiler is setup is also pretty legally murky. We could replace the models with stripped down versions that don't use any art but are just invisible polygons.

@aliendroid1
Copy link

I got a response from CCHyper/EAHyper regarding ini files and those are redistributable.

We don't even have to remove audio and video file code. We can just replace those with blanks of the and length if needed.

I think we can do something similar with .tga files and just replace them all with blank textures with the same name

We just need to figure out model files and if we can sort those out then I think we should be in the clear

@Mauller
Copy link

Mauller commented Jul 17, 2025

To prevent any issues around the legality of the use of assets, this PR is going to take a lot of non code based work to get it into a workable state.

Model data is used within the pathfinding which is required for the replay to work correctly.
Not all of this data is pre calculated either so will require models with the exact dimensions being created for everything within the game.

Which leads me to think that this PR will not be feasible in a form that allows a common CI option for the project and should be closed.

@helmutbuhler
Copy link

To prevent any issues around the legality of the use of assets, this PR is going to take a lot of non code based work to get it into a workable state.

Model data is used within the pathfinding which is required for the replay to work correctly. Not all of this data is pre calculated either so will require models with the exact dimensions being created for everything within the game.

Which leads me to think that this PR will not be feasible in a form that allows a common CI option for the project and should be closed.

We can put the gamedata into an encrypted S3 bucket. That way distribution is impossible.

@Skaronator
Copy link
Author

I agree that this isn’t easily feasible at the moment, so I’ll go ahead and close this PR.

One thing I’d still like to explore is getting the replay test to run in a Linux environment. That would let me self-host the CI runner on my own hardware without running into legal concerns. It looks like Linux support is still in early stages (see #547 / #486), but I’ll keep an eye on it.

@Skaronator Skaronator closed this Jul 18, 2025
@helmutbuhler
Copy link

The linux build won't be compatible because compatibility depends on VS6 optimizations.
But maybe you can try to make the windows build run with wine, should still be compatible that way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants