Skip to content
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

[WIP] Avoid unnecessary test restarts on PR approval. [DO NOT MERGE] #4598

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

OhmSpectator
Copy link
Member

Added a new check_existing_workflow job to prevent restarting tests if a workflow is already running. This job checks for active test runs and only triggers a new one if no workflow is in progress and the last completed test run failed or was canceled.

Modified get_run_id to depend on
check_existing_workflow.outputs.should_run, ensuring tests only start when needed. This avoids redundant test executions on repeated approvals while still allowing re-runs if previous tests failed.

@rene
Copy link
Contributor

rene commented Feb 7, 2025

@OhmSpectator , AFAIK the GHA it won't run from your PR, unfortunately we need to first merge it to master to actually see if it works... that's why a very careful review is needed....

☝️ @yash-zededa

@OhmSpectator OhmSpectator force-pushed the feature/do-not-restart-test-on-approve branch from 4f22e69 to 9cb8289 Compare February 7, 2025 14:49
@OhmSpectator
Copy link
Member Author

@OhmSpectator , AFAIK the GHA it won't run from your PR, unfortunately we need to first merge it to master to actually see if it works... that's why a very careful review is needed....

☝️ @yash-zededa

I hoped to test it in the scope of this PR, because, to be honest, I'm absolutely unsure about the proposed approach...

@OhmSpectator
Copy link
Member Author

By the way, I've just noticed that the artifacts from the failed Yetus run do not contain real logs with errors =(

It just brings change to a .go file to trigger Eden (we need to test it).

Signed-off-by: Nikolay Martyanov <[email protected]>
@OhmSpectator OhmSpectator force-pushed the feature/do-not-restart-test-on-approve branch from 9cb8289 to 446f2d2 Compare February 7, 2025 14:54
Copy link
Contributor

@rene rene left a comment

Choose a reason for hiding this comment

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

Approving for testing as requested by @OhmSpectator

⚠️ Maintainers: DO NOT MERGE THIS PR YET!

@OhmSpectator OhmSpectator changed the title [WIP] Avoid unnecessary test restarts on PR approval. [WIP] Avoid unnecessary test restarts on PR approval. [DO NOT MERGE] Feb 7, 2025
@OhmSpectator OhmSpectator marked this pull request as ready for review February 7, 2025 15:36
Added a new `check_existing_workflow` job to prevent restarting tests if
a workflow is already running. This job checks for active test runs and
only triggers a new one if no workflow is in progress and the last
completed test run failed or was canceled.

Modified `get_run_id` to depend on
`check_existing_workflow.outputs.should_run`, ensuring tests only start
when needed. This avoids redundant test executions on repeated approvals
while still allowing re-runs if previous tests failed.

Signed-off-by: Nikolay Martyanov <[email protected]>
Turn off check for WF files to prevent tests run

Signed-off-by: Nikolay Martyanov <[email protected]>
@OhmSpectator OhmSpectator force-pushed the feature/do-not-restart-test-on-approve branch from 446f2d2 to 45b602a Compare February 7, 2025 16:10
@deitch
Copy link
Contributor

deitch commented Feb 8, 2025

Did you see that there are changes to domainmgr.go in here?

@deitch
Copy link
Contributor

deitch commented Feb 8, 2025

I think I understand you. The logic now is, "when approved, run the advanced tests". You are saying, "sure, but if you approved, and the tests started, and then I approved, don't restart the tests, they already are running."

Two requests. First, it takes reading the code to understand that logic (and I am sure I didn't understand it). Can we document it, and make it really clear all of the scenarios and when they should run and when not?

Second, if I understood the logic correctly, shouldn't the choice of whether or not approval triggers workflow depend not on failure or not, but instead on whether or not the currently running workflow has the same hash as the current one on approval? Or maybe even just "is anything running"? The concern is that if no workflow is running, and I approve, that shouldn't necessarily trigger a workflow run either; maybe nothing has changed. It really should depend on, "is the hash changed from the last run".

@OhmSpectator
Copy link
Member Author

Two requests. First, it takes reading the code to understand that logic (and I am sure I didn't understand it). Can we document it, and make it really clear all of the scenarios and when they should run and when not?

Yeah, sure. Once I have a verified PoC I will polish the code to make it more understandable. Current PR is more about testing the approach.

Second, if I understood the logic correctly, shouldn't the choice of whether or not approval triggers workflow depend not on failure or not, but instead on whether or not the currently running workflow has the same hash as the current one on approval? Or maybe even just "is anything running"? The concern is that if no workflow is running, and I approve, that shouldn't necessarily trigger a workflow run either; maybe nothing has changed. It really should depend on, "is the hash changed from the last run".

Good point. I'll check how to get this info about "if the PR changed".

@yash-zededa
Copy link
Collaborator

@OhmSpectator , AFAIK the GHA it won't run from your PR, unfortunately we need to first merge it to master to actually see if it works... that's why a very careful review is needed....
☝️ @yash-zededa

I hoped to test it in the scope of this PR, because, to be honest, I'm absolutely unsure about the proposed approach...

@rene Yes. With the current WF condition the eden.yml won't be triggered to test these changes. Even if the condition as for false the eden would be triggered only for the PR approved condition which makes it difficult to test.

@yash-zededa
Copy link
Collaborator

Approving the PR to test something.

⚠️ Maintainers: DO NOT MERGE THIS PR YET!

@OhmSpectator
Copy link
Member Author

@yash-zededa, I don't think I'll be working on this PR for the next few days. Feel free to take it over if you'd like.

@yash-zededa
Copy link
Collaborator

@OhmSpectator I will take over and optimize it :)

@OhmSpectator
Copy link
Member Author

@yash-zededa, yeah, sure, thanks a lot!

@OhmSpectator OhmSpectator marked this pull request as draft February 11, 2025 12:26
RUNNING_WORKFLOWS=$(curl -s -L \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/$REPO/actions/runs?head_sha=$PR_SHA&status=in_progress")
Copy link
Contributor

Choose a reason for hiding this comment

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

Does including the PR_SHA mean that if there was an update to the PR it will run? The description doesn't state this which is why I'm asking.

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