GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||
GeezerVison is showing github.com — fixed #12325 - cancel workflows if a newer commit is pushed on the same branch by kitsiosk · Pull Request #7636 · cppcheck-opensource/cppcheck Conversation
Contributor
Change SummaryCurrently, if a push to The introduced syntax comes from the official documentation. ContextHi, We are a team of researchers from University of Zurich and we are currently working on energy optimizations in Github Actions workflows. Based on our offline analysis, cancelling CodeQL runs triggered by a now-obsolete commit (because a new commit has triggered the CodeQL workflow again), could have saved ~49.9 CPU hours since the beginning of the project. For example, the commit 70b1f triggered this workflow run, and one minute later the commit ea2c3, that happened on top of the first commit, triggered this workflow. Both workflows ran till the end, spending ~12 CPU minutes each. With the proposed changes, the first run would be cancelled, hence saving ~11 CPU minutes and clearing the queue for other workflows. Kindly let us know (here or in the email below) if you would like more details on our offline evaluation, if you want to reject the proposed changes for other reasons, or if you have any question whatsoever. Best regards,
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Collaborator
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Collaborator
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
|
There was an error while loading. Please reload this page.
|
Thanks for working on this. I envision that this could mean that fewer pipelines will be queued and that you will get the CI result a little faster for your latest push. That is good!
I also agree with @firewave. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
This is interesting and makes sense.
Exactly! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I found my old changes and I think the problem I was facing was finding a solution to generate groups which work with pushes and PRs which you did solve with I was not aware that strings could be used in concatenation code - looking at it I would have assume that the expression would resolve to And I also did not think about just leveraging Regrading some question I had about this back then - can you confirm the the groups are just enforced across repos/forks and not globally? Otherwise the group needs to add I will also do some tests later on to see if it behaves as expected. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
I confirm; workflows in this repo's I have just pushed the improved version, let me know if I can do anything else. For example, I could add it to all workflows that trigger on PR if you wish. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
That would be great. But let me run some tests first. Will do later today. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Another point is that we do not require PRs to be at HEAD to be merged. So even though no merge conflicts are shown the changes from various PRs might not be compatible with each other. That's why we also need to do the workflows for the Also a note on why we filter the workflow. We had the problem that when you create a PR from a branch in the same repo you want to merge it into the builds would run twice. Once for the PR and once for the push to the branch. This is making it harder to test changes before you open a PR even if you are not working on the repo the PR will merge into. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Oh, I see, that makes sense!
Right, we were also thinking about this problem and how to propose an optimization to overcome it, but we couldn't come up with something that can be applied automatically to an arbitrary yaml file. What you have done here seems to work great. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry for not testing the changes yet, but something else came up.
Except for the shortcoming. And I am not too happy about it since i affects all forks. But so far "it works". An optimizations we also implemented is using |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Okay, I gave it a spin. This prevents the workflows from running more than once on But that really doesn't matter because in our case the concurrency should not be applied when in the non-PR case at all (I have the feeling that this is what I was actually hitting on back then). I wonder if an empty |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
We can make this work this by making the concurrency a unique ID for the non-PR case: concurrency: group: ${{ github.event_name }}-${{ github.workflow }}-${{ github.head_ref || github.sha }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} # this will cancel only PRs |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
In that case we might not even need the conditional value for |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Oh no - that is all wrong (it's too warm). That is not set for PRs. It should be: concurrency: group: ${{ github.event_name }}-${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} # this will cancel only PRs |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
This will have the same effect with the changes in this PR, under the condition that from a single branch, only one PR can be opened. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
echo "${{ github.event_name }}-${{ github.workflow }}-${{ github.head_ref }}" echo "${{ github.event_name }}-${{ github.workflow }}-${{ github.ref }}" echo "${{ github.event_name }}-${{ github.workflow }}-${{ github.sha }}" echo "${{ github.event_name }}-${{ github.workflow }}-${{ github.event.pull_request.number }}" main (push) branch (push) branch (pull_request) I cannot think right now - it is just too warm ... |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
:D Thanks for the echo results. I will also have another look and try to prepare a couple of illustrative examples. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
In the meantime, you may also have a look at this one: #7641 The change is much simpler, we would be curious to see what you think of the idea. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
I had another look in this, and I think your suggestion is better. It also works in the case where from branch In your poposal, the Given that, I could apply your proposal if you wish. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Will have another look later today.
I think this is impossible in GitHub and there is a 1-to-1 relation between branches and PRs. A look at https://github.com/danmar/cppcheck/branches seems to support that. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
That is very interesting. That should not affect our main repo but might forks. Bot something I think we should consider for this repo. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Signed-off-by: Konstantinos <[email protected]>
Signed-off-by: Konstantinos <[email protected]>
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hi @danmar, I see that nothing changed in the CI/CD file recently, so I believe the change proposed in this PR is still useful and can be merged. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@firewave can you please make the decision on this one? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.