Skip to content

PR test runner - #4140

Closed
saurtron wants to merge 16 commits into
beyond-all-reason:masterfrom
saurtron:pr-test-runner
Closed

PR test runner#4140
saurtron wants to merge 16 commits into
beyond-all-reason:masterfrom
saurtron:pr-test-runner

Conversation

@saurtron

@saurtron saurtron commented Jan 8, 2025

Copy link
Copy Markdown
Collaborator

Work done

  • base github actions and tooling by @salinecitrine
  • mocha reporting:
    • shows success, failed, skipped tests.
  • workflows:
    • make the deploy jobs depend on successful tests.
    • at request of @p2004a joined everything into one workflow file.
      • has three internal stages: run_test, process_test, deploy
  • add a special test scanning infolog.txt for errors.
  • update to run on Supreme Isthmus v1.8

More details

for convenience, from #2626:

This uses https://github.com/EnricoMi/publish-unit-test-result-action to publish test results for PRs, including forks. It uses roughly the setup described here to do so. This means there is an action that runs on the PR branch that runs the tests, and an action that runs on the master branch that publishes the results.

Remarks

  • This is the result on an epic journey by @salinecitrine, he created the test runner, created the github actions. An incredible amount of work, so would like to thank him and send ❤️.
  • The test runner shows a bot comment like this at PRs, this can be a bit verbose and could get old fast. It can be disabled.
  • Does release deploy only if the tests pass, so once this is in can't deploy automatically if the tests fail.
    • Seems there's a secondary publish method running on cron somewhere, so if we want to use only deploy if tests work will need to avoid using that, unless there's a situation that requires it.
    • Should be best... but ninja commits (without PR and previous checking of tests working) can be bad.
  • To block merging when the checks don't pass, I believe this needs to be configured at github project.
  • The infolog.txt test goes further than normal tests, since it scans any infolog.txt occurring during running of tests and initialization. It should catch weird situations.
  • Due to the (current) headless nature of tests, they can fail in situations where normally code wouldn't fail.
    • For widgets and gadgets hard requiring opengl, best is to add depends: {"gl"} at info
    • Others will benefit from clear separation of draw and logic so tests can be run even when drawing part isn't working
    • Maybe later we find a way to run headless but without the headless engine, that would allow more things to work fine and be tested automatically.

@saurtron
saurtron requested a review from p2004a January 8, 2025 18:45
@saurtron

saurtron commented Jan 8, 2025

Copy link
Copy Markdown
Collaborator Author

Ok looks like need to address https://github.com/EnricoMi/publish-unit-test-result-action/blob/v2.18.0/README.md#support-fork-repositories-and-dependabot-branches before the tests will run on PRs from separate repos. Will check this soon.

Anyways can use review already.

@saurtron
saurtron marked this pull request as draft January 8, 2025 18:53
@salinecitrine

salinecitrine commented Jan 8, 2025

Copy link
Copy Markdown
Collaborator

Ok looks like need to address https://github.com/EnricoMi/publish-unit-test-result-action/blob/v2.18.0/README.md#support-fork-repositories-and-dependabot-branches before the tests will run on PRs from separate repos. Will check this soon.

Anyways can use review already.

Haven't had much of a chance to review things (sorry!), but FYI the previous PR (#2626) was set up to handle fork PRs as described in that link. Could probably steal the setup from there at least as inspiration.

@saurtron

saurtron commented Jan 8, 2025

Copy link
Copy Markdown
Collaborator Author

Haven't had much of a chance to review things (sorry!), but FYI the previous PR (#2626) was set up to handle fork PRs as described in that link. Could probably steal the setup from there at least as inspiration.

Yeah I totally based on that one, I think I removed smth related when merging workflows into one file tho. Thx for the tip!

@saurtron

saurtron commented Jan 8, 2025

Copy link
Copy Markdown
Collaborator Author

Could probably steal the setup from there at least as inspiration.

Ok I think it's working now but the secondary workflows need to be in master for them to work. Difficult to tell tbh XD. I did try at saurtron#9 and still seems to work.

Anyways I'll still tweak a bit since some things need to be changed when in 2 files and not sure everything is tuned right now. I tried before with 3 separate workflows (like yours + deploy), also with 2, so I'll review.

@p2004a

p2004a commented Jan 8, 2025

Copy link
Copy Markdown
Collaborator

I removed smth related when merging workflows into one file tho

bd43a2e, 139 more lines to read and maintain. Why?

@saurtron

saurtron commented Jan 8, 2025

Copy link
Copy Markdown
Collaborator Author

bd43a2e, 139 more lines to read and maintain. Why?

Seems we overlooked this: https://github.com/EnricoMi/publish-unit-test-result-action/blob/v2.18.0/README.md#support-fork-repositories-and-dependabot-branches

Its just ~40 lines more btw, anyways doesn't seem to be much we can do about it, can't fix without some extra lines, sorry.

@saurtron

saurtron commented Jan 9, 2025

Copy link
Copy Markdown
Collaborator Author

bd43a2e, 139 more lines to read and maintain. Why?

A bit more background, after having checked the issue, that required those changes:

This seems to be a security mechanism to avoid getting hacked through github actions, check this: https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/.

These parts are the most interesting:

"Since, by definition, a PR supplies code to any build or test logic in place for your project, attackers can achieve arbitrary code execution in a workflow runner operating on a malicious PR in a variety of ways."

"Due to the dangers inherent to automatic processing of PRs, GitHub’s standard pull_request workflow trigger by default prevents write permissions and secrets access to the target repository."

@saurtron

saurtron commented Jan 9, 2025

Copy link
Copy Markdown
Collaborator Author

This seems to be a security mechanism

Also, having read all that, I'd say the original three workflow way would be the most secure in order to avoid getting hacked by https://github.com/EnricoMi/publish-unit-test-result-action itself, although we could avoid that by having a private copy of that, or pinning some specific commit maybe. Not totally sure though, would have to read more about the permissions... also I think disabling comments for that action makes it not require write access to the repo.

Comment thread .github/workflows/run_tests.yml Outdated
@S3KCentrifugal

Copy link
Copy Markdown
Contributor

To keep code pretty, maybe add a linter? (I didn't see one being used)
https://github.com/marketplace/actions/luacheck

Just found this action available, but I am sure there are others.

@oopsbagel

oopsbagel commented Mar 6, 2025

Copy link
Copy Markdown
Contributor

To keep code pretty, maybe add a linter? (I didn't see one being used) https://github.com/marketplace/actions/luacheck

Just found this action available, but I am sure there are others.

If you're going to add a lua linter, I'm personally fond of selene, a more active project -- there's also a github action.

@p2004a

p2004a commented Apr 6, 2025

Copy link
Copy Markdown
Collaborator

@saurtron what is the status of this? It's still in draft mode

@saurtron

saurtron commented Apr 6, 2025

Copy link
Copy Markdown
Collaborator Author

@saurtron what is the status of this? It's still in draft mode

I think I'm going to split the run_tests_and_deploy (note: already did it, check below comment) out for now, so quick_deploy won't depend on tests for now, I'll also check all tests still pass properly.

Then I will make an additional PR joining them again, to apply when we're sure it's not going to be disruptive. I think it's more sensible than trying to do everything in one go. It's great having tests blocking merge, or deploy if something broken is commited, but doesn't need to go all in in one go.

Let me know if you don't like this approach, and give me 1-2 days and I'll prepare it so it can be merged already.

@saurtron

saurtron commented Apr 6, 2025

Copy link
Copy Markdown
Collaborator Author

Let me know if you don't like this approach, and give me 1-2 days and I'll prepare it so it can be merged already.

Ok, did it already, also created #4737 as "part 2" so in the end is the same we had before and already reviewed.

Now I need to check some master test failures on headless before this can be merged (ie, to remove the DRAFT status).

@saurtron

saurtron commented Apr 7, 2025

Copy link
Copy Markdown
Collaborator Author

@p2004a p2004a left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Let's merge after those are fixed and see how it behaves.

@saurtron
saurtron force-pushed the pr-test-runner branch 2 times, most recently from 4643179 to b3c7787 Compare April 15, 2025 16:35
@saurtron
saurtron marked this pull request as ready for review April 15, 2025 17:00
@saurtron

saurtron commented Apr 15, 2025

Copy link
Copy Markdown
Collaborator Author

Ok, the mentioned changes are in, so this is ready for final review.

I have it merged at my repo's master, so if you want to see it work I think you can PR there. (probably a good idea so we see it works with external PR)

I did a PR myself to myself, with the cmd-extension-mechanism as an example. saurtron#15 (you can see the test results there)

@WatchTheFort

Copy link
Copy Markdown
Member

Does this supersede #2626? Should #2626 be closed in favour of this one?

@saurtron

Copy link
Copy Markdown
Collaborator Author

Does this supersede #2626? Should #2626 be closed in favour of this one?

yeah I think it can be closed, its built on his with some changes and then a follow up PR #4737 for when/if we want to make deploy depend on successful tests

@p2004a

p2004a commented Apr 25, 2025

Copy link
Copy Markdown
Collaborator

@saurtron per saurtron#16 looks like some test is currently failing on master.

Also can you explain the pending tests? Why pending is not failing?

@WatchTheFort

Copy link
Copy Markdown
Member

@saurtron What is the status of this? Is it ready to merge?

@saurtron

saurtron commented Jun 26, 2025

Copy link
Copy Markdown
Collaborator Author

@saurtron What is the status of this? Is it ready to merge?

Need to wait until engine 2025.04.10+ before testrunner is usable since they don't work with 2025.04.08/09 due to too strict lua security policy.

After that will have to review and fix any current errors in master again. Sorry about that, its just merging this requires tests to be passing at the time and its kind of a moving target for now.

Anyways looking close when the bar engine is updated to current latest stable 2025.04.10 or more recent.

@NortySpock

Copy link
Copy Markdown
Contributor

@saurtron Looks like http://github.com/beyond-all-reason/Beyond-All-Reason/pull/5702 merged recently... does that unblock this PR?

(Call it heresy if you will, but would commenting out most of the tests help accelerate the process, and then a follow-on PR performs the test fixes, post-merge?)

(Just curious because I feel automated CI testing would be nice to see in this project.)

@WatchTheFort

WatchTheFort commented Aug 28, 2025

Copy link
Copy Markdown
Member

Does this PR supersede #2626? Both PRs add the same set of Github action files.

@p2004a

p2004a commented Aug 31, 2025

Copy link
Copy Markdown
Collaborator

Anyways looking close when the bar engine is updated to current latest stable 2025.04.10 or more recent.

That precondition did not happen, bar is still on engine 2025.04.08.

@p2004a

p2004a commented Aug 31, 2025

Copy link
Copy Markdown
Collaborator

Does this PR supersede #2626? Both PRs add the same set of Github action files.

First line of this PR:

based on previous PR by salinecitrine. see there for further info and discussion

@NortySpock NortySpock mentioned this pull request Sep 9, 2025
1 task
WatchTheFort pushed a commit that referenced this pull request Oct 30, 2025
- rebased  PR #4140 on master
- removed a test for air repair pads
- skipped two tests that were failing (hope that's ok so that progress can be made on getting CICD working)
- In theory this should run tests in GitHub Actions (we'll see if it still works)
- Sets tests to run on the "manual-linux-test-engine" engine from the release config.json
  - recoil_2025.06.06
- ...which still seems old relative to master... are there newer releases we should be targeting? Or is "manual-linux-test-engine" always going to be the correct one to target?
@NortySpock

Copy link
Copy Markdown
Contributor

Recommend closing this PR as the now-merged #5874 (which is just a rebase of this PR with some tests skipped) covers this functionality.

Thanks for all the hard work you put in getting this PR working @saurtron . I stand upon the shoulders of a giant.

Xehrath pushed a commit to Xehrath/Beyond-All-Reason that referenced this pull request Jan 31, 2026
- rebased  PR beyond-all-reason#4140 on master
- removed a test for air repair pads
- skipped two tests that were failing (hope that's ok so that progress can be made on getting CICD working)
- In theory this should run tests in GitHub Actions (we'll see if it still works)
- Sets tests to run on the "manual-linux-test-engine" engine from the release config.json
  - recoil_2025.06.06
- ...which still seems old relative to master... are there newer releases we should be targeting? Or is "manual-linux-test-engine" always going to be the correct one to target?
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.

7 participants