Skip to content

Support Actions concurrency syntax #32751

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

Draft
wants to merge 29 commits into
base: main
Choose a base branch
from

Conversation

Zettat123
Copy link
Contributor

@Zettat123 Zettat123 commented Dec 7, 2024

Fix #24769
Fix #32662
Fix #33260

Depends on https://gitea.com/gitea/act/pulls/124

⚠️ BREAKING ⚠️

This PR removes the auto-cancellation feature added by #25716. Users need to manually add concurrency to workflows to control concurrent workflows or jobs.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Dec 7, 2024
@github-actions github-actions bot added modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code modifies/migrations modifies/dependencies labels Dec 7, 2024
@Zettat123 Zettat123 force-pushed the support-actions-concurrency branch from 3551677 to fcf4517 Compare December 10, 2024 08:56
@lunny lunny added this to the 1.24.0 milestone Dec 16, 2024
@Zettat123 Zettat123 force-pushed the support-actions-concurrency branch from 52833e7 to 130f2a2 Compare December 17, 2024 01:49
@Zettat123 Zettat123 force-pushed the support-actions-concurrency branch 3 times, most recently from 461c7c1 to d5168a2 Compare January 6, 2025 06:16
@Zettat123 Zettat123 force-pushed the support-actions-concurrency branch from e038ed2 to f77f266 Compare January 10, 2025 06:00
@Zettat123 Zettat123 changed the title WIP: Support concurrency for Actions WIP: Support Actions concurrency syntax Jan 15, 2025
@Zettat123 Zettat123 force-pushed the support-actions-concurrency branch from ad71599 to 8f5948b Compare January 15, 2025 03:03
@Zettat123

This comment was marked as resolved.

wxiaoguang added a commit that referenced this pull request Jan 15, 2025
)

Move the main logic of `generateTaskContext` and `findTaskNeeds` to the
`services` layer.

This is a part of #32751, since we need the git context and `needs` to
parse the concurrency expressions.

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
@Naxdy
Copy link
Contributor

Naxdy commented Jul 18, 2025

Sounds good. Feel free to ping / DM on discord if you want me to test something, or need something else. I've been running this for a while on my instance already.

@Zettat123
Copy link
Contributor Author

@ChristopherHX Sorry for the late reply, as I was busy with other work last month. Thank you for the improvements and bug fixes to this PR. Please feel free to update the code. I will also check if there are still issues with this PR.

@ChristopherHX
Copy link
Contributor

Hi,

No problem, once we both agree this is finished and can be merged I approve.

Good that you already looked at the cancellation problem.

I still think about if my code removal is correct or not in sense of not only let existing tests pass.

I had another behavior difference
If we do not have cancel in progress

  • GitHub Actions cancells all earlier blocked runs/jobs (only inprogress are kept if cancel-in-progress is false)
  • This PR queues up and runs every Run one by one

Would we want to add a custom boolean to implement both behaviors?

concurrency:
  cancel-pending: true # default true for GitHub Actions Compat, false for current implementation

Would we want to keep the behavior difference and document it?

@Zettat123
Copy link
Contributor Author

I still think about if my code removal is correct or not in sense of not only let existing tests pass.

I think these changes look good. Thanks for simplifying the code.

I had another behavior difference If we do not have cancel in progress

  • GitHub Actions cancells all earlier blocked runs/jobs (only inprogress are kept if cancel-in-progress is false)
  • This PR queues up and runs every Run one by one

Yes. I noticed the behavior difference between GitHub actions and my implementation. I think for now we can use GitHub's logic. And in the future, we can add the cancel-pending option as a new feature. If we agree to this solution, I would like to modify the current logic (or you can push your changes if you have done :) ).

@github-actions github-actions bot added the modifies/api This PR adds API routes or modifies them label Jul 25, 2025
@ChristopherHX
Copy link
Contributor

ChristopherHX commented Jul 25, 2025

In d5f6c44 I have implemented my last TODO that does not require changes to gitea/act.

This now works good for me


My last open discussion point is this one, since this is related to our database structure. The functionality to allow the shorten syntax of concurrency is ok for me to defer.

If we would see the following valid GitHub Action snipped

concurrency: |-
  ${{ fromjson('{
    "group": "somegroup",
    "cancel-in-progress": true
  }') }}
concurrency: |-
  ${{ fromjson(vars.CONCURRENCY_GROUP_OBJ) }}

How do we pass this to Gitea via RawConcurrency?


My current idea would be adding some boilerplate expression so this is transparent for the current implementation e.g. store

where fromjson(vars.CONCURRENCY_GROUP_OBJ) is the original expression

RawGroup: "${{ !fromjson(vars.CONCURRENCY_GROUP_OBJ).group && fromjson(vars.CONCURRENCY_GROUP_OBJ) || fromjson(vars.CONCURRENCY_GROUP_OBJ).group }}"

While this does feel a bit bad, we need to copy paste a lot to make this work without side effects


On the other hand, Could we just store RawConcurrency as json/yaml? Instead of splitting it before evaluation.

EDIT
I prepared a long time ago ee.EvaluateYamlNode(...) for this scenario.

@Zettat123
Copy link
Contributor Author

Zettat123 commented Jul 25, 2025

My last open discussion point is this one, since this is related to our database structure. The functionality to allow the shorten syntax of concurrency is ok for me to defer.

I would prefer the second solution:

On the other hand, Could we just store RawConcurrency as json/yaml? Instead of splitting it before evaluation.

In this way, we only need a RawConcurrency to store the raw content of concurrency and we can remove RawConcurrencyGroup and RawConcurrencyCancel. To support this, should we also improve EvaluateConcurrency to allow it to parse RawConcurrency in different formats?

I prepared a long time ago ee.EvaluateYamlNode(...) for this scenario.

If you have completed the code, please feel free to push your changes.

@ChristopherHX
Copy link
Contributor

ChristopherHX commented Jul 25, 2025

I will look into implementing the second solution.

To support this, should we also improve EvaluateConcurrency to allow it to parse RawConcurrency in different formats?

Yes this is going to be required together with fixing parsing the workflow to support both formats.

Change to act, seems like I can make this merge as soon as possible and this PR does not have to wait

@ChristopherHX
Copy link
Contributor

I am somewhat confused, after my first attempt 796d2c1 to use a single RawConcurrency entry gitea feels to be slow to queue...

I didn't expected such a slowdown via yaml.Marshal and yaml.Unmarshal.

I will revert and test again to check if this is unrelated...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/need 1 This PR needs approval from one additional maintainer to be merged. modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code modifies/migrations pr/breaking Merging this PR means builds will break. Needs a description what exactly breaks, and how to fix it!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

workflow_dispatch allows only one job in a branch [Actions] Opt-out from auto-cancellation [Actions] Support concurrency syntax
8 participants