enable forgejo-runner validate to run on files in repository without cloning it #51

Closed
opened 2025-09-16 15:37:11 +00:00 by Freso · 5 comments

How to use this feature request

  • Please describe your first hand experience in a comment to show why you are interested into the same feature.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

First hand experience

  • I’m trying to add a pre-commit hook for forgejo-runner.
  • During testing (and implementing automated testing), I’ve realised that there isn’t a good way to validate files in a repository that haven’t yet been committed.
  • forgejo-runner validate --repository makes a clone of the repository and validates that, which obviously doesn’t include not-yet-committed files or changes to files
  • forgejo-runner validate --path
    1. only takes one file at a time
    2. requires you to know in advance whether this file is an action or a workflow file

Needs and benefits

Not being able to test the uncommitted status of a repository without specifying individual files by hand makes it hard to implement a pre-commit hook (or even manually make a git or other VCS pre-commit hook) since we’d want to test it before it enters the repository, not after.

Feature Description

A flag (--local?) to validate ^(\.(forgejo|github|gitea)/workflows/[^/]+|action)\.ya?ml$ files in the current directory, regardless of whether they’ve been committed or not, and without having to specify each file.

Alternatively(/additionally?), let --path take multiple arguments and let it decide whether to validate as action or workflow files based on their paths/filenames (if --action or --workflow is not explicitly given).

What needs to happen before a feature request is ready to be implemented?

Users can complete the first step (accumulating first and experience) on their own, even if this feature request did not catch the eye of someone with the necessary skills to implement it. And when it reaches that point, it will stand out and have a much higher chance of being implemented.

  1. A few other users contributed their own first hand experience.
    To fully grasp the scope of a feature request, and to brainstorm possible solutions, a feature request will generally wait until several users have provided their perspective.
    Thumbs-up reactions help gauge popularity, but do not provide the same amount of useful information.
  2. The "Needs and benefit" and "Feature description" are finalized.
    Results from discussions and additional user experiences are incorporated into a final summary to provide a single reference for the developers working on this change.
    This can be done by the author of the issue or anyone else in a followup comment.
  3. The label Stage/Idea is changed to Stage/Ready.
  4. Feature request is created in the repository where the code resides.
    Depending on the feature request it can be in Forgejo, Forgejo runner or Forgejo ACT.
    A copy/paste of the "Needs and benefit" and "Feature description" should be used, with link to this issue so the developer knows where to find more details if they need to.
### How to use this feature request * Please describe your first hand experience in a comment to show why you are interested into the same feature. * Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue. * Subscribe to receive notifications on status change and new comments. ### First hand experience - I’m [trying to add a `pre-commit` hook for `forgejo-runner`](https://code.forgejo.org/forgejo/runner/pulls/1002). - During testing (and implementing automated testing), I’ve realised that there isn’t a good way to validate files in a repository that haven’t yet been committed. - `forgejo-runner validate --repository` makes a clone of the repository and validates that, which obviously doesn’t include not-yet-committed files or changes to files - `forgejo-runner validate --path` 1. only takes one file at a time 2. requires you to know in advance whether this file is an action or a workflow file ### Needs and benefits Not being able to test the uncommitted status of a repository without specifying individual files by hand makes it hard to implement a `pre-commit` hook (or even manually make a git or other VCS pre-commit hook) since we’d want to test it before it enters the repository, not after. ### Feature Description A flag (`--local`?) to validate `^(\.(forgejo|github|gitea)/workflows/[^/]+|action)\.ya?ml$` files in the current directory, regardless of whether they’ve been committed or not, and without having to specify each file. Alternatively(/additionally?), let `--path` take multiple arguments and let it decide whether to validate as action or workflow files based on their paths/filenames (if `--action` or `--workflow` is not explicitly given). ### What needs to happen before a feature request is ready to be implemented? Users can complete the first step (accumulating first and experience) on their own, even if this feature request did not catch the eye of someone with the necessary skills to implement it. And when it reaches that point, it will stand out and have a much higher chance of being implemented. 1. **A few other users contributed their own first hand experience.** To fully grasp the scope of a feature request, and to brainstorm possible solutions, a feature request will generally wait until several users have provided their perspective. Thumbs-up reactions help gauge popularity, but do not provide the same amount of useful information. 1. **The "Needs and benefit" and "Feature description" are finalized.** Results from discussions and additional user experiences are incorporated into a final summary to provide a single reference for the developers working on this change. This can be done by the author of the issue or anyone else in a followup comment. 1. **The label `Stage/Idea` is changed to `Stage/Ready`.** 1. **Feature request is created in the repository where the code resides.** Depending on the feature request it can be in [Forgejo](https://codeberg.org/forgejo/forgejo/issues/new?template=.forgejo%2fissue_template%2ffeature-request.yaml), [Forgejo runner](https://code.forgejo.org/forgejo/runner/issues/new?template=.forgejo%2fissue_template%2ffeature-request.yaml) or [Forgejo ACT](https://code.forgejo.org/forgejo/act/issues/new). A copy/paste of the "Needs and benefit" and "Feature description" should be used, with link to this issue so the developer knows where to find more details if they need to.

This is a compelling use case.

This is a compelling use case.

I think the --clonedir option does what you need.

$ forgejo-runner-11.0.0 validate --clonedir . --repository .
.forgejo/workflows/build.yml workflow schema validation OK
.forgejo/workflows/sync.yml workflow schema validation OK
.forgejo/workflows/test.yml workflow schema validation OK
I think the `--clonedir` option does what you need. ```sh $ forgejo-runner-11.0.0 validate --clonedir . --repository . .forgejo/workflows/build.yml workflow schema validation OK .forgejo/workflows/sync.yml workflow schema validation OK .forgejo/workflows/test.yml workflow schema validation OK ```
Author

That does indeed seem to work! But it feels quite hacky. 😆

But at least it unblocks forgejo/runner#1002 and lets me return to that. 🫡

That does indeed seem to work! But it feels quite hacky. 😆 But at least it unblocks https://code.forgejo.org/forgejo/runner/pulls/1002 and lets me return to that. 🫡

That does indeed seem to work! But it feels quite hacky. 😆

Agreed. When diving in the implementation it is actually straightforward but it feels hacky from the CLI. The solution would be to never clone when it is a directory. But then it would require writing tests using URLs for the sake of getting coverage and this is a little more work.

> That does indeed seem to work! But it feels quite hacky. 😆 Agreed. When diving in the implementation it is actually straightforward but it feels hacky from the CLI. The solution would be to never clone when it is a directory. But then it would require writing tests using URLs for the sake of getting coverage and this is a little more work.

Feel free to convert this feature request into doing that. Or close it. It is a border case that probably does not deserve the effort. But it may just me being lazy.

Feel free to convert this feature request into doing that. Or close it. It is a border case that probably does not deserve the effort. But it may just me being lazy.
Sign in to join this conversation.
No labels
Stage
Idea
Stage
Ready
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
forgejo/forgejo-actions-feature-requests#51
No description provided.