feat: use git work trees for remote git actions & workflows #1162

Merged
mfenniak merged 6 commits from mfenniak/forgejo-runner:feat-worktrees into main 2025-11-21 13:49:27 +00:00
Owner

Breaking: forgejo-runner now requires access to git on its PATH in order to create efficient work trees for execution of remote git actions or workflows, such as uses: actions/checkout.


When you use a remote step action or a remote composite action, forgejo-runner will perform a clone of the remote repo into a temporary directory. For steps, the temporary directory will be named with a SHA of the uses: ... step text; for reusable workflows, it will be named with a combination of remote org,repo@ref. These are stored in ~/.cache/act (or the workflow_parent, if overridden in the config file).

This design has these problems:

  • Whenever the contents of uses: ... changes, an independent clone is performed as it causes a different unique directory name. For example, when changing from uses: actions/checkout@v4 to ...v5, the existing cached repo that contains v4 is not reused in any way; a new cache is made for @v5.
  • The contents of the temp directories are somewhat cleaned up by a git reset --HARD between uses, but non-tracked files could be left in the directory between runs polluting from one run to another; there's no git clean -fxd performed.
  • The directory could be used concurrently by multiple running actions. If the git reference changes (eg. it is a reference to a tag, and it has changed in the second run), or if the workflow writes any content to the directory, it will pollute across action runs.
  • Probably due to bugs identified in the past with performing operations on these shared repo directories, only a single clone operation can be performed by forgejo-runner at once:
    • A mutex is used that permits a forgejo-runner to only clone one repo at a time --
      cloneLock sync.Mutex
    • A redundant mutex is used during reusable workflow clones to permit only one clone at a time --
      var executorLock sync.Mutex
      func newMutexExecutor(executor common.Executor) common.Executor {
      return func(ctx context.Context) error {
      executorLock.Lock()
      defer executorLock.Unlock()
      return executor(ctx)
      }
      }
  • (Not resolved in this PR): All remote references are pulled during git clone of a remote, even if they aren't relevant to the reference being fetched. (To be fixed in the future based upon this change.)

To address these issues, this PR proposes this design update:

  • Based upon the remote URL without the reference, a single bare clone repo will be maintained.
  • When a reference is to a branch, tag, or unidentified sha, a fetch will be performed on the bare repo to get the current sha for the reference.
  • For each execution using the repo, a new independent work tree will be created from the bare repo.
  • The work trees will be cleaned up at the end of execution; the bare repo will remain to be reused.
  • Concurrency control will be handed over to git, since it is capable of managing multiple fetches and work tree creations from a single bare repo transitioned to a finer grained MutexMap, allowing higher concurrency but not taking any risks of go-git's unclear concurrency guarantees.

This will address the problems described above. It does have a negative side-effect -- each running remote action will require creating a new work tree, increasing on-disk I/O where previously these might have been in-place already. However, this is a trade-off against reducing total disk I/O and usage by sharing a single repo over multiple references to that repo; so long-term usage will likely be lower.

WIP: the core work is done and ready to be put through the test battery to see if any unexpected problems occur, which is why I opened this PR. TODO:

  • Update the original repo to be a bare repo
  • Cleanup work trees after they are Close()'d
  • Seems like reference is slipping into the filepaths in ~/.cache/act currently -- should be stripped
  • Pass through each commits to identify any needed automated testing revisions
  • Get all automated tests to pass
  • Perform manual testing as needed
  • features
    • PR: feat: use git work trees for remote git actions & workflows
**Breaking:** forgejo-runner now requires access to `git` on its PATH in order to create efficient work trees for execution of remote git actions or workflows, such as `uses: actions/checkout`. --- When you use a remote step action or a remote composite action, forgejo-runner will perform a clone of the remote repo into a temporary directory. For steps, the temporary directory will be named with a SHA of the `uses: ...` step text; for reusable workflows, it will be named with a combination of remote org,repo@ref. These are stored in `~/.cache/act` (or the `workflow_parent`, if overridden in the config file). This design has these problems: - Whenever the contents of `uses: ...` changes, an independent clone is performed as it causes a different unique directory name. For example, when changing from `uses: actions/checkout@v4` to `...v5`, the existing cached repo that contains `v4` is not reused in any way; a new cache is made for `@v5`. - The contents of the temp directories are somewhat cleaned up by a `git reset --HARD` between uses, but non-tracked files could be left in the directory between runs polluting from one run to another; there's no `git clean -fxd` performed. - The directory could be used concurrently by multiple running actions. If the git reference changes (eg. it is a reference to a tag, and it has changed in the second run), or if the workflow writes any content to the directory, it will pollute across action runs. - Probably due to bugs identified in the past with performing operations on these shared repo directories, only a single clone operation can be performed by `forgejo-runner` at once: - A mutex is used that permits a forgejo-runner to only clone one repo at a time -- https://code.forgejo.org/forgejo/runner/src/commit/c1fe7a26a342ebb5ea0fbe4ef1ed75369cd6ac01/act/common/git/git.go#L30 - A redundant mutex is used during reusable workflow clones to permit only one clone at a time -- https://code.forgejo.org/forgejo/runner/src/commit/c1fe7a26a342ebb5ea0fbe4ef1ed75369cd6ac01/act/runner/reusable_workflow.go#L87-L96 - **(Not resolved in this PR)**: All remote references are pulled during `git clone` of a remote, even if they aren't relevant to the reference being fetched. (To be fixed in the future based upon this change.) To address these issues, this PR proposes this design update: - Based upon the remote URL without the reference, a single bare clone repo will be maintained. - When a reference is to a branch, tag, or unidentified sha, a fetch will be performed on the bare repo to get the current sha for the reference. - For each execution using the repo, a new independent work tree will be created from the bare repo. - The work trees will be cleaned up at the end of execution; the bare repo will remain to be reused. - Concurrency control will be ~~handed over to git, since it is capable of managing multiple fetches and work tree creations from a single bare repo~~ transitioned to a finer grained `MutexMap`, allowing higher concurrency but not taking any risks of go-git's [unclear concurrency guarantees](https://github.com/go-git/go-git/issues/773). This will address the problems described above. It does have a negative side-effect -- each running remote action will require creating a new work tree, increasing on-disk I/O where previously these might have been in-place already. However, this is a trade-off against reducing total disk I/O and usage by sharing a single repo over multiple references to that repo; so long-term usage will likely be lower. WIP: the core work is done and ready to be put through the test battery to see if any unexpected problems occur, which is why I opened this PR. TODO: - [x] Update the original repo to be a bare repo - [x] Cleanup work trees after they are `Close()`'d - [x] Seems like reference is slipping into the filepaths in `~/.cache/act` currently -- should be stripped - [x] Pass through each commits to identify any needed automated testing revisions - [x] Get all automated tests to pass - [x] Perform manual testing as needed <!--start release-notes-assistant--> <!--URL:https://code.forgejo.org/forgejo/runner--> - features - [PR](https://code.forgejo.org/forgejo/runner/pulls/1162): <!--number 1162 --><!--line 0 --><!--description ZmVhdDogdXNlIGdpdCB3b3JrIHRyZWVzIGZvciByZW1vdGUgZ2l0IGFjdGlvbnMgJiB3b3JrZmxvd3M=-->feat: use git work trees for remote git actions & workflows<!--description--> <!--end release-notes-assistant-->
mfenniak force-pushed feat-worktrees from 1ded1d2666
Some checks failed
issue-labels / release-notes (pull_request_target) Successful in 4s
checks / build and test (pull_request) Failing after 29s
checks / runner exec tests (pull_request) Has been skipped
checks / runner integration tests (pull_request) Has been skipped
checks / validate pre-commit-hooks file (pull_request) Successful in 29s
checks / validate mocks (pull_request) Successful in 34s
checks / integration tests (pull_request) Failing after 10m19s
to 8a6c7741b9
Some checks failed
cascade / forgejo (pull_request_target) Has been skipped
cascade / debug (pull_request_target) Has been skipped
cascade / end-to-end (pull_request_target) Has been skipped
checks / validate mocks (pull_request) Successful in 32s
checks / validate pre-commit-hooks file (pull_request) Successful in 30s
checks / build and test (pull_request) Successful in 1m55s
checks / runner exec tests (pull_request) Successful in 23s
checks / runner integration tests (pull_request) Successful in 4m53s
issue-labels / release-notes (pull_request_target) Successful in 4s
checks / integration tests (pull_request) Failing after 9m41s
2025-11-17 22:40:22 +00:00
Compare
mfenniak force-pushed feat-worktrees from 8a6c7741b9
Some checks failed
cascade / forgejo (pull_request_target) Has been skipped
cascade / debug (pull_request_target) Has been skipped
cascade / end-to-end (pull_request_target) Has been skipped
checks / validate mocks (pull_request) Successful in 32s
checks / validate pre-commit-hooks file (pull_request) Successful in 30s
checks / build and test (pull_request) Successful in 1m55s
checks / runner exec tests (pull_request) Successful in 23s
checks / runner integration tests (pull_request) Successful in 4m53s
issue-labels / release-notes (pull_request_target) Successful in 4s
checks / integration tests (pull_request) Failing after 9m41s
to 03aab6a211
Some checks failed
cascade / forgejo (pull_request_target) Has been skipped
cascade / debug (pull_request_target) Has been skipped
cascade / end-to-end (pull_request_target) Has been skipped
issue-labels / release-notes (pull_request_target) Successful in 5s
checks / validate mocks (pull_request) Successful in 33s
checks / validate pre-commit-hooks file (pull_request) Successful in 32s
checks / build and test (pull_request) Successful in 1m52s
checks / runner exec tests (pull_request) Successful in 26s
checks / runner integration tests (pull_request) Successful in 4m44s
checks / integration tests (pull_request) Failing after 9m52s
2025-11-18 02:32:04 +00:00
Compare
mfenniak force-pushed feat-worktrees from 03aab6a211
Some checks failed
cascade / forgejo (pull_request_target) Has been skipped
cascade / debug (pull_request_target) Has been skipped
cascade / end-to-end (pull_request_target) Has been skipped
issue-labels / release-notes (pull_request_target) Successful in 5s
checks / validate mocks (pull_request) Successful in 33s
checks / validate pre-commit-hooks file (pull_request) Successful in 32s
checks / build and test (pull_request) Successful in 1m52s
checks / runner exec tests (pull_request) Successful in 26s
checks / runner integration tests (pull_request) Successful in 4m44s
checks / integration tests (pull_request) Failing after 9m52s
to 1fd5c5eb13
Some checks failed
cascade / forgejo (pull_request_target) Has been skipped
cascade / debug (pull_request_target) Has been skipped
cascade / end-to-end (pull_request_target) Has been skipped
checks / validate mocks (pull_request) Successful in 29s
checks / validate pre-commit-hooks file (pull_request) Successful in 29s
checks / build and test (pull_request) Successful in 39s
checks / runner exec tests (pull_request) Successful in 24s
checks / runner integration tests (pull_request) Successful in 4m41s
issue-labels / release-notes (pull_request_target) Successful in 4s
checks / integration tests (pull_request) Failing after 9m30s
2025-11-18 02:54:44 +00:00
Compare
mfenniak force-pushed feat-worktrees from 1fd5c5eb13
Some checks failed
cascade / forgejo (pull_request_target) Has been skipped
cascade / debug (pull_request_target) Has been skipped
cascade / end-to-end (pull_request_target) Has been skipped
checks / validate mocks (pull_request) Successful in 29s
checks / validate pre-commit-hooks file (pull_request) Successful in 29s
checks / build and test (pull_request) Successful in 39s
checks / runner exec tests (pull_request) Successful in 24s
checks / runner integration tests (pull_request) Successful in 4m41s
issue-labels / release-notes (pull_request_target) Successful in 4s
checks / integration tests (pull_request) Failing after 9m30s
to 8202b3acc1
Some checks failed
cascade / forgejo (pull_request_target) Has been skipped
cascade / debug (pull_request_target) Has been skipped
cascade / end-to-end (pull_request_target) Has been skipped
issue-labels / release-notes (pull_request_target) Successful in 5s
checks / validate mocks (pull_request) Successful in 31s
checks / validate pre-commit-hooks file (pull_request) Successful in 29s
checks / integration tests (pull_request) Failing after 41s
checks / build and test (pull_request) Successful in 1m46s
checks / runner exec tests (pull_request) Successful in 29s
checks / runner integration tests (pull_request) Successful in 4m49s
2025-11-18 03:07:24 +00:00
Compare
mfenniak force-pushed feat-worktrees from 8202b3acc1
Some checks failed
cascade / forgejo (pull_request_target) Has been skipped
cascade / debug (pull_request_target) Has been skipped
cascade / end-to-end (pull_request_target) Has been skipped
issue-labels / release-notes (pull_request_target) Successful in 5s
checks / validate mocks (pull_request) Successful in 31s
checks / validate pre-commit-hooks file (pull_request) Successful in 29s
checks / integration tests (pull_request) Failing after 41s
checks / build and test (pull_request) Successful in 1m46s
checks / runner exec tests (pull_request) Successful in 29s
checks / runner integration tests (pull_request) Successful in 4m49s
to cffdf9d28c
Some checks failed
cascade / forgejo (pull_request_target) Has been skipped
cascade / debug (pull_request_target) Has been skipped
cascade / end-to-end (pull_request_target) Has been skipped
issue-labels / release-notes (pull_request_target) Successful in 6s
checks / validate mocks (pull_request) Successful in 32s
checks / validate pre-commit-hooks file (pull_request) Successful in 31s
checks / build and test (pull_request) Successful in 1m48s
checks / runner exec tests (pull_request) Successful in 22s
checks / runner integration tests (pull_request) Successful in 4m42s
checks / integration tests (pull_request) Failing after 10m11s
2025-11-18 03:08:39 +00:00
Compare
mfenniak force-pushed feat-worktrees from cffdf9d28c
Some checks failed
cascade / forgejo (pull_request_target) Has been skipped
cascade / debug (pull_request_target) Has been skipped
cascade / end-to-end (pull_request_target) Has been skipped
issue-labels / release-notes (pull_request_target) Successful in 6s
checks / validate mocks (pull_request) Successful in 32s
checks / validate pre-commit-hooks file (pull_request) Successful in 31s
checks / build and test (pull_request) Successful in 1m48s
checks / runner exec tests (pull_request) Successful in 22s
checks / runner integration tests (pull_request) Successful in 4m42s
checks / integration tests (pull_request) Failing after 10m11s
to bf3e51bef0
Some checks failed
cascade / forgejo (pull_request_target) Has been skipped
cascade / debug (pull_request_target) Has been skipped
cascade / end-to-end (pull_request_target) Has been skipped
issue-labels / release-notes (pull_request_target) Successful in 6s
checks / validate mocks (pull_request) Successful in 30s
checks / validate pre-commit-hooks file (pull_request) Successful in 29s
checks / build and test (pull_request) Successful in 38s
checks / runner exec tests (pull_request) Successful in 24s
checks / runner integration tests (pull_request) Successful in 4m41s
checks / integration tests (pull_request) Failing after 11m9s
2025-11-18 03:24:16 +00:00
Compare
Contributor

FYI there are no errors server side for the job running the CI on this PR.

FYI there are no errors server side for the job running the CI on this PR.
@ -148,3 +149,2 @@
run: |
go test -race ./act/container
go test -race -timeout 30m ./act/runner/...
go test -race -v ./act/container 2>&1 > tests.log
Contributor
go test -race -v ./act/container > tests.log 2>&1 

or

go test -race -v ./act/container >&  tests.log

because &1 is not yet tests.log

``` go test -race -v ./act/container > tests.log 2>&1 ``` or ``` go test -race -v ./act/container >& tests.log ``` because `&1` is not yet `tests.log`
Author
Owner

Thanks for pointing that out... could be why I'm not getting test errors. 🤔

Thanks for pointing that out... could be why I'm not getting test errors. 🤔
mfenniak marked this conversation as resolved
mfenniak force-pushed feat-worktrees from ae87859802
Some checks failed
cascade / forgejo (pull_request_target) Has been skipped
cascade / debug (pull_request_target) Has been skipped
cascade / end-to-end (pull_request_target) Has been skipped
issue-labels / release-notes (pull_request_target) Successful in 6s
checks / validate mocks (pull_request) Successful in 32s
checks / validate pre-commit-hooks file (pull_request) Successful in 32s
checks / build and test (pull_request) Successful in 1m40s
checks / runner exec tests (pull_request) Successful in 23s
checks / runner integration tests (pull_request) Failing after 4m26s
checks / integration tests (pull_request) Failing after 10m19s
to 5ab8171b85
All checks were successful
cascade / forgejo (pull_request_target) Has been skipped
cascade / debug (pull_request_target) Has been skipped
cascade / end-to-end (pull_request_target) Has been skipped
issue-labels / release-notes (pull_request_target) Successful in 7s
checks / validate mocks (pull_request) Successful in 33s
checks / validate pre-commit-hooks file (pull_request) Successful in 35s
checks / build and test (pull_request) Successful in 1m57s
checks / runner exec tests (pull_request) Successful in 24s
checks / runner integration tests (pull_request) Successful in 4m43s
checks / integration tests (pull_request) Successful in 10m39s
2025-11-19 18:30:27 +00:00
Compare
mfenniak force-pushed feat-worktrees from 5ab8171b85
All checks were successful
cascade / forgejo (pull_request_target) Has been skipped
cascade / debug (pull_request_target) Has been skipped
cascade / end-to-end (pull_request_target) Has been skipped
issue-labels / release-notes (pull_request_target) Successful in 7s
checks / validate mocks (pull_request) Successful in 33s
checks / validate pre-commit-hooks file (pull_request) Successful in 35s
checks / build and test (pull_request) Successful in 1m57s
checks / runner exec tests (pull_request) Successful in 24s
checks / runner integration tests (pull_request) Successful in 4m43s
checks / integration tests (pull_request) Successful in 10m39s
to 2028bf61fe
Some checks failed
checks / validate pre-commit-hooks file (pull_request) Successful in 40s
checks / validate mocks (pull_request) Successful in 44s
checks / build and test (pull_request) Successful in 2m10s
checks / runner exec tests (pull_request) Successful in 28s
cascade / forgejo (pull_request_target) Has been skipped
cascade / debug (pull_request_target) Has been skipped
checks / runner integration tests (pull_request) Successful in 5m25s
checks / integration tests (pull_request) Successful in 10m44s
issue-labels / release-notes (pull_request_target) Successful in 5s
cascade / end-to-end (pull_request_target) Failing after 9m15s
2025-11-19 20:33:01 +00:00
Compare
Contributor

cascading-pr updated at actions/setup-forgejo#765

cascading-pr updated at https://code.forgejo.org/actions/setup-forgejo/pulls/765
mfenniak changed title from WIP: feat: use git work trees for remote git actions & workflows to feat: use git work trees for remote git actions & workflows 2025-11-19 20:44:00 +00:00
mfenniak force-pushed feat-worktrees from 2028bf61fe
Some checks failed
checks / validate pre-commit-hooks file (pull_request) Successful in 40s
checks / validate mocks (pull_request) Successful in 44s
checks / build and test (pull_request) Successful in 2m10s
checks / runner exec tests (pull_request) Successful in 28s
cascade / forgejo (pull_request_target) Has been skipped
cascade / debug (pull_request_target) Has been skipped
checks / runner integration tests (pull_request) Successful in 5m25s
checks / integration tests (pull_request) Successful in 10m44s
issue-labels / release-notes (pull_request_target) Successful in 5s
cascade / end-to-end (pull_request_target) Failing after 9m15s
to dd8e7427cb
All checks were successful
cascade / forgejo (pull_request_target) Has been skipped
cascade / debug (pull_request_target) Has been skipped
issue-labels / release-notes (pull_request_target) Successful in 6s
checks / validate mocks (pull_request) Successful in 36s
checks / validate pre-commit-hooks file (pull_request) Successful in 35s
checks / build and test (pull_request) Successful in 1m53s
checks / runner exec tests (pull_request) Successful in 29s
checks / integration tests (pull_request) Successful in 9m39s
checks / runner integration tests (pull_request) Successful in 4m20s
cascade / end-to-end (pull_request_target) Successful in 29m48s
2025-11-19 21:01:47 +00:00
Compare
Contributor

cascading-pr updated at actions/setup-forgejo#765

cascading-pr updated at https://code.forgejo.org/actions/setup-forgejo/pulls/765
@ -382,0 +338,4 @@
r, err := cloneIfRequired(ctx, refName, input, logger, worktreeDir)
if err != nil {
return nil, err
}

s/may be reused optimize future clone/may be reused by future clone/

s/may be reused optimize future clone/may be reused by future clone/
Author
Owner

Thanks, fixed. dd8e7427cb..40f61a4621

Thanks, fixed. https://code.forgejo.org/forgejo/runner/compare/dd8e7427cb234bfb27566b5a3765928ba4ef1fc9..40f61a4621943de27f1ea19a8b60d1606487f7d9
limiting-factor marked this conversation as resolved
@ -382,0 +410,4 @@
if hash.String() != input.Ref && len(input.Ref) >= 4 && strings.HasPrefix(hash.String(), input.Ref) {
return nil, &Error{
err: ErrShortRef,
commit: hash.String(),

this adds a dependency to the runner

this adds a dependency to the runner
Author
Owner

Yes, this is a good point that warrants evaluation. As go-git doesn't support the worktree capability (github.com/go-git/go-git@0fd785bbcd/COMPATIBILITY.md (advanced)), shelling out to git is required for this capability.

We could manage this in a few ways:

  1. I'd propose to address this in general by adding a prominent release note when this feature is released. It could be argued as a breaking change requiring a major version bump, but considering forgejo-runner's OCI containers already contain the dependency, and it's just git which is widely available, I'd lean towards a prominent release note only.

  2. Same in terms of just documenting it, but breaking version change.

  3. Detect the availability of git and use the new capability. In its absence, print a warning message and retain the old approach of using dedicated full-clone repos.

  4. Use go-git's capabilities to read the repo and manually create a temporary working directory that contains the target revision's contents. The risk with this approach would be that the new working directory won't be a git repo, but just a bare directory -- if a remote action does something that inspects itself with git tooling, it would fail. It's also tricky to do this right; file perms, symlinks, other complications.

  5. Do 4, but only in the absence of git capable of doing work trees, providing a way to remediate the "action isn't a git repo" problem if it is identified.

I'm leaning towards 1 or 2 but I am clearly biased by "it's done", so I appreciate any input and thoughts.

Yes, this is a good point that warrants evaluation. As go-git doesn't support the `worktree` capability (https://github.com/go-git/go-git/blob/0fd785bbcd95f59b0d404e12ad25441fc484197f/COMPATIBILITY.md#advanced), shelling out to git is required for this capability. We could manage this in a few ways: 1. I'd propose to address this in general by adding a prominent release note when this feature is released. It could be argued as a breaking change requiring a major version bump, but considering forgejo-runner's OCI containers already contain the dependency, and it's just git which is widely available, I'd lean towards a prominent release note only. 2. Same in terms of just documenting it, but breaking version change. 3. Detect the availability of `git` and use the new capability. In its absence, print a warning message and retain the old approach of using dedicated full-clone repos. 4. Use go-git's capabilities to read the repo and manually create a temporary working directory that contains the target revision's contents. The risk with this approach would be that the new working directory won't be a git repo, but just a bare directory -- if a remote action does something that inspects itself with git tooling, it would fail. It's also tricky to do this right; file perms, symlinks, other complications. 5. Do 4, but only in the absence of `git` capable of doing work trees, providing a way to remediate the "action isn't a git repo" problem if it is identified. I'm leaning towards 1 or 2 but I am clearly biased by "it's done", so I appreciate any input and thoughts.

2 seems best: it will break any installation that does not have git in the PATH.

In favor of adding git as a dependency:

  • the runner is not a standalone binary, it already has at least one dependency: docker or podman
  • go-git is not as robust and should be replaced by git everywhere: this opens the way
2 seems best: it will break any installation that does not have `git` in the PATH. In favor of adding git as a dependency: - the runner is not a standalone binary, it already has at least one dependency: docker or podman - go-git is not as robust and should be replaced by git everywhere: this opens the way
Author
Owner

OK, I'll mark this as breaking and ensure a major version bump.

OK, I'll mark this as breaking and ensure a major version bump.
limiting-factor marked this conversation as resolved

s/[^\w]/-/g would be safer

`s/[^\w]/-/g` would be safer

what if the resulting file name is longer than the maximum? wouldn't it be safer to use a checksum?

what if the resulting file name is longer than the maximum? wouldn't it be safer to use a checksum?
Author
Owner

Yes, I think this is a good idea. I somewhat liked having readable folder names to identify the repos... was useful for manual testing at least... but I've changed it to a hash following the same pattern as the worktree directories. dd8e7427cb..40f61a4621

Yes, I think this is a good idea. I somewhat liked having readable folder names to identify the repos... was useful for manual testing at least... but I've changed it to a hash following the same pattern as the worktree directories. https://code.forgejo.org/forgejo/runner/compare/dd8e7427cb234bfb27566b5a3765928ba4ef1fc9..40f61a4621943de27f1ea19a8b60d1606487f7d9
limiting-factor marked this conversation as resolved
mfenniak force-pushed feat-worktrees from dd8e7427cb
All checks were successful
cascade / forgejo (pull_request_target) Has been skipped
cascade / debug (pull_request_target) Has been skipped
issue-labels / release-notes (pull_request_target) Successful in 6s
checks / validate mocks (pull_request) Successful in 36s
checks / validate pre-commit-hooks file (pull_request) Successful in 35s
checks / build and test (pull_request) Successful in 1m53s
checks / runner exec tests (pull_request) Successful in 29s
checks / integration tests (pull_request) Successful in 9m39s
checks / runner integration tests (pull_request) Successful in 4m20s
cascade / end-to-end (pull_request_target) Successful in 29m48s
to 40f61a4621
Some checks failed
cascade / forgejo (pull_request_target) Has been skipped
cascade / debug (pull_request_target) Has been skipped
issue-labels / release-notes (pull_request_target) Successful in 7s
checks / validate pre-commit-hooks file (pull_request) Successful in 1m2s
checks / validate mocks (pull_request) Successful in 1m22s
checks / build and test (pull_request) Successful in 3m18s
checks / runner exec tests (pull_request) Successful in 34s
checks / runner integration tests (pull_request) Successful in 5m59s
checks / integration tests (pull_request) Failing after 14m48s
cascade / end-to-end (pull_request_target) Successful in 40m9s
2025-11-20 16:11:48 +00:00
Compare
Contributor

cascading-pr updated at actions/setup-forgejo#765

cascading-pr updated at https://code.forgejo.org/actions/setup-forgejo/pulls/765
Author
Owner

Ran across https://github.com/go-git/go-git/issues/773 while answering that last comment and it has me concerned that the Mutex removal might not be as safe as it would be if we were using raw git subcommands. I'm going to incorporate the MutexMap that I recently added to Forgejo (in https://codeberg.org/forgejo/forgejo/pulls/10127) which can provide fine-grained locking, providing safety without as much performance impact.

Ran across https://github.com/go-git/go-git/issues/773 while answering that last comment and it has me concerned that the Mutex removal might not be as safe as it would be if we were using raw git subcommands. I'm going to incorporate the `MutexMap` that I recently added to Forgejo (in https://codeberg.org/forgejo/forgejo/pulls/10127) which can provide fine-grained locking, providing safety without as much performance impact.
mfenniak force-pushed feat-worktrees from 40f61a4621
Some checks failed
cascade / forgejo (pull_request_target) Has been skipped
cascade / debug (pull_request_target) Has been skipped
issue-labels / release-notes (pull_request_target) Successful in 7s
checks / validate pre-commit-hooks file (pull_request) Successful in 1m2s
checks / validate mocks (pull_request) Successful in 1m22s
checks / build and test (pull_request) Successful in 3m18s
checks / runner exec tests (pull_request) Successful in 34s
checks / runner integration tests (pull_request) Successful in 5m59s
checks / integration tests (pull_request) Failing after 14m48s
cascade / end-to-end (pull_request_target) Successful in 40m9s
to 7716bb0ecc
Some checks failed
cascade / forgejo (pull_request_target) Has been skipped
cascade / debug (pull_request_target) Has been skipped
issue-labels / release-notes (pull_request_target) Successful in 7s
checks / build and test (pull_request) Failing after 51s
checks / runner exec tests (pull_request) Has been skipped
checks / runner integration tests (pull_request) Has been skipped
checks / validate pre-commit-hooks file (pull_request) Successful in 54s
checks / validate mocks (pull_request) Successful in 1m11s
checks / integration tests (pull_request) Successful in 21m43s
cascade / end-to-end (pull_request_target) Successful in 43m19s
2025-11-20 16:46:48 +00:00
Compare
Contributor

cascading-pr updated at actions/setup-forgejo#765

cascading-pr updated at https://code.forgejo.org/actions/setup-forgejo/pulls/765
mfenniak force-pushed feat-worktrees from 7716bb0ecc
Some checks failed
cascade / forgejo (pull_request_target) Has been skipped
cascade / debug (pull_request_target) Has been skipped
issue-labels / release-notes (pull_request_target) Successful in 7s
checks / build and test (pull_request) Failing after 51s
checks / runner exec tests (pull_request) Has been skipped
checks / runner integration tests (pull_request) Has been skipped
checks / validate pre-commit-hooks file (pull_request) Successful in 54s
checks / validate mocks (pull_request) Successful in 1m11s
checks / integration tests (pull_request) Successful in 21m43s
cascade / end-to-end (pull_request_target) Successful in 43m19s
to 5c8dcb38e0
All checks were successful
checks / validate mocks (pull_request) Successful in 1m3s
checks / build and test (pull_request) Successful in 3m29s
checks / validate pre-commit-hooks file (pull_request) Successful in 58s
checks / runner exec tests (pull_request) Successful in 1m2s
checks / integration tests (pull_request) Successful in 21m49s
checks / runner integration tests (pull_request) Successful in 8m28s
issue-labels / release-notes (pull_request_target) Successful in 5s
cascade / debug (pull_request_target) Has been skipped
cascade / end-to-end (pull_request_target) Successful in 6s
cascade / forgejo (pull_request_target) Successful in 19s
2025-11-20 16:50:12 +00:00
Compare
Contributor

cascading-pr updated at actions/setup-forgejo#765

cascading-pr updated at https://code.forgejo.org/actions/setup-forgejo/pulls/765

@mfenniak wrote in #1162 (comment):

be if we were using raw git subcommands.

it is one example advocating for replacing one usage of go-git with a git command.

@mfenniak wrote in https://code.forgejo.org/forgejo/runner/pulls/1162#issuecomment-67299: > be if we were using raw git subcommands. it is one example advocating for replacing one usage of go-git with a git command.
https://forgejo.org/docs/latest/admin/actions/runner-installation/ should also be updated.
mfenniak deleted branch feat-worktrees 2025-11-21 13:49:27 +00:00
First-time contributor

Hmm, this causes problems with actions written with nix, such as https://github.com/ajamtli/update-flake-inputs-forgejo - the checkout copied into /var/run/act in the runner environment/namespace has a .git file pointing to the original clone in the runner's cache directory (/var/lib/runner/name/.cache on my system), but the latter directory is not actually accessible. Any ideas for a workaround? And where is the best place to discuss this? :)

      … while fetching the input 'git+file:///var/run/act/actions/35/28050195cc655e7e238860ffa5fd3bfbbacb01a4afa93d0e3fc12ef850c948'
       error: opening Git repository "/var/run/act/actions/35/28050195cc655e7e238860ffa5fd3bfbbacb01a4afa93d0e3fc12ef850c948": failed to resolve path '/var/lib/private/gitea-runner/nuc1/.cache/act/26/66c8c9dd16956ab7eecd9de1e7cf2d16c471242d49bff453029bae099f0f02/worktrees/28050195cc655e7e238860ffa5fd3bfbbacb01a4afa93d0e3fc12ef850c948': No such file or directory
      ```
Hmm, this causes problems with actions written with nix, such as https://github.com/ajamtli/update-flake-inputs-forgejo - the checkout copied into /var/run/act in the runner environment/namespace has a .git file pointing to the original clone in the runner's cache directory (/var/lib/runner/name/.cache on my system), but the latter directory is not actually accessible. Any ideas for a workaround? And where is the best place to discuss this? :) ``` … while fetching the input 'git+file:///var/run/act/actions/35/28050195cc655e7e238860ffa5fd3bfbbacb01a4afa93d0e3fc12ef850c948' error: opening Git repository "/var/run/act/actions/35/28050195cc655e7e238860ffa5fd3bfbbacb01a4afa93d0e3fc12ef850c948": failed to resolve path '/var/lib/private/gitea-runner/nuc1/.cache/act/26/66c8c9dd16956ab7eecd9de1e7cf2d16c471242d49bff453029bae099f0f02/worktrees/28050195cc655e7e238860ffa5fd3bfbbacb01a4afa93d0e3fc12ef850c948': No such file or directory ```
Member

@srd424 I think it would be best to open a new issue, ideally with a reproducer that we can run ourselves.

@srd424 I think it would be best to open a new issue, ideally with a reproducer that we can run ourselves.
Owner

@srd424 please open a new bug issue and add a minimal reproduction

@srd424 please open a new bug issue and add a minimal reproduction
First-time contributor

Will do - it's arguably not a bug so much as a new incompatibility, but agree a new issue is probably the best place!

Will do - it's arguably not a bug so much as a new incompatibility, but agree a new issue is probably the best place!
First-time contributor

Done in #1369 - I can add more info if required, just shout.

Done in https://code.forgejo.org/forgejo/runner/issues/1369 - I can add more info if required, just shout.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
7 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
forgejo/runner!1162
No description provided.