fix: clone actions with Git instead of go-git #1255

Merged
mfenniak merged 1 commit from aahlenst/runner:clone-with-git into main 2026-01-08 22:37:32 +00:00
Member

Enables cloning of actions hosted on Git repositories that use SHA-256.

  • bug fixes
    • PR: fix: clone actions with Git instead of go-git
Enables cloning of actions hosted on Git repositories that use SHA-256. <!--start release-notes-assistant--> <!--URL:https://code.forgejo.org/forgejo/runner--> - bug fixes - [PR](https://code.forgejo.org/forgejo/runner/pulls/1255): <!--number 1255 --><!--line 0 --><!--description Zml4OiBjbG9uZSBhY3Rpb25zIHdpdGggR2l0IGluc3RlYWQgb2YgZ28tZ2l0-->fix: clone actions with Git instead of go-git<!--description--> <!--end release-notes-assistant-->
Author
Member

I hope I tested all scenarios including moving branches, tags, and force pushes. I couldn't test actions in private repositories because I don't know how to make it work. In any case, I would be great if reviewers would try it locally, too.

I didn't touch the locks (see #1162 for background) because I'm unsure whether it's safe to remove them.

There is no centralized debug logging of generated git commands in git() because I'm unable to obtain a context in every case, the biggest obstacle being Close() of gitWorktree.

I found three more usages of go-git across the code base. All seem to do some kind of matching involving .gitignore. I don't know whether it makes sense to replace them or if it's even possible. If anyone knows, let me know.

I hope I tested all scenarios including moving branches, tags, and force pushes. I couldn't test actions in private repositories because I don't know how to make it work. In any case, I would be great if reviewers would try it locally, too. I didn't touch the locks (see https://code.forgejo.org/forgejo/runner/pulls/1162 for background) because I'm unsure whether it's safe to remove them. There is no centralized debug logging of generated `git` commands in `git()` because I'm unable to obtain a context in every case, the biggest obstacle being `Close()` of `gitWorktree`. I found three more usages of go-git across the code base. All seem to do some kind of matching involving `.gitignore`. I don't know whether it makes sense to replace them or if it's even possible. If anyone knows, let me know.
limiting-factor requested changes 2026-01-05 09:50:14 +00:00
Dismissed
@ -239,2 +174,2 @@
_ = os.RemoveAll(repoDir)
}
func cloneIfRequired(input CloneInput, logger log.FieldLogger, repoDir string) error {
if url, err := getRemoteURL(repoDir, "origin"); err == nil {

the case where err != nil needs to be handled by returning the error

the case where err != nil needs to be handled by returning the error

looking at getRemoteURL, it assumes that all errors are recoverable in the sense that they can be ignored and the function can proceed to clone the repository

in the case of an error case I think

  • the repoDir should be removed (if it exists the clone would fail)
  • the getRemoteURL messages should be marked to be ignored to not be confused with errors that need fixing
looking at getRemoteURL, it assumes that all errors are recoverable in the sense that they can be ignored and the function can proceed to clone the repository in the case of an error case I think - the repoDir should be removed (if it exists the clone would fail) - the getRemoteURL messages should be marked to be ignored to not be confused with errors that need fixing
Author
Member

There, the role of getRemoteURL() is to check whether we can avoid cloning, not to ensure that cloning will succeed. That's why the code only looks at the positive case. There are many reasons why a clone could fail and git clone is best equipped to handle those.

I'll add a comment in any case.

the getRemoteURL messages should be marked to be ignored to not be confused with errors that need fixing

I don't follow.

There, the role of `getRemoteURL()` is to check whether we can avoid cloning, not to ensure that cloning will succeed. That's why the code only looks at the positive case. There are many reasons why a clone could fail and `git clone` is best equipped to handle those. I'll add a comment in any case. > the getRemoteURL messages should be marked to be ignored to not be confused with errors that need fixing I don't follow.
limiting-factor marked this conversation as resolved
@ -435,0 +391,4 @@
workingDirectory string
}
func git(options *gitOptions, args ...string) (string, error) {

you could borrow from https://code.forgejo.org/f3/gof3/src/branch/main/util/exec.go to run the command with a context that will bind the git command to the context and stop it when the context is cancelled

you could borrow from https://code.forgejo.org/f3/gof3/src/branch/main/util/exec.go to run the command with a context that will bind the git command to the context and stop it when the context is cancelled
Author
Member

See #1255 (comment) for why there's no context, logging, or cancellation, at least not yet.

See https://code.forgejo.org/forgejo/runner/pulls/1255#issuecomment-71549 for why there's no context, logging, or cancellation, at least not yet.

func cloneIfRequired( was called with a context that was used when calling git.PlainCloneContext and I assume (did not check) that it would allow it to be cancelled or timeout at least in some cases that are meaningful. This is why I suggested to at least support context in the same cases in the proposed re-implementation.

If you found that in the previous implementation a clone would hang forever in all cases instead of timing out, my remark is not useful.

`func cloneIfRequired(` was called with a context that was used when calling `git.PlainCloneContext` and I assume (did not check) that it would allow it to be cancelled or timeout at least in some cases that are meaningful. This is why I suggested to at least support context in the same cases in the proposed re-implementation. If you found that in the previous implementation a clone would hang forever in all cases instead of timing out, my remark is not useful.
Author
Member

Let me rephrase my problem: Close() calls git. It did so before the re-implementation. Due to way Close() is defined, it cannot receive a context. So I either have to implement git() for Close() without a context, add context to Close(), or leave it as it is.

I have no idea which of these options is the right one.

Let me rephrase my problem: `Close()` calls `git`. It did so before the re-implementation. Due to way `Close()` is defined, it cannot receive a context. So I either have to implement `git()` for `Close()` without a context, add context to `Close()`, or leave it as it is. I have no idea which of these options is the right one.

Here is what intuitively makes sense to me: since func (t *gitWorktree) Close() error is short lived and does not currently need a context, using context.Background() for the new git function will not change its behavior. Adding a context to Close() may make sense but it seems to be out of scope for what this pull request is trying to achieve. In order to allow for a git clone to timeout or be cancelled (which is needed in general because it can hang - but again I did not check if that actually works now) the new git function should run git with a context.

I hope that helps. But I don't have a strong opinion because I did not thoroughly investigate the current behavior with go-git during a git clone. If it cannot timeout for some reason despite being provided with a context, then trying to add that functionality is out of scope. If it does timeout, a failure to do so in the git based re-implementation would be a regression.

Here is what intuitively makes sense to me: since `func (t *gitWorktree) Close() error ` is short lived and does not currently need a context, using `context.Background()` for the new `git` function will not change its behavior. Adding a context to `Close()` may make sense but it seems to be out of scope for what this pull request is trying to achieve. In order to allow for a git clone to timeout or be cancelled (which is needed in general because it can hang - but again I did not check if that actually works now) the new `git` function should run git with a context. I hope that helps. But I don't have a strong opinion because I did not thoroughly investigate the current behavior with go-git during a git clone. If it cannot timeout for some reason despite being provided with a context, then trying to add that functionality is out of scope. If it does timeout, a failure to do so in the git based re-implementation would be a regression.
Author
Member

I read up on io.Closer() and there seems to be no special behaviour associated with it. And because the blast radius of adding a context is rather small, I went ahead and added a context everywhere. See 8bad8fc7de..505bf5120c.

Cancellation is handled by exec.CommandContext().

I read up on `io.Closer()` and there seems to be no special behaviour associated with it. And because the blast radius of adding a context is rather small, I went ahead and added a context everywhere. See https://code.forgejo.org/forgejo/runner/compare/8bad8fc7de8f1c461d41d3b656da0838ec3551f8..505bf5120c87fc825d349b5f6b0474d2ed3adbe3. Cancellation is handled by `exec.CommandContext()`.
limiting-factor marked this conversation as resolved
@ -435,0 +396,4 @@
if options.token != "" {
authHeader := fmt.Sprintf("Authorization: Basic %s", base64.StdEncoding.EncodeToString([]byte(options.token)))
gitArguments = append(gitArguments, "-c", fmt.Sprintf("http.extraHeader='%s'", authHeader))

codeberg.org/forgejo/forgejo@acdfb122cb/modules/git/repo.go (L153-L181)

shows how to set credentials without leaking them in the command line

https://codeberg.org/forgejo/forgejo/src/commit/acdfb122cbfd0f600dc1c8d97a09ea2791467cdd/modules/git/repo.go#L153-L181 shows how to set credentials without leaking them in the command line
Author
Member
Fixed in https://code.forgejo.org/forgejo/runner/compare/fd2207c0059938b01e2ba44f2133134fe18faea1..8f163719243730c2cd3aa381b81105e6777c7c91
limiting-factor marked this conversation as resolved
aahlenst force-pushed clone-with-git from fd2207c005
All checks were successful
checks / validate mocks (pull_request) Successful in 42s
checks / validate pre-commit-hooks file (pull_request) Successful in 42s
checks / build and test (pull_request) Successful in 1m43s
checks / runner exec tests (pull_request) Successful in 27s
checks / runner integration tests (pull_request) Successful in 4m11s
checks / integration tests (docker-latest) (pull_request) Successful in 7m10s
checks / integration tests (docker-stable) (pull_request) Successful in 9m18s
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 4s
to 8f16371924
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 5s
checks / validate pre-commit-hooks file (pull_request) Successful in 1m13s
checks / validate mocks (pull_request) Successful in 1m28s
checks / build and test (pull_request) Successful in 2m51s
checks / runner exec tests (pull_request) Successful in 39s
checks / runner integration tests (pull_request) Successful in 6m22s
checks / integration tests (docker-latest) (pull_request) Successful in 11m51s
checks / integration tests (docker-stable) (pull_request) Successful in 14m40s
2026-01-05 13:57:06 +00:00
Compare
aahlenst force-pushed clone-with-git from 8f16371924
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 5s
checks / validate pre-commit-hooks file (pull_request) Successful in 1m13s
checks / validate mocks (pull_request) Successful in 1m28s
checks / build and test (pull_request) Successful in 2m51s
checks / runner exec tests (pull_request) Successful in 39s
checks / runner integration tests (pull_request) Successful in 6m22s
checks / integration tests (docker-latest) (pull_request) Successful in 11m51s
checks / integration tests (docker-stable) (pull_request) Successful in 14m40s
to 8bad8fc7de
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 11s
checks / build and test (pull_request) Successful in 1m34s
checks / validate mocks (pull_request) Successful in 1m0s
checks / validate pre-commit-hooks file (pull_request) Successful in 56s
checks / runner exec tests (pull_request) Successful in 53s
checks / runner integration tests (pull_request) Successful in 5m54s
checks / integration tests (docker-latest) (pull_request) Successful in 11m25s
checks / integration tests (docker-stable) (pull_request) Successful in 13m55s
2026-01-05 15:07:42 +00:00
Compare
@ -241,0 +180,4 @@
_ = os.RemoveAll(repoDir)
} else {
// The remote exists and has not changed, therefore we do not have to clone the repository.
return nil

If getRemoteURL fails and repoDir exists, the clone that follows will fail because repoDir exists.

If getRemoteURL fails and repoDir exists, the clone that follows will fail because repoDir exists.
Author
Member

That is true. And as far I know, git clone will complain about it. The end result is the same: an error.

Or do you want me to decrease the likelihood of a clone error? The resulting code would still ignore the error, but have to perform an additional check whether the directory and exists. If it exists and getRemoteURL fails, we can assume that the clone is unhealthy and remove it. But is it a good idea? Something went seriously wrong if we encountered that situation.

That is true. And as far I know, `git clone` will complain about it. The end result is the same: an error. Or do you want me to decrease the likelihood of a clone error? The resulting code would still ignore the error, but have to perform an additional check whether the directory and exists. If it exists and `getRemoteURL` fails, we can assume that the clone is unhealthy and remove it. But is it a good idea? Something went seriously wrong if we encountered that situation.

@aahlenst wrote in #1255 (comment):

That is true. An will complain about it. The end result is the same: an error.

True. But then the git clone error will shadow the first error. I do not feel strongly about this: the previous implementation had the same "let's ignore errors" behavior and I'm fine with not changing that in this pull request.

Or do you want me to decrease the likelihood of a clone error?

My comment was more in reaction to never handling or displaying any of the gitRemoteURL errors which is an unusual pattern. But I'm find with how it currently is, this is a minor non blocking matter.

@aahlenst wrote in https://code.forgejo.org/forgejo/runner/pulls/1255#issuecomment-71684: > That is true. An will complain about it. The end result is the same: an error. True. But then the git clone error will shadow the first error. I do not feel strongly about this: the previous implementation had the same "let's ignore errors" behavior and I'm fine with not changing that in this pull request. > Or do you want me to decrease the likelihood of a clone error? My comment was more in reaction to never handling or displaying any of the gitRemoteURL errors which is an unusual pattern. But I'm find with how it currently is, this is a minor non blocking matter.
limiting-factor marked this conversation as resolved
aahlenst force-pushed clone-with-git from 8bad8fc7de
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 11s
checks / build and test (pull_request) Successful in 1m34s
checks / validate mocks (pull_request) Successful in 1m0s
checks / validate pre-commit-hooks file (pull_request) Successful in 56s
checks / runner exec tests (pull_request) Successful in 53s
checks / runner integration tests (pull_request) Successful in 5m54s
checks / integration tests (docker-latest) (pull_request) Successful in 11m25s
checks / integration tests (docker-stable) (pull_request) Successful in 13m55s
to 505bf5120c
All checks were successful
checks / validate mocks (pull_request) Successful in 35s
checks / validate pre-commit-hooks file (pull_request) Successful in 43s
checks / build and test (pull_request) Successful in 1m13s
checks / runner exec tests (pull_request) Successful in 39s
checks / runner integration tests (pull_request) Successful in 4m59s
checks / integration tests (docker-latest) (pull_request) Successful in 8m45s
checks / integration tests (docker-stable) (pull_request) Successful in 10m42s
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 4s
cascade / end-to-end (pull_request_target) Successful in 18m20s
2026-01-06 13:36:55 +00:00
Compare
Contributor

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

cascading-pr updated at https://code.forgejo.org/actions/setup-forgejo/pulls/805
mfenniak left a comment
Owner

I haven't been able to complete my review yet, but I have pulled this branch down to run through it locally, and I've tagged for the end-to-end tests to run.

I haven't been able to complete my review yet, but I have pulled this branch down to run through it locally, and I've tagged for the end-to-end tests to run.
@ -641,3 +690,2 @@
require.NoError(t, err)
assert.Equal(t, "refs/tags/tag-1", ref)
runtime.GC() // release file locks held by go-git on Windows
assert.Equal(t, "tags/tag-1", ref)
Owner

I'm a little concerned about the test change here. From my understanding of the code, FindGitRef which is now DescribeHead is used to populate ${{ forgejo.ref }}, and the output here has changed from refs/tags/tag-1 to tags/tag-1. Which would seem like it would cause compatibility issues with workflows that use this var. Am I mistaken in that analysis?

It's a little subtle where this is used in the runner, but I think I've identified it -- forgejo-runner exec will now report ${{ forgejo.ref }} as heads/... rather than refs/heads/.... In non-exec cases the ref is provided by Forgejo rather than determined by the runner.

I'm a little concerned about the test change here. From my understanding of the code, `FindGitRef` which is now `DescribeHead` is used to populate `${{ forgejo.ref }}`, and the output here has changed from `refs/tags/tag-1` to `tags/tag-1`. Which would seem like it would cause compatibility issues with workflows that use this var. Am I mistaken in that analysis? It's a little subtle where this is used in the runner, but I think I've identified it -- `forgejo-runner exec` will now report `${{ forgejo.ref }}` as `heads/...` rather than `refs/heads/...`. In non-exec cases the ref is provided by Forgejo rather than determined by the runner.
Author
Member

Thanks a lot for finding that problem and figuring out where it's being used.

Should be fixed with 505bf5120c..7105022726.

Thanks a lot for finding that problem and figuring out where it's being used. Should be fixed with https://code.forgejo.org/forgejo/runner/compare/505bf5120c87fc825d349b5f6b0474d2ed3adbe3..7105022726a7eb06727442d00ae4b28ae2c7787a.
aahlenst force-pushed clone-with-git from 505bf5120c
All checks were successful
checks / validate mocks (pull_request) Successful in 35s
checks / validate pre-commit-hooks file (pull_request) Successful in 43s
checks / build and test (pull_request) Successful in 1m13s
checks / runner exec tests (pull_request) Successful in 39s
checks / runner integration tests (pull_request) Successful in 4m59s
checks / integration tests (docker-latest) (pull_request) Successful in 8m45s
checks / integration tests (docker-stable) (pull_request) Successful in 10m42s
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 4s
cascade / end-to-end (pull_request_target) Successful in 18m20s
to 7105022726
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 mocks (pull_request) Successful in 43s
checks / build and test (pull_request) Failing after 1m19s
checks / validate pre-commit-hooks file (pull_request) Successful in 42s
checks / runner exec tests (pull_request) Has been skipped
checks / runner integration tests (pull_request) Has been skipped
checks / integration tests (docker-latest) (pull_request) Successful in 9m20s
checks / integration tests (docker-stable) (pull_request) Successful in 12m0s
cascade / end-to-end (pull_request_target) Has been cancelled
2026-01-07 13:07:35 +00:00
Compare
Contributor

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

cascading-pr updated at https://code.forgejo.org/actions/setup-forgejo/pulls/805
@ -437,3 +312,1 @@
executor := r.NewPlanExecutor(plan)
return executor(ctx)
func runExec(ctx context.Context, execArgs *executeArgs) error {
Author
Member

The only change here is the removal of the closure which makes runExec() easier to test. The closure has been moved to the cobra configuration.

The only change here is the removal of the closure which makes `runExec()` easier to test. The closure has been moved to the cobra configuration.
@ -0,0 +38,4 @@
for _, testCase := range testCases {
args := &executeArgs{
event: testCase.event,
containerDaemonSocket: "/var/run/docker.sock",
Author
Member

It doesn't work with Podman no matter what's specified here and at least it silences the warning.

It doesn't work with Podman no matter what's specified here and at least it silences the warning.
Author
Member

I just realized that the test isn't included in make integration-test, so it won't be run by CI. I guess there are more tests in the code base that aren't picked up.

Having to manage paths or even to remember to update the Makefile isn't sustainable. Do you have any ideas to fix this mess, @mfenniak?

I just realized that the test isn't included in `make integration-test`, so it won't be run by CI. I guess there are more tests in the code base that aren't picked up. Having to manage paths or even to remember to update the Makefile isn't sustainable. Do you have any ideas to fix this mess, @mfenniak?
aahlenst force-pushed clone-with-git from 7105022726
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 mocks (pull_request) Successful in 43s
checks / build and test (pull_request) Failing after 1m19s
checks / validate pre-commit-hooks file (pull_request) Successful in 42s
checks / runner exec tests (pull_request) Has been skipped
checks / runner integration tests (pull_request) Has been skipped
checks / integration tests (docker-latest) (pull_request) Successful in 9m20s
checks / integration tests (docker-stable) (pull_request) Successful in 12m0s
cascade / end-to-end (pull_request_target) Has been cancelled
to 9c87ac35ff
All checks were successful
issue-labels / release-notes (pull_request_target) Successful in 4s
checks / validate mocks (pull_request) Successful in 28s
checks / validate pre-commit-hooks file (pull_request) Successful in 38s
checks / build and test (pull_request) Successful in 1m8s
checks / integration tests (docker-latest) (pull_request) Successful in 8m10s
checks / runner exec tests (pull_request) Successful in 26s
checks / integration tests (docker-stable) (pull_request) Successful in 10m22s
checks / runner integration tests (pull_request) Successful in 4m9s
cascade / debug (pull_request_target) Has been skipped
cascade / end-to-end (pull_request_target) Successful in 5s
cascade / forgejo (pull_request_target) Successful in 1m16s
2026-01-07 13:20:14 +00:00
Compare
Contributor

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

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

Something like this?

modified   Makefile
@@ -115,12 +115,11 @@ integration-test: runner-integration-test act-integration-test
 
 .PHONY: runner-integration-test
 runner-integration-test:
-	@$(GO) test -race -v ./internal/app/run/...
+	@$(GO) test -race -v ./internal/...
 
 .PHONY: act-integration-test
 act-integration-test:
-	@$(GO) test -race ./act/container
-	@$(GO) test -race -v -timeout 30m ./act/runner/...
+	@$(GO) test -race -v -timeout 30m ./act/...
 
 .PHONY: vet
 vet:
Something like this? ```diff modified Makefile @@ -115,12 +115,11 @@ integration-test: runner-integration-test act-integration-test .PHONY: runner-integration-test runner-integration-test: - @$(GO) test -race -v ./internal/app/run/... + @$(GO) test -race -v ./internal/... .PHONY: act-integration-test act-integration-test: - @$(GO) test -race ./act/container - @$(GO) test -race -v -timeout 30m ./act/runner/... + @$(GO) test -race -v -timeout 30m ./act/... .PHONY: vet vet: ```
Owner

Regarding testing, I can think of two reasonable approaches, with the goal that there is no risk that newly added tests aren't executed because they need to be listed in a Makefile:

Option A) make test runs go test -short, and make integration-test runs it without -short, without any package targeting at all. As make integration-test would be repeating all the same tests that make test runs, there's probably no value in doing both in separate CI steps -- the CI should probably just lint, and then run make integration-test.

Option B) take a "filter" approach, where the Makefile would list known "integration test" (or slow test) packages that are run in make integration-test, and everything else generated by go list ./... is run in make test. Forgejo almost does this, but then it still hard-codes the migration and integration tests in two places; the filter, and later in the test target that they're run, which is ... OK but not perfect. codeberg.org/forgejo/forgejo@ef6debfc02/Makefile (L289-L291)

Option A is simpler... and I think that the current set up is overly complicated... so I'd lean that way. It would require touching quite a few tests to put if testing.Short() { t.Skip("skipping integration test") }, but this pattern is already used in some tests here so it's aligned in that direction already.

Regarding testing, I can think of two reasonable approaches, with the goal that there is no risk that newly added tests aren't executed because they need to be listed in a `Makefile`: Option A) `make test` runs `go test -short`, and `make integration-test` runs it without `-short`, without any package targeting at all. As `make integration-test` would be repeating all the same tests that `make test` runs, there's probably no value in doing both in separate CI steps -- the CI should probably just lint, and then run `make integration-test`. Option B) take a "filter" approach, where the Makefile would list known "integration test" (or slow test) packages that are run in `make integration-test`, and *everything else* generated by `go list ./...` is run in `make test`. Forgejo *almost* does this, but then it still hard-codes the migration and integration tests in two places; the filter, and later in the test target that they're run, which is ... OK but not perfect. https://codeberg.org/forgejo/forgejo/src/commit/ef6debfc0263a87ce9d4ba721bf3e1d6daeac420/Makefile#L289-L291 Option A is simpler... and I think that the current set up is overly complicated... so I'd lean that way. It would require touching quite a few tests to put `if testing.Short() { t.Skip("skipping integration test") }`, but this pattern is already used in some tests here so it's aligned in that direction already.
Owner

(Something to do in a separate change. 🙂)

(Something to do in a separate change. 🙂)
mfenniak approved these changes 2026-01-08 22:36:40 +00:00
Owner

Fantastic work. 👍

Fantastic work. 👍
Author
Member

Thanks a lot @limiting-factor for your advice. Much appreciated.

Thanks a lot @limiting-factor for your advice. Much appreciated.

Thanks a lot for your work on the runner.

Thanks a lot for your work on the runner.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
4 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!1255
No description provided.