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

Migrate to actionlint #33074

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

Conversation

TheFox0x7
Copy link
Contributor

Move from jobparser to actionlint as base for job processing


Both PR and description are very WIP.

For now it did three things:

  1. Include jobparser code in tree so I have easier time changing it (I can't find any reason as to why it shouldn't be here anyway)
  2. Swap Event detection function to be use actionlint
  3. Use actionlint to check syntax in webui (still needs work as it looks bad)

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jan 1, 2025
@pull-request-size pull-request-size bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jan 1, 2025
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Jan 1, 2025
@TheFox0x7
Copy link
Contributor Author

@Zettat123 @wolfogre Seeing as you are working on actions, could you take a look at this before I mess with this further?

webui check look like this for reference:
image

@lunny
Copy link
Member

lunny commented Jan 1, 2025

Once we introduce actinlint, we need to introduce it in act_runner and drop the act's parser at the same time.

@wolfogre
Copy link
Member

wolfogre commented Jan 2, 2025

@TheFox0x7 Thank you for your attempts in this direction. However, I may not have the time to provide detailed assistance recently due to personal reasons. Here are my simple thoughts on this (please understand that I haven't investigated in depth, so it may not be accurate):

  • Under the current situation, are there enough pain points that make migrating to actionlint worthwhile? This requires an issue description.
  • Is migrating to actionlint feasible, and is the adaptation work acceptable? Because actionlint is designed for GitHub Actions, and the syntax of Gitea Actions has slight differences, for example, uses: https://gitea.com/a/b is not valid for GitHub Actions.
  • How should the functional modules be divided? Is actionlint only responsible for the validation of YAML files, or will it also be responsible for job parsing? If it is the latter, then as Lunny said, the act_runner's job parsing work should be updated synchronously. How should this be handled? Should act_runner introduce Gitea as an external package?
  • Is there a better way? For example, I guess having act introduce actionlint is the most intuitive direction, as both Gitea and act_runner will depend on act.

@TheFox0x7
Copy link
Contributor Author

First of all, no worries. I mainly started this because I already worked on this and actions before, which made me think that taking this system was a mistake - but it's too late to reverse this and I don't want that work to go to waste. Worst case I'll close this and it might be useful to someone later.


Under the current situation, are there enough pain points that make migrating to actionlint worthwhile? This requires an issue description.

Yes and no. Having actionlint as at least a validation layer, would give end user better errors and safeguard jobparser from bad yamls, plus access to permissions and concurrency fields. On the other hand, I did try to fully port gitea to actionlint before and there are some things which actionlint is just bad at for this use:

  1. No marshaling into a regular yaml (this is a large issue)
  2. on field has to always be processed and the same with steps (this is mainly annoyance as I can't do the thing jobparser does not and copy entire node which I don't need to touch)

So I don't think dropping act parser or jobparser is doable for now.

Is migrating to actionlint feasible, and is the adaptation work acceptable? Because actionlint is designed for GitHub Actions, and the syntax of Gitea Actions has slight differences, for example, uses: https://gitea.com/a/b is not valid for GitHub Actions.

Unless we explicitly add validation runs after parsing none of the additional rules will trigger - only syntax-check. So actions rule won't flag the uses url as it won't be ran. There are no syntax differences that would make this a bad idea and introducing them would mean breaking compatibility with github.

How should the functional modules be divided? Is actionlint only responsible for the validation of YAML files, or will it also be responsible for job parsing? If it is the latter, then as Lunny said, the act_runner's job parsing work should be updated synchronously. How should this be handled? Should act_runner introduce Gitea as an external package?

act_runner as far as I saw, doesn't use jobparser module at all. I did try to make actionlint do job processing and... yeah that turned into spaghetti fast. It is doable but far from fun and there would still be expression parser required.
Act_runner doesn't need any of Gitea job code as it gets regular workflows that act can run last time I looked. If anything I really don't see why jobparser is out of main tree in the first place so even pulling it in can be an improvement.

Is there a better way? For example, I guess having act introduce actionlint is the most intuitive direction, as both Gitea and act_runner will depend on act.

act already pulls actionlint as dependency and I guess here are/were some plans to use it for validation as per comment:

// BUTx2 I leave this for when we rewrite act to use actionlint for workflow validation
// so we return proper errors before any execution or spawning containers

in pkg/runner/step_run.go. But touching act is outside of my area of expertise as I get lost in that codebase very fast and don't use it in general.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/dependencies modifies/go Pull requests that update Go code size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants