mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-04-24 21:00:27 +08:00
Merges the `gitea.com/gitea/act` fork into this repository as the `act/` directory and consumes it as a local package. The `replace github.com/nektos/act => gitea.com/gitea/act` directive is removed; act's dependencies are merged into the root `go.mod`. - Imports rewritten: `github.com/nektos/act/pkg/...` → `gitea.com/gitea/act_runner/act/...` (flattened — `pkg/` boundary dropped to match the layout forgejo-runner adopted). - Dropped act's CLI (`cmd/`, `main.go`) and all upstream project files; kept the library tree + `LICENSE`. - Added `// Copyright <year> The Gitea Authors ...` / `// Copyright <year> nektos` headers to 104 `.go` files. - Pre-existing act lint violations annotated inline with `//nolint:<linter> // pre-existing issue from nektos/act`. `.golangci.yml` is unchanged vs `main`. - Makefile test target: `-race -short` (matches forgejo-runner). - Pre-existing integration test failures fixed: race in parallel executor (atomic counters); TestSetupEnv / command_test / expression_test / run_context_test updated to match gitea fork runtime; TestJobExecutor and TestActionCache gated on `testing.Short()`. Full `gitea/act` commit history is reachable via the second parent. Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
// Copyright 2024 The Gitea Authors. All rights reserved.
|
|
// Copyright 2024 The nektos/act Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package runner
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
"path"
|
|
|
|
git "github.com/go-git/go-git/v5"
|
|
"github.com/go-git/go-git/v5/plumbing"
|
|
)
|
|
|
|
type GoGitActionCacheOfflineMode struct {
|
|
Parent GoGitActionCache
|
|
}
|
|
|
|
func (c GoGitActionCacheOfflineMode) Fetch(ctx context.Context, cacheDir, url, ref, token string) (string, error) {
|
|
sha, fetchErr := c.Parent.Fetch(ctx, cacheDir, url, ref, token)
|
|
gitPath := path.Join(c.Parent.Path, safeFilename(cacheDir)+".git")
|
|
gogitrepo, err := git.PlainOpen(gitPath)
|
|
if err != nil {
|
|
return "", fetchErr
|
|
}
|
|
refName := plumbing.ReferenceName("refs/action-cache-offline/" + ref)
|
|
r, err := gogitrepo.Reference(refName, true)
|
|
if fetchErr == nil {
|
|
if err != nil || sha != r.Hash().String() {
|
|
if err == nil {
|
|
refName = r.Name()
|
|
}
|
|
ref := plumbing.NewHashReference(refName, plumbing.NewHash(sha))
|
|
_ = gogitrepo.Storer.SetReference(ref)
|
|
}
|
|
} else if err == nil {
|
|
return r.Hash().String(), nil
|
|
}
|
|
return sha, fetchErr
|
|
}
|
|
|
|
func (c GoGitActionCacheOfflineMode) GetTarArchive(ctx context.Context, cacheDir, sha, includePrefix string) (io.ReadCloser, error) {
|
|
return c.Parent.GetTarArchive(ctx, cacheDir, sha, includePrefix)
|
|
}
|