mirror of
https://gitea.com/gitea/runner.git
synced 2026-11-16 21:03:43 +00:00
Compare commits
10
Commits
f2fbd67962
...
v5.4.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa56f46c89 | ||
|
|
7a9fccb842 | ||
|
|
7d6e1ff021 | ||
|
|
319567213d | ||
|
|
0093731295 | ||
|
|
3e1b4b42c2 | ||
|
|
dcba546cb3 | ||
|
|
142d9f8c88 | ||
|
|
54b2cb944c | ||
|
|
b65fd0f8f8 |
No files matched your search
@@ -34,6 +34,13 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
go-version-file: "go.mod"
|
go-version-file: "go.mod"
|
||||||
check-latest: true
|
check-latest: true
|
||||||
|
- name: Import GPG key
|
||||||
|
id: import_gpg
|
||||||
|
uses: crazy-max/ghaction-import-gpg@2dc316deee8e90f13e1a351ab510b4d5bc0c82cd # v7
|
||||||
|
with:
|
||||||
|
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
|
||||||
|
passphrase: ${{ secrets.PASSPHRASE }}
|
||||||
|
fingerprint: CC64B1DB67ABBEECAB24B6455FC346329753F4B0
|
||||||
- name: goreleaser
|
- name: goreleaser
|
||||||
uses: goreleaser/goreleaser-action@a4f02ab5355a589de60d917a659ce617ed19b3de # v7
|
uses: goreleaser/goreleaser-action@a4f02ab5355a589de60d917a659ce617ed19b3de # v7
|
||||||
with:
|
with:
|
||||||
@@ -47,6 +54,7 @@ jobs:
|
|||||||
R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
|
R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
|
||||||
GORELEASER_FORCE_TOKEN: "gitea"
|
GORELEASER_FORCE_TOKEN: "gitea"
|
||||||
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
|
||||||
|
|
||||||
release-image:
|
release-image:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
name: windows
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
- cron: '0 3 * * 1'
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
env:
|
|
||||||
DOCKER_CONFIG: /tmp/docker-noauth # see test.yml
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test:
|
|
||||||
name: test on windows
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
timeout-minutes: 180
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
||||||
- uses: ./.gitea/actions/go-setup
|
|
||||||
- name: prepare anonymous docker config
|
|
||||||
run: mkdir -p "$DOCKER_CONFIG" && echo '{}' > "$DOCKER_CONFIG/config.json"
|
|
||||||
- name: test on windows
|
|
||||||
run: make test-windows
|
|
||||||
@@ -57,6 +57,32 @@ jobs:
|
|||||||
make coverage-report
|
make coverage-report
|
||||||
cat .tmp/coverage.md >> "$GITHUB_STEP_SUMMARY"
|
cat .tmp/coverage.md >> "$GITHUB_STEP_SUMMARY"
|
||||||
|
|
||||||
|
windows:
|
||||||
|
name: test on windows
|
||||||
|
runs-on: ubuntu-latest-kvm
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||||
|
- uses: ./.gitea/actions/go-setup
|
||||||
|
- name: prepare anonymous docker config
|
||||||
|
run: mkdir -p "$DOCKER_CONFIG" && echo '{}' > "$DOCKER_CONFIG/config.json"
|
||||||
|
- name: windows vm cache key
|
||||||
|
id: windows-vm
|
||||||
|
run: echo "key=windows-vm-$(grep '^WINDOWS_TEST_IMAGE' Makefile | cat - scripts/test-windows.sh scripts/test-windows-setup.ps1 | sha256sum | cut -c1-16)" >> "$GITHUB_OUTPUT"
|
||||||
|
- uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||||
|
with:
|
||||||
|
path: ~/.cache/windows-vm
|
||||||
|
key: ${{ steps.windows-vm.outputs.key }}
|
||||||
|
- name: test on windows
|
||||||
|
id: test-windows
|
||||||
|
run: WINDOWS_TEST_CACHE="$HOME/.cache/windows-vm" make test-windows
|
||||||
|
env:
|
||||||
|
WINDOWS_TEST_TIMEOUT: 45
|
||||||
|
- if: always() && steps.test-windows.outputs.save-cache == 'true'
|
||||||
|
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||||
|
with:
|
||||||
|
path: ~/.cache/windows-vm
|
||||||
|
key: ${{ steps.windows-vm.outputs.key }}
|
||||||
|
|
||||||
e2e:
|
e2e:
|
||||||
name: gitea compatibility (${{ matrix.gitea_image }})
|
name: gitea compatibility (${{ matrix.gitea_image }})
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ linters:
|
|||||||
deny:
|
deny:
|
||||||
- pkg: golang.org/x/exp
|
- pkg: golang.org/x/exp
|
||||||
desc: it's experimental and unreliable
|
desc: it's experimental and unreliable
|
||||||
|
- pkg: unsafe
|
||||||
|
desc: use typed APIs instead
|
||||||
logging:
|
logging:
|
||||||
files:
|
files:
|
||||||
- $all
|
- $all
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ builds:
|
|||||||
publishers:
|
publishers:
|
||||||
- name: cloudflare-r2
|
- name: cloudflare-r2
|
||||||
checksum: true
|
checksum: true
|
||||||
|
signature: true
|
||||||
extra_files:
|
extra_files:
|
||||||
- glob: ./**.xz
|
- glob: ./**.xz
|
||||||
- glob: ./**.sha256
|
- glob: ./**.sha256
|
||||||
@@ -100,6 +101,10 @@ checksum:
|
|||||||
extra_files:
|
extra_files:
|
||||||
- glob: ./**.xz
|
- glob: ./**.xz
|
||||||
|
|
||||||
|
signs:
|
||||||
|
- artifacts: checksum
|
||||||
|
args: ["--batch", "-u", "{{ .Env.GPG_FINGERPRINT }}", "--output", "${signature}", "--detach-sign", "${artifact}"]
|
||||||
|
|
||||||
snapshot:
|
snapshot:
|
||||||
version_template: "{{ .Branch }}-devel"
|
version_template: "{{ .Branch }}-devel"
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -77,4 +77,5 @@ repository runners. A run path is `<workflow>@<ref>` and a log row is `<timestam
|
|||||||
The host must be amd64 and allow privileged containers. `WINDOWS_TEST_TIMEOUT` sets the minutes
|
The host must be amd64 and allow privileged containers. `WINDOWS_TEST_TIMEOUT` sets the minutes
|
||||||
allowed for installing Windows and running the tests, 165 by default. The VM uses KVM when the host
|
allowed for installing Windows and running the tests, 165 by default. The VM uses KVM when the host
|
||||||
has `/dev/kvm`, otherwise Windows is emulated and much slower. Docker-backed tests skip in the VM
|
has `/dev/kvm`, otherwise Windows is emulated and much slower. Docker-backed tests skip in the VM
|
||||||
and the race detector is off, it needs cgo. CI runs this weekly and on demand.
|
and the race detector is off, it needs cgo. `WINDOWS_TEST_CACHE` names a directory to keep the
|
||||||
|
installed Windows in, so later runs skip the install. CI runs this on every pull request.
|
||||||
@@ -153,7 +153,7 @@ test-dind: ## run the daemon-facing tests against the built dind image or podman
|
|||||||
|
|
||||||
.PHONY: test-windows
|
.PHONY: test-windows
|
||||||
test-windows: ## run the tests on Windows Server Core in a QEMU VM on the docker host
|
test-windows: ## run the tests on Windows Server Core in a QEMU VM on the docker host
|
||||||
@WINDOWS_TEST_IMAGE=$(WINDOWS_TEST_IMAGE) ./scripts/test-windows.sh
|
@GO=$(GO) WINDOWS_TEST_IMAGE=$(WINDOWS_TEST_IMAGE) ./scripts/test-windows.sh
|
||||||
|
|
||||||
E2E_CONCURRENCY ?= 8
|
E2E_CONCURRENCY ?= 8
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ The recommended Docker-in-Docker image runs its own Docker daemon for jobs. Jobs
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run --privileged -e GITEA_INSTANCE_URL=https://your_gitea.com -e GITEA_RUNNER_REGISTRATION_TOKEN=<your_token> \
|
docker run --privileged -e GITEA_INSTANCE_URL=https://your_gitea.com -e GITEA_RUNNER_REGISTRATION_TOKEN=<your_token> \
|
||||||
-v "$PWD/data:/data" -v runner-docker:/var/lib/docker --name my_runner gitea/runner:nightly-dind
|
-v "$PWD/data:/data" -v runner-docker:/var/lib/docker --name my_runner gitea/runner:latest-dind
|
||||||
```
|
```
|
||||||
|
|
||||||
The volumes keep the registration and the image cache across container recreation. The image reads more variables, such as `GITEA_RUNNER_LABELS` and `CONFIG_FILE`, see [scripts/run.sh](scripts/run.sh) and the [Docker example](examples/docker/README.md).
|
The volumes keep the registration and the image cache across container recreation. The image reads more variables, such as `GITEA_RUNNER_LABELS` and `CONFIG_FILE`, see [scripts/run.sh](scripts/run.sh) and the [Docker example](examples/docker/README.md).
|
||||||
@@ -164,7 +164,7 @@ ubuntu-latest:docker://docker.gitea.com/runner-images:ubuntu-latest,macos:host
|
|||||||
|
|
||||||
[gitea/runner-images](https://gitea.com/gitea/runner-images) has suitable images. Jobs matching no label run in `runner.default_image`, or on the host when docker is unavailable.
|
[gitea/runner-images](https://gitea.com/gitea/runner-images) has suitable images. Jobs matching no label run in `runner.default_image`, or on the host when docker is unavailable.
|
||||||
|
|
||||||
Host jobs still need a Docker daemon for Docker actions and `docker://` steps. Windows hosts do not support those, as on GitHub. On Windows, a step's background processes end with the job unless it opts out, see [host mode](docs/host-mode.md).
|
Host jobs still need a Docker daemon for Docker actions and `docker://` steps. Windows hosts do not support those, as on GitHub. A step's background processes end with the job unless it opts out, see [host mode](docs/host-mode.md).
|
||||||
|
|
||||||
#### Registration vs config labels
|
#### Registration vs config labels
|
||||||
|
|
||||||
|
|||||||
@@ -104,7 +104,8 @@ type Handler struct {
|
|||||||
stopSync context.CancelFunc
|
stopSync context.CancelFunc
|
||||||
syncing sync.WaitGroup
|
syncing sync.WaitGroup
|
||||||
|
|
||||||
outboundIP string
|
outboundIP string
|
||||||
|
instanceTransport http.RoundTripper
|
||||||
|
|
||||||
// internalSecret guards /_internal/{register,revoke}. When set, a remote
|
// internalSecret guards /_internal/{register,revoke}. When set, a remote
|
||||||
// runner can use these endpoints to pre-register per-job
|
// runner can use these endpoints to pre-register per-job
|
||||||
@@ -124,7 +125,7 @@ type Handler struct {
|
|||||||
|
|
||||||
policy Policy
|
policy Policy
|
||||||
|
|
||||||
// freeDisk is a field so tests can drive evictForFreeSpace without a full volume.
|
// freeDisk is a field so tests can drive makeRoom without a full volume.
|
||||||
freeDisk func(string) (uint64, error)
|
freeDisk func(string) (uint64, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,19 +144,21 @@ type Options struct {
|
|||||||
// in-process RegisterJob method directly.
|
// in-process RegisterJob method directly.
|
||||||
InternalSecret string
|
InternalSecret string
|
||||||
|
|
||||||
Policy Policy
|
Policy Policy
|
||||||
Logger *logging.Logger
|
Logger *logging.Logger
|
||||||
|
InstanceTransport http.RoundTripper // reaches the instance artifact requests are forwarded to, nil for http.DefaultTransport
|
||||||
}
|
}
|
||||||
|
|
||||||
// StartHandler starts an embedded cache or forwards cache requests to Upstream.
|
// StartHandler starts an embedded cache or forwards cache requests to Upstream.
|
||||||
func StartHandler(opts Options) (*Handler, error) {
|
func StartHandler(opts Options) (*Handler, error) {
|
||||||
dir, logger := opts.Dir, opts.Logger
|
dir, logger := opts.Dir, opts.Logger
|
||||||
h := &Handler{
|
h := &Handler{
|
||||||
creds: make(map[string]*credEntry),
|
creds: make(map[string]*credEntry),
|
||||||
internalSecret: opts.InternalSecret,
|
internalSecret: opts.InternalSecret,
|
||||||
policy: opts.Policy.withDefaults(),
|
policy: opts.Policy.withDefaults(),
|
||||||
freeDisk: disk.FreeBytes,
|
freeDisk: disk.FreeBytes,
|
||||||
dbLock: make(chan struct{}, 1),
|
dbLock: make(chan struct{}, 1),
|
||||||
|
instanceTransport: opts.InstanceTransport,
|
||||||
}
|
}
|
||||||
|
|
||||||
if logger == nil {
|
if logger == nil {
|
||||||
@@ -773,6 +776,7 @@ func (h *Handler) upload(w http.ResponseWriter, r *http.Request) {
|
|||||||
h.responseJSON(w, r, 400, err)
|
h.responseJSON(w, r, 400, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
h.makeRoom(r.ContentLength)
|
||||||
if err := h.storage.Write(cache.ID, start, r.Body); err != nil {
|
if err := h.storage.Write(cache.ID, start, r.Body); err != nil {
|
||||||
h.responseJSON(w, r, 500, err)
|
h.responseJSON(w, r, 500, err)
|
||||||
return
|
return
|
||||||
@@ -875,11 +879,8 @@ func (h *Handler) commitCache(cache *Cache) error {
|
|||||||
if h.s3 != nil {
|
if h.s3 != nil {
|
||||||
return nil // lifecycle rules on the bucket bound its size
|
return nil // lifecycle rules on the bucket bound its size
|
||||||
}
|
}
|
||||||
// A commit is the only thing that grows the store, so the only thing that can push the
|
|
||||||
// volume under the floor.
|
|
||||||
h.evictRepo(db, cache.Repo)
|
h.evictRepo(db, cache.Repo)
|
||||||
h.evictTotal(db)
|
h.evictTotal(db)
|
||||||
h.evictForFreeSpace(db)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1173,9 +1174,6 @@ func (h *Handler) touchCache(id uint64, requireIncomplete bool) error {
|
|||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
||||||
cache, err := db.get(id)
|
cache, err := db.get(id)
|
||||||
if errors.Is(err, errCacheNotFound) {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -1260,23 +1258,29 @@ func (h *Handler) gcCache() {
|
|||||||
h.evictExpired(db)
|
h.evictExpired(db)
|
||||||
h.evictSuperseded(db)
|
h.evictSuperseded(db)
|
||||||
h.evictOversized(db)
|
h.evictOversized(db)
|
||||||
h.evictForFreeSpace(db)
|
_ = db.Close()
|
||||||
|
h.makeRoom(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// evictForFreeSpace bounds the volume itself, so it also covers bytes the cache never
|
// makeRoom evicts the least recently used entries to keep need bytes above the floor, as GitHub saves new over old.
|
||||||
// accounted for.
|
func (h *Handler) makeRoom(need int64) {
|
||||||
func (h *Handler) evictForFreeSpace(db *cacheDB) {
|
|
||||||
free, err := h.freeDisk(h.dir)
|
free, err := h.freeDisk(h.dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
h.logger.Debugf("free disk check: %v", err) // unsupported platform, treat as unavailable rather than full
|
h.logger.Debugf("free disk check: %v", err) // unsupported platform, treat as unavailable rather than full
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if free >= uint64(h.policy.MinFreeDisk) {
|
shortfall := h.policy.MinFreeDisk + max(need, 0) - int64(free)
|
||||||
|
if h.s3 != nil || shortfall <= 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
db, err := h.openDB()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
caches := h.completedByUse(db)
|
caches := h.completedByUse(db)
|
||||||
total, shortfall := totalSize(caches), h.policy.MinFreeDisk-int64(free)
|
total := totalSize(caches)
|
||||||
if total <= shortfall {
|
if total <= shortfall {
|
||||||
// Say so, or shedding everything and still being short reads as the backstop working.
|
// Say so, or shedding everything and still being short reads as the backstop working.
|
||||||
h.logger.Warnf("cache volume is %d MiB short of the free space floor with only %d MiB of cache on it; something else is filling it", shortfall/miB, total/miB)
|
h.logger.Warnf("cache volume is %d MiB short of the free space floor with only %d MiB of cache on it; something else is filling it", shortfall/miB, total/miB)
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
"testing/iotest"
|
||||||
"testing/synctest"
|
"testing/synctest"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -673,7 +674,7 @@ func TestHandler_evictPolicy(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHandler_evictForFreeSpace(t *testing.T) {
|
func TestHandler_makeRoom(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
free := func(n int64) func(string) (uint64, error) {
|
free := func(n int64) func(string) (uint64, error) {
|
||||||
return func(string) (uint64, error) { return uint64(n), nil }
|
return func(string) (uint64, error) { return uint64(n), nil }
|
||||||
@@ -682,14 +683,16 @@ func TestHandler_evictForFreeSpace(t *testing.T) {
|
|||||||
for _, tc := range []struct {
|
for _, tc := range []struct {
|
||||||
name string
|
name string
|
||||||
freeDisk func(string) (uint64, error)
|
freeDisk func(string) (uint64, error)
|
||||||
|
upload int64
|
||||||
kept []string
|
kept []string
|
||||||
}{
|
}{
|
||||||
{"ample free space evicts nothing", free(defaultMinFreeDisk), []string{"oldest", "middle", "newest"}},
|
{"ample free space evicts nothing", free(defaultMinFreeDisk), 0, []string{"oldest", "middle", "newest"}},
|
||||||
{"a small shortfall sheds one entry", free(defaultMinFreeDisk - 4*miB), []string{"middle", "newest"}},
|
{"room for an upload sheds the oldest entry", free(defaultMinFreeDisk), 4 * miB, []string{"middle", "newest"}},
|
||||||
{"a shortfall the cache cannot cover sheds all of it", free(0), nil},
|
{"a shortfall the cache cannot cover sheds all of it", free(0), 0, nil},
|
||||||
{
|
{
|
||||||
"an unreadable volume is treated as unavailable, not as full",
|
"an unreadable volume is treated as unavailable, not as full",
|
||||||
func(string) (uint64, error) { return 0, errors.New("unsupported") },
|
func(string) (uint64, error) { return 0, errors.New("unsupported") },
|
||||||
|
0,
|
||||||
[]string{"oldest", "middle", "newest"},
|
[]string{"oldest", "middle", "newest"},
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
@@ -702,11 +705,7 @@ func TestHandler_evictForFreeSpace(t *testing.T) {
|
|||||||
}
|
}
|
||||||
handler := newTestHandler(t, Policy{}, entries...)
|
handler := newTestHandler(t, Policy{}, entries...)
|
||||||
handler.freeDisk = tc.freeDisk
|
handler.freeDisk = tc.freeDisk
|
||||||
|
handler.makeRoom(tc.upload)
|
||||||
db, err := handler.openDB()
|
|
||||||
require.NoError(t, err)
|
|
||||||
handler.evictForFreeSpace(db)
|
|
||||||
require.NoError(t, db.Close())
|
|
||||||
|
|
||||||
assert.ElementsMatch(t, tc.kept, keptKeys(t, handler, entries))
|
assert.ElementsMatch(t, tc.kept, keptKeys(t, handler, entries))
|
||||||
})
|
})
|
||||||
@@ -888,6 +887,13 @@ func keptKeys(t *testing.T, handler *Handler, entries []*Cache) []string {
|
|||||||
return kept
|
return kept
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestStorageDropsFailedWrites(t *testing.T) {
|
||||||
|
storage, err := NewStorage(t.TempDir())
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Error(t, storage.Write(1, 0, io.MultiReader(strings.NewReader("partial"), iotest.ErrReader(io.ErrUnexpectedEOF))))
|
||||||
|
assert.NoFileExists(t, storage.tempName(1, 0))
|
||||||
|
}
|
||||||
|
|
||||||
func writeBlob(t *testing.T, handler *Handler, id uint64) {
|
func writeBlob(t *testing.T, handler *Handler, id uint64) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
require.NoError(t, handler.storage.Write(id, 0, strings.NewReader("a")))
|
require.NoError(t, handler.storage.Write(id, 0, strings.NewReader("a")))
|
||||||
|
|||||||
@@ -218,6 +218,7 @@ func (h *Handler) v2UploadBlob(w http.ResponseWriter, r *http.Request) {
|
|||||||
h.responseJSON(w, r, http.StatusBadRequest, err)
|
h.responseJSON(w, r, http.StatusBadRequest, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
h.makeRoom(r.ContentLength)
|
||||||
|
|
||||||
query := r.URL.Query()
|
query := r.URL.Query()
|
||||||
switch strings.ToLower(query.Get("comp")) {
|
switch strings.ToLower(query.Get("comp")) {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@@ -84,6 +85,8 @@ func TestCacheServiceV2RoundTrip(t *testing.T) {
|
|||||||
|
|
||||||
unsigned := fmt.Sprintf("%s%s/1", handler.ExternalURL(), blobPath)
|
unsigned := fmt.Sprintf("%s%s/1", handler.ExternalURL(), blobPath)
|
||||||
assert.Equal(t, http.StatusUnauthorized, putBlob(t, unsigned, content))
|
assert.Equal(t, http.StatusUnauthorized, putBlob(t, unsigned, content))
|
||||||
|
unreserved := handler.signedURL(JobCredential{Repo: testRepo}, blobPath, blobUploadPurpose, 1, time.Now().Add(time.Minute))
|
||||||
|
assert.Equal(t, http.StatusBadRequest, putBlob(t, unreserved, content))
|
||||||
|
|
||||||
finalized, uploadURL := saveV2(t, handler, "deps-v1", "abc123", content)
|
finalized, uploadURL := saveV2(t, handler, "deps-v1", "abc123", content)
|
||||||
require.Equal(t, true, finalized["ok"])
|
require.Equal(t, true, finalized["ok"])
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ func (h *Handler) forwardOrNotFound(w http.ResponseWriter, r *http.Request) {
|
|||||||
h.twirpError(w, r, twirpInternal, fmt.Errorf("cache server cannot reach the artifact service at %s: %w", target, err))
|
h.twirpError(w, r, twirpInternal, fmt.Errorf("cache server cannot reach the artifact service at %s: %w", target, err))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if cred.InsecureTLS {
|
if proxy.Transport = h.instanceTransport; proxy.Transport == nil && cred.InsecureTLS { // the instance transport carries runner.insecure and the client cert
|
||||||
proxy.Transport = insecureTransport
|
proxy.Transport = insecureTransport
|
||||||
}
|
}
|
||||||
proxy.ServeHTTP(w, r)
|
proxy.ServeHTTP(w, r)
|
||||||
|
|||||||
@@ -133,3 +133,20 @@ func TestFrontResultsService(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestFrontResultsServiceForwardsThroughTheInstanceTransport(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
gitea := httptest.NewTLSServer(http.HandlerFunc(func(writer http.ResponseWriter, _request *http.Request) { _, _ = io.WriteString(writer, "{}") }))
|
||||||
|
defer gitea.Close()
|
||||||
|
handler, err := StartHandler(Options{Dir: t.TempDir(), OutboundIP: "127.0.0.1", InstanceTransport: gitea.Client().Transport})
|
||||||
|
require.NoError(t, err)
|
||||||
|
defer handler.Close()
|
||||||
|
defer handler.RegisterJob("token", JobCredential{Results: gitea.URL})()
|
||||||
|
|
||||||
|
req, err := http.NewRequestWithContext(t.Context(), http.MethodPost, handler.ExternalURL()+artifactServicePath+"CreateArtifact", nil)
|
||||||
|
require.NoError(t, err)
|
||||||
|
resp, err := (&http.Client{Transport: &bearerTransport{token: "token"}}).Do(req)
|
||||||
|
require.NoError(t, err)
|
||||||
|
defer resp.Body.Close()
|
||||||
|
require.Equal(t, http.StatusOK, resp.StatusCode)
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json/v2"
|
"encoding/json/v2"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -51,9 +52,10 @@ func (s *Storage) writeFile(name string, reader io.Reader) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer file.Close()
|
|
||||||
|
|
||||||
_, err = io.Copy(file, reader)
|
_, err = io.Copy(file, reader)
|
||||||
|
if err = errors.Join(err, file.Close()); err != nil {
|
||||||
|
_ = os.Remove(name)
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,50 +104,46 @@ func (s *Storage) Commit(id uint64, size int64) (int64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
written, err := assemble(name, tempNames)
|
written, err := assemble(name, tempNames)
|
||||||
if err != nil {
|
if err == nil && size >= 0 && written != size { // old clients like actions/cache@v2 send no size
|
||||||
return 0, err
|
err = fmt.Errorf("broken file: %v != %v", written, size)
|
||||||
}
|
}
|
||||||
// If size is less than 0, it means the size is unknown.
|
if err != nil {
|
||||||
// We can't check the size of the file, just skip the check.
|
|
||||||
// It happens when the request comes from old versions of actions, like `actions/cache@v2`.
|
|
||||||
if size >= 0 && written != size {
|
|
||||||
_ = os.Remove(name)
|
_ = os.Remove(name)
|
||||||
return 0, fmt.Errorf("broken file: %v != %v", written, size)
|
return 0, err
|
||||||
}
|
}
|
||||||
return written, nil
|
return written, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// assemble concatenates the uploaded parts into name. A single part, which is what the v2 API
|
// assemble appends the parts into the first, deleting each once copied, so it never needs twice the space.
|
||||||
// produces below the client's block threshold, is already the whole archive and is moved.
|
|
||||||
func assemble(name string, tempNames []string) (int64, error) {
|
func assemble(name string, tempNames []string) (int64, error) {
|
||||||
if len(tempNames) == 1 {
|
if len(tempNames) == 0 {
|
||||||
info, err := os.Stat(tempNames[0])
|
return 0, errors.New("nothing was uploaded")
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
return info.Size(), os.Rename(tempNames[0], name)
|
|
||||||
}
|
}
|
||||||
|
if err := os.Rename(tempNames[0], name); err != nil {
|
||||||
file, err := os.Create(name)
|
return 0, err
|
||||||
|
}
|
||||||
|
file, err := os.OpenFile(name, os.O_WRONLY|os.O_APPEND, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
for _, v := range tempNames[1:] {
|
||||||
var written int64
|
part, err := os.Open(v)
|
||||||
for _, v := range tempNames {
|
|
||||||
f, err := os.Open(v)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
n, err := io.Copy(file, f)
|
_, err = io.Copy(file, part)
|
||||||
_ = f.Close()
|
_ = part.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
written += n
|
_ = os.Remove(v)
|
||||||
}
|
}
|
||||||
return written, nil
|
info, err := file.Stat()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return info.Size(), file.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Storage) Serve(w http.ResponseWriter, r *http.Request, id uint64) {
|
func (s *Storage) Serve(w http.ResponseWriter, r *http.Request, id uint64) {
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ package common
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math/rand/v2"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
|
"time"
|
||||||
|
|
||||||
"gitea.com/gitea/runner/act/common/logging"
|
"gitea.com/gitea/runner/act/common/logging"
|
||||||
)
|
)
|
||||||
@@ -158,6 +160,28 @@ func (e Executor) IfBool(conditional bool) Executor {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RetryBackoff is the wait between Retry's attempts, random between 1 and 10 seconds like GitHub's runner.
|
||||||
|
var RetryBackoff = func() time.Duration { return time.Second + rand.N(9*time.Second) }
|
||||||
|
|
||||||
|
// Retry runs the executor up to attempts times until it succeeds.
|
||||||
|
func (e Executor) Retry(attempts int) Executor {
|
||||||
|
return func(ctx context.Context) error {
|
||||||
|
for attempt := 1; ; attempt++ {
|
||||||
|
err := e(ctx)
|
||||||
|
if err == nil || attempt == attempts || ctx.Err() != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
backoff := RetryBackoff()
|
||||||
|
Logger(ctx).Warnf("%v, retrying in %s", err, backoff.Round(time.Second))
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
return err
|
||||||
|
case <-time.After(backoff):
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Finally adds an executor to run after other executor
|
// Finally adds an executor to run after other executor
|
||||||
func (e Executor) Finally(finally Executor) Executor {
|
func (e Executor) Finally(finally Executor) Executor {
|
||||||
return func(ctx context.Context) error {
|
return func(ctx context.Context) error {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@@ -134,6 +135,31 @@ func TestExecutorConditionalsAndFinally(t *testing.T) {
|
|||||||
assert.Equal(t, []string{"if-true", "if-not", "if-bool", "main", "finally"}, calls)
|
assert.Equal(t, []string{"if-true", "if-not", "if-bool", "main", "finally"}, calls)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestExecutorRetryStopsOnSuccessOrAfterAllAttempts(t *testing.T) {
|
||||||
|
backoff := RetryBackoff
|
||||||
|
RetryBackoff = func() time.Duration { return 0 }
|
||||||
|
t.Cleanup(func() { RetryBackoff = backoff })
|
||||||
|
transient := errors.New("transient")
|
||||||
|
for _, tc := range []struct {
|
||||||
|
failures, calls int
|
||||||
|
err error
|
||||||
|
}{
|
||||||
|
{failures: 2, calls: 3},
|
||||||
|
{failures: 5, calls: 3, err: transient},
|
||||||
|
} {
|
||||||
|
var calls int
|
||||||
|
err := Executor(func(context.Context) error {
|
||||||
|
calls++
|
||||||
|
if calls <= tc.failures {
|
||||||
|
return transient
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}).Retry(3)(t.Context())
|
||||||
|
require.Equal(t, tc.err, err)
|
||||||
|
require.Equal(t, tc.calls, calls)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestExecutorFinallyReturnsFinallyErrorWithOriginal(t *testing.T) {
|
func TestExecutorFinallyReturnsFinallyErrorWithOriginal(t *testing.T) {
|
||||||
finalErr := errors.New("cleanup failed")
|
finalErr := errors.New("cleanup failed")
|
||||||
for _, mainErr := range []error{context.Canceled, nil} {
|
for _, mainErr := range []error{context.Canceled, nil} {
|
||||||
|
|||||||
+11
-6
@@ -185,6 +185,7 @@ type NewGitCloneExecutorInput struct {
|
|||||||
// For Gitea
|
// For Gitea
|
||||||
InsecureSkipTLS bool
|
InsecureSkipTLS bool
|
||||||
ClientCertFile, ClientKeyFile string // PEM, absolute as git runs in other directories
|
ClientCertFile, ClientKeyFile string // PEM, absolute as git runs in other directories
|
||||||
|
CAFile string // PEM, absolute, replaces git's CA bundle
|
||||||
Transport http.RoundTripper // for FetchAction's archive downloads, nil for http.DefaultTransport
|
Transport http.RoundTripper // for FetchAction's archive downloads, nil for http.DefaultTransport
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -389,12 +390,16 @@ func RemoteConfig(token string, insecureSkipTLS bool) []string {
|
|||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|
||||||
func ClientCertConfig(prefix, certFile, keyFile, executionOS string) []string {
|
// SSLConfig uses OpenSSL on Windows, as Schannel takes no PEM key and ignores sslCAInfo.
|
||||||
if certFile == "" {
|
func SSLConfig(prefix, certFile, keyFile, caFile, executionOS string) []string {
|
||||||
return nil
|
var config []string
|
||||||
|
if certFile != "" {
|
||||||
|
config = append(config, prefix+"sslCert="+certFile, prefix+"sslKey="+keyFile)
|
||||||
}
|
}
|
||||||
config := []string{prefix + "sslCert=" + certFile, prefix + "sslKey=" + keyFile}
|
if caFile != "" {
|
||||||
if strings.EqualFold(executionOS, "windows") {
|
config = append(config, prefix+"sslCAInfo="+caFile)
|
||||||
|
}
|
||||||
|
if config != nil && strings.EqualFold(executionOS, "windows") {
|
||||||
config = append(config, prefix+"sslBackend=openssl")
|
config = append(config, prefix+"sslBackend=openssl")
|
||||||
}
|
}
|
||||||
return config
|
return config
|
||||||
@@ -457,7 +462,7 @@ func runGitWithStdin(ctx context.Context, dir string, input *NewGitCloneExecutor
|
|||||||
config := []string{"core.autocrlf=false", "core.eol=lf"} // keep action files LF
|
config := []string{"core.autocrlf=false", "core.eol=lf"} // keep action files LF
|
||||||
if input != nil {
|
if input != nil {
|
||||||
config = append(config, RemoteConfig(input.Token, input.InsecureSkipTLS)...)
|
config = append(config, RemoteConfig(input.Token, input.InsecureSkipTLS)...)
|
||||||
config = append(config, ClientCertConfig("http.", input.ClientCertFile, input.ClientKeyFile, runtime.GOOS)...)
|
config = append(config, SSLConfig("http.", input.ClientCertFile, input.ClientKeyFile, input.CAFile, runtime.GOOS)...)
|
||||||
}
|
}
|
||||||
if dir != "" {
|
if dir != "" {
|
||||||
args = append([]string{"-C", dir}, args...)
|
args = append([]string{"-C", dir}, args...)
|
||||||
|
|||||||
@@ -54,18 +54,18 @@ func TestMain(m *testing.M) {
|
|||||||
os.Exit(code)
|
os.Exit(code)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClientCertConfig(t *testing.T) {
|
func TestSSLConfig(t *testing.T) {
|
||||||
for _, testcase := range []struct {
|
for _, testcase := range []struct {
|
||||||
prefix, certFile, executionOS string
|
prefix, certFile, caFile, executionOS string
|
||||||
expected []string
|
expected []string
|
||||||
}{
|
}{
|
||||||
{"http.", "cert.pem", "windows", []string{"http.sslCert=cert.pem", "http.sslKey=key.pem", "http.sslBackend=openssl"}},
|
{"http.https://example.com/.", "cert.pem", "ca.pem", "Windows", []string{"http.https://example.com/.sslCert=cert.pem", "http.https://example.com/.sslKey=key.pem", "http.https://example.com/.sslCAInfo=ca.pem", "http.https://example.com/.sslBackend=openssl"}},
|
||||||
{"http.https://example.com/.", "cert.pem", "Windows", []string{"http.https://example.com/.sslCert=cert.pem", "http.https://example.com/.sslKey=key.pem", "http.https://example.com/.sslBackend=openssl"}},
|
{"http.", "", "ca.pem", "windows", []string{"http.sslCAInfo=ca.pem", "http.sslBackend=openssl"}},
|
||||||
{"http.", "cert.pem", "Linux", []string{"http.sslCert=cert.pem", "http.sslKey=key.pem"}},
|
{"http.", "cert.pem", "ca.pem", "Linux", []string{"http.sslCert=cert.pem", "http.sslKey=key.pem", "http.sslCAInfo=ca.pem"}},
|
||||||
{"http.", "", "Windows", nil},
|
{"http.", "", "", "Windows", nil},
|
||||||
} {
|
} {
|
||||||
t.Run(testcase.prefix+testcase.certFile+testcase.executionOS, func(t *testing.T) {
|
t.Run(testcase.prefix+testcase.certFile+testcase.caFile+testcase.executionOS, func(t *testing.T) {
|
||||||
assert.Equal(t, testcase.expected, ClientCertConfig(testcase.prefix, testcase.certFile, "key.pem", testcase.executionOS))
|
assert.Equal(t, testcase.expected, SSLConfig(testcase.prefix, testcase.certFile, "key.pem", testcase.caFile, testcase.executionOS))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ func NewDockerBuildExecutor(input NewDockerBuildExecutorInput) common.Executor {
|
|||||||
|
|
||||||
options := client.ImageBuildOptions{
|
options := client.ImageBuildOptions{
|
||||||
Tags: []string{input.ImageTag},
|
Tags: []string{input.ImageTag},
|
||||||
|
Labels: map[string]string{"com.gitea.runner.image": input.ImageTag}, // own image ID per tag, so removing one never deletes another job's identical build
|
||||||
Remove: true,
|
Remove: true,
|
||||||
AuthConfigs: LoadDockerAuthConfigs(ctx),
|
AuthConfigs: LoadDockerAuthConfigs(ctx),
|
||||||
Dockerfile: input.Dockerfile,
|
Dockerfile: input.Dockerfile,
|
||||||
|
|||||||
@@ -18,10 +18,12 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDockerBuildReportsDaemonError(t *testing.T) {
|
func TestDockerBuildLabelsImageWithItsTagAndReportsDaemonError(t *testing.T) {
|
||||||
|
var labels string
|
||||||
daemon := httptest.NewServer(http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
|
daemon := httptest.NewServer(http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
|
||||||
writer.Header().Set("API-Version", "1.47")
|
writer.Header().Set("API-Version", "1.47")
|
||||||
if strings.HasSuffix(request.URL.Path, "/build") {
|
if strings.HasSuffix(request.URL.Path, "/build") {
|
||||||
|
labels = request.URL.Query().Get("labels")
|
||||||
writer.Header().Set("Content-Type", "application/json")
|
writer.Header().Set("Content-Type", "application/json")
|
||||||
writer.WriteHeader(http.StatusInternalServerError)
|
writer.WriteHeader(http.StatusInternalServerError)
|
||||||
_, _ = io.WriteString(writer, `{"message":"build rejected"}`)
|
_, _ = io.WriteString(writer, `{"message":"build rejected"}`)
|
||||||
@@ -35,6 +37,7 @@ func TestDockerBuildReportsDaemonError(t *testing.T) {
|
|||||||
require.ErrorContains(t, NewDockerBuildExecutor(NewDockerBuildExecutorInput{
|
require.ErrorContains(t, NewDockerBuildExecutor(NewDockerBuildExecutorInput{
|
||||||
ImageTag: "action:test", Dockerfile: "Dockerfile", BuildContext: strings.NewReader(""),
|
ImageTag: "action:test", Dockerfile: "Dockerfile", BuildContext: strings.NewReader(""),
|
||||||
})(t.Context()), "build rejected")
|
})(t.Context()), "build rejected")
|
||||||
|
require.JSONEq(t, `{"com.gitea.runner.image":"action:test"}`, labels)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCreateBuildContextFollowsDockerignoreAndSymlinkedRootButKeepsDockerfile(t *testing.T) {
|
func TestCreateBuildContextFollowsDockerignoreAndSymlinkedRootButKeepsDockerfile(t *testing.T) {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import (
|
|||||||
|
|
||||||
// NewDockerPullExecutor function to create a run executor for the container
|
// NewDockerPullExecutor function to create a run executor for the container
|
||||||
func NewDockerPullExecutor(input NewDockerPullExecutorInput) common.Executor {
|
func NewDockerPullExecutor(input NewDockerPullExecutorInput) common.Executor {
|
||||||
return func(ctx context.Context) error {
|
return common.Executor(func(ctx context.Context) error {
|
||||||
logger := common.Logger(ctx)
|
logger := common.Logger(ctx)
|
||||||
logger.Debugf("docker pull %v", input.Image)
|
logger.Debugf("docker pull %v", input.Image)
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ func NewDockerPullExecutor(input NewDockerPullExecutorInput) common.Executor {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return fmt.Errorf("failed to pull image '%s' (%s): %w", imageRef, input.Platform, err)
|
return fmt.Errorf("failed to pull image '%s' (%s): %w", imageRef, input.Platform, err)
|
||||||
}
|
}).Retry(3)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getImagePullOptions(ctx context.Context, input NewDockerPullExecutorInput) (client.ImagePullOptions, error) {
|
func getImagePullOptions(ctx context.Context, input NewDockerPullExecutorInput) (client.ImagePullOptions, error) {
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ func (e *HostEnvironment) processGroup(ctx context.Context) *process.Group {
|
|||||||
e.procGroupOnce.Do(func() {
|
e.procGroupOnce.Do(func() {
|
||||||
group, err := process.NewGroup()
|
group, err := process.NewGroup()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.Logger(ctx).Warnf("could not create the job's process group; processes a step leaves behind can only be reclaimed by the workspace scan: %v", err)
|
common.Logger(ctx).Warnf("could not create the job's process group, processes a step leaves behind may outlive the job: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
e.procGroup.Store(group)
|
e.procGroup.Store(group)
|
||||||
@@ -415,46 +415,6 @@ func removePathWithRetry(ctx context.Context, path string) error {
|
|||||||
return lastErr
|
return lastErr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *HostEnvironment) terminateRunningProcesses(ctx context.Context) {
|
|
||||||
if runtime.GOOS != "windows" {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Detached: exec.CommandContext won't start on a cancelled ctx, and a
|
|
||||||
// server cancel has already cancelled the parent ctx.
|
|
||||||
killCtx, killCancel := context.WithTimeout(context.Background(), 30*time.Second)
|
|
||||||
defer killCancel()
|
|
||||||
|
|
||||||
logger := common.Logger(ctx)
|
|
||||||
|
|
||||||
// Dirs we own; a process referencing one is a leftover. ToolCache is shared
|
|
||||||
// across jobs, and Workdir may be a caller-owned checkout.
|
|
||||||
owned := []string{e.Path, e.TmpDir}
|
|
||||||
if e.CleanWorkdir {
|
|
||||||
owned = append(owned, e.Workdir)
|
|
||||||
}
|
|
||||||
dirs := make([]string, 0, len(owned))
|
|
||||||
for _, d := range owned {
|
|
||||||
if d == "" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
abs, err := filepath.Abs(d)
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
dirs = append(dirs, abs)
|
|
||||||
}
|
|
||||||
if len(dirs) == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if killed, err := process.KillProcessesWithPaths(killCtx, dirs, e.TrackingID); err != nil {
|
|
||||||
logger.Debugf("workspace process cleanup reported errors: %v", err)
|
|
||||||
} else if killed > 0 {
|
|
||||||
logger.Debugf("terminated %d leftover workspace process(es)", killed)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// hostCleanupTimeout bounds each teardown phase so one stalled delete cannot
|
// hostCleanupTimeout bounds each teardown phase so one stalled delete cannot
|
||||||
// wedge the runner slot. A var so tests can shrink it.
|
// wedge the runner slot. A var so tests can shrink it.
|
||||||
var hostCleanupTimeout = 30 * time.Second
|
var hostCleanupTimeout = 30 * time.Second
|
||||||
@@ -463,12 +423,15 @@ func (e *HostEnvironment) Remove() common.Executor {
|
|||||||
return func(ctx context.Context) error {
|
return func(ctx context.Context) error {
|
||||||
logger := common.Logger(ctx)
|
logger := common.Logger(ctx)
|
||||||
|
|
||||||
// End lingering processes before removing the workspace; on Windows their
|
// End lingering processes before removing the workspace, on Windows their file locks block cleanup.
|
||||||
// file locks block cleanup. Closing the group is deterministic, the scan a net.
|
|
||||||
if err := e.procGroup.Load().Close(); err != nil {
|
if err := e.procGroup.Load().Close(); err != nil {
|
||||||
logger.Debugf("closing the job's process group failed: %v", err)
|
logger.Debugf("closing the job's process group failed: %v", err)
|
||||||
}
|
}
|
||||||
e.terminateRunningProcesses(ctx)
|
if killed, err := process.KillTrackedProcesses(e.TrackingID); err != nil {
|
||||||
|
logger.Debugf("killing the job's leftover processes reported errors: %v", err)
|
||||||
|
} else if killed > 0 {
|
||||||
|
logger.Debugf("killed %d leftover process(es) of the job", killed)
|
||||||
|
}
|
||||||
|
|
||||||
// Detach: a cancelled ctx would skip removePathWithRetry's retries,
|
// Detach: a cancelled ctx would skip removePathWithRetry's retries,
|
||||||
// which absorb Windows file-handle release lag after the kill above.
|
// which absorb Windows file-handle release lag after the kill above.
|
||||||
|
|||||||
@@ -4,18 +4,15 @@
|
|||||||
package container
|
package container
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
"unsafe"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"golang.org/x/sys/windows"
|
"golang.org/x/sys/windows"
|
||||||
@@ -40,7 +37,6 @@ func TestHostEnvironmentTrackingCleanup(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
env["GITEA_TRACKING_HELPER"] = "step"
|
env["GITEA_TRACKING_HELPER"] = "step"
|
||||||
env["GITEA_TRACKING_WORKSPACE"] = workspace
|
|
||||||
env["GITEA_TRACKING_ADDRESS"] = listener.Addr().String()
|
env["GITEA_TRACKING_ADDRESS"] = listener.Addr().String()
|
||||||
if tracking == "default" {
|
if tracking == "default" {
|
||||||
env["RUNNER_TRACKING_ID"] = environment.TrackingID
|
env["RUNNER_TRACKING_ID"] = environment.TrackingID
|
||||||
@@ -52,23 +48,6 @@ func TestHostEnvironmentTrackingCleanup(t *testing.T) {
|
|||||||
go func() {
|
go func() {
|
||||||
result <- environment.Exec([]string{os.Args[0], "-test.run=^TestHostTrackingHelper$"}, env, "", workspace)(ctx)
|
result <- environment.Exec([]string{os.Args[0], "-test.run=^TestHostTrackingHelper$"}, env, "", workspace)(ctx)
|
||||||
}()
|
}()
|
||||||
step, err := listener.Accept()
|
|
||||||
require.NoError(t, err)
|
|
||||||
defer step.Close()
|
|
||||||
require.NoError(t, step.SetDeadline(time.Now().Add(20*time.Second)))
|
|
||||||
var stepPID int
|
|
||||||
_, err = fmt.Fscanln(step, &stepPID)
|
|
||||||
require.NoError(t, err)
|
|
||||||
stepHandle, err := windows.OpenProcess(windows.PROCESS_QUERY_LIMITED_INFORMATION, false, uint32(stepPID))
|
|
||||||
require.NoError(t, err)
|
|
||||||
defer func() { _ = windows.CloseHandle(stepHandle) }()
|
|
||||||
require.Eventually(t, func() bool {
|
|
||||||
var assigned int32
|
|
||||||
result, _, _ := windows.NewLazySystemDLL("kernel32.dll").NewProc("IsProcessInJob").Call(uintptr(stepHandle), 0, uintptr(unsafe.Pointer(&assigned)))
|
|
||||||
return result != 0 && assigned != 0
|
|
||||||
}, 5*time.Second, 10*time.Millisecond)
|
|
||||||
_, err = step.Write([]byte{1})
|
|
||||||
require.NoError(t, err)
|
|
||||||
var helpers []windows.Handle
|
var helpers []windows.Handle
|
||||||
for range 2 {
|
for range 2 {
|
||||||
connection, err := listener.Accept()
|
connection, err := listener.Accept()
|
||||||
@@ -114,23 +93,18 @@ func TestHostTrackingHelper(t *testing.T) {
|
|||||||
if mode == "" {
|
if mode == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if mode != "descendant" {
|
||||||
|
child := exec.Command(os.Args[0], "-test.run=^TestHostTrackingHelper$")
|
||||||
|
child.Env = append(os.Environ(), "GITEA_TRACKING_HELPER="+map[string]string{"step": "helper", "helper": "descendant"}[mode])
|
||||||
|
require.NoError(t, child.Start())
|
||||||
|
if mode == "step" {
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
connection, err := net.Dial("tcp4", os.Getenv("GITEA_TRACKING_ADDRESS"))
|
connection, err := net.Dial("tcp4", os.Getenv("GITEA_TRACKING_ADDRESS"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
_, err = fmt.Fprintln(connection, os.Getpid())
|
_, err = fmt.Fprintln(connection, os.Getpid())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
if mode == "step" {
|
|
||||||
_, err := bufio.NewReader(connection).ReadByte()
|
|
||||||
require.NoError(t, err)
|
|
||||||
}
|
|
||||||
if mode != "descendant" {
|
|
||||||
child := exec.Command(os.Args[0], "-test.run=^TestHostTrackingHelper$", filepath.Join(os.Getenv("GITEA_TRACKING_WORKSPACE"), "tracking-reference"))
|
|
||||||
child.Env = append(os.Environ(), "GITEA_TRACKING_HELPER="+map[string]string{"step": "helper", "helper": "descendant"}[mode])
|
|
||||||
require.NoError(t, child.Start())
|
|
||||||
if mode == "step" {
|
|
||||||
require.NoError(t, connection.Close())
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_, err = io.Copy(io.Discard, connection)
|
_, err = io.Copy(io.Discard, connection)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, connection.Close())
|
require.NoError(t, connection.Close())
|
||||||
|
|||||||
@@ -80,9 +80,6 @@ func lookPath(file string, env map[string]string) (string, error) {
|
|||||||
return "", &Error{file, err}
|
return "", &Error{file, err}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if f, err := findExecutable(filepath.Join(".", file), exts); err == nil {
|
|
||||||
return f, nil
|
|
||||||
}
|
|
||||||
path := getenv(env, "path")
|
path := getenv(env, "path")
|
||||||
for _, dir := range filepath.SplitList(path) {
|
for _, dir := range filepath.SplitList(path) {
|
||||||
if f, err := findExecutable(filepath.Join(dir, file), exts); err == nil {
|
if f, err := findExecutable(filepath.Join(dir, file), exts); err == nil {
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
// Copyright 2026 The Gitea Authors. All rights reserved.
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
package lookpath
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestLookPath2IgnoresTheCurrentDirectory(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
|
require.NoError(t, os.WriteFile(filepath.Join(dir, "tool.exe"), nil, 0o755))
|
||||||
|
t.Chdir(dir)
|
||||||
|
_, err := LookPath2("tool", map[string]string{"PATH": t.TempDir()})
|
||||||
|
require.EqualError(t, err, ErrNotFound.Error())
|
||||||
|
}
|
||||||
+18
-22
@@ -339,34 +339,30 @@ func execAsDocker(ctx context.Context, step actionStep, actionName, actionDir, b
|
|||||||
|
|
||||||
if !correctArchExists || rc.Config.ForceRebuild {
|
if !correctArchExists || rc.Config.ForceRebuild {
|
||||||
logger.Debugf("image '%s' for architecture '%s' will be built from context '%s", image, rc.Config.ContainerArchitecture, contextDir)
|
logger.Debugf("image '%s' for architecture '%s' will be built from context '%s", image, rc.Config.ContainerArchitecture, contextDir)
|
||||||
var buildContext io.ReadCloser
|
prepImage = common.Executor(func(ctx context.Context) error {
|
||||||
if localAction {
|
input := container.NewDockerBuildExecutorInput{
|
||||||
buildContext, err = rc.JobContainer.GetContainerArchive(ctx, contextDir+"/.")
|
ContextDir: contextDir,
|
||||||
if err != nil {
|
Dockerfile: fileName,
|
||||||
return err
|
ImageTag: image,
|
||||||
|
Platform: rc.Config.ContainerArchitecture,
|
||||||
|
BuildArgs: rc.proxyBuildArgs(),
|
||||||
}
|
}
|
||||||
defer buildContext.Close()
|
if localAction {
|
||||||
}
|
buildContext, err := rc.JobContainer.GetContainerArchive(ctx, contextDir+"/.")
|
||||||
prepImage = ContainerNewDockerBuildExecutor(container.NewDockerBuildExecutorInput{
|
if err != nil {
|
||||||
ContextDir: contextDir,
|
return err
|
||||||
Dockerfile: fileName,
|
}
|
||||||
ImageTag: image,
|
defer buildContext.Close()
|
||||||
BuildContext: buildContext,
|
input.BuildContext = buildContext
|
||||||
Platform: rc.Config.ContainerArchitecture,
|
} else {
|
||||||
BuildArgs: rc.proxyBuildArgs(),
|
unlock, err := git.AcquireCloneLock(ctx, actionDir) // held across the whole build, the daemon drains contextDir lazily
|
||||||
})
|
|
||||||
if buildContext == nil {
|
|
||||||
// Held across the whole build: the daemon drains contextDir lazily.
|
|
||||||
inner := prepImage
|
|
||||||
prepImage = func(ctx context.Context) error {
|
|
||||||
unlock, err := git.AcquireCloneLock(ctx, actionDir)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer unlock()
|
defer unlock()
|
||||||
return inner(ctx)
|
|
||||||
}
|
}
|
||||||
}
|
return ContainerNewDockerBuildExecutor(input)(ctx)
|
||||||
|
}).Retry(3)
|
||||||
} else {
|
} else {
|
||||||
logger.Debugf("image '%s' for architecture '%s' already exists", image, rc.Config.ContainerArchitecture)
|
logger.Debugf("image '%s' for architecture '%s' already exists", image, rc.Config.ContainerArchitecture)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ func (rc *RunContext) runJobHook(ctx context.Context, hookPath, name string) err
|
|||||||
}
|
}
|
||||||
rawLogger.Infof("::endgroup::")
|
rawLogger.Infof("::endgroup::")
|
||||||
|
|
||||||
env := mergeMaps(rc.containerSpec.Env, rc.GetEnv())
|
env := rc.mergeEnv(rc.caEnv, rc.containerSpec.Env, rc.GetEnv())
|
||||||
rc.withGithubEnv(ctx, rc.getGithubContext(ctx), env)
|
rc.withGithubEnv(ctx, rc.getGithubContext(ctx), env)
|
||||||
rc.ApplyExtraPath(ctx, &env)
|
rc.ApplyExtraPath(ctx, &env)
|
||||||
|
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ func (c Config) withInstanceAuth(input git.NewGitCloneExecutorInput, token strin
|
|||||||
}
|
}
|
||||||
input.ClientCertFile, input.ClientKeyFile = c.ClientCertFile, c.ClientKeyFile
|
input.ClientCertFile, input.ClientKeyFile = c.ClientCertFile, c.ClientKeyFile
|
||||||
if onInstanceHost(u.Host, c.GitHubInstance) {
|
if onInstanceHost(u.Host, c.GitHubInstance) {
|
||||||
input.InsecureSkipTLS, input.Transport = c.InsecureSkipTLS, c.InstanceTransport
|
input.InsecureSkipTLS, input.CAFile, input.Transport = c.InsecureSkipTLS, c.CAFile, c.InstanceTransport
|
||||||
}
|
}
|
||||||
if u.User == nil {
|
if u.User == nil {
|
||||||
input.Token = token
|
input.Token = token
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ func TestReusableWorkflowCachedBranchRefRefreshes(t *testing.T) {
|
|||||||
|
|
||||||
func TestNewReusableWorkflowExecutorHoldsCloneLock(t *testing.T) {
|
func TestNewReusableWorkflowExecutorHoldsCloneLock(t *testing.T) {
|
||||||
workflowDir := t.TempDir()
|
workflowDir := t.TempDir()
|
||||||
require.NoError(t, os.WriteFile(filepath.Join(workflowDir, "reusable.yml"), []byte(":"), 0o644))
|
require.NoError(t, os.WriteFile(filepath.Join(workflowDir, "reusable.yml"), []byte("["), 0o644))
|
||||||
|
|
||||||
unlock, err := git.AcquireCloneLock(t.Context(), workflowDir)
|
unlock, err := git.AcquireCloneLock(t.Context(), workflowDir)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -118,7 +118,7 @@ func TestNewLocalReusableWorkflowExecutorFindsSameRepositoryPaths(t *testing.T)
|
|||||||
workdir := filepath.Join(t.TempDir(), "workspace")
|
workdir := filepath.Join(t.TempDir(), "workspace")
|
||||||
require.NoError(t, os.MkdirAll(filepath.Join(workdir, ".gitea", "workflows"), 0o755))
|
require.NoError(t, os.MkdirAll(filepath.Join(workdir, ".gitea", "workflows"), 0o755))
|
||||||
require.NoError(t, os.Mkdir(workdir+".lock", 0o755))
|
require.NoError(t, os.Mkdir(workdir+".lock", 0o755))
|
||||||
require.NoError(t, os.WriteFile(filepath.Join(workdir, ".gitea", "workflows", "reusable.yml"), []byte(":"), 0o644))
|
require.NoError(t, os.WriteFile(filepath.Join(workdir, ".gitea", "workflows", "reusable.yml"), []byte("["), 0o644))
|
||||||
|
|
||||||
for _, uses := range []string{"./.gitea/workflows/reusable.yml", "$/.gitea/workflows/reusable.yml"} {
|
for _, uses := range []string{"./.gitea/workflows/reusable.yml", "$/.gitea/workflows/reusable.yml"} {
|
||||||
rc := &RunContext{
|
rc := &RunContext{
|
||||||
@@ -130,7 +130,7 @@ func TestNewLocalReusableWorkflowExecutorFindsSameRepositoryPaths(t *testing.T)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCloneRemoteReusableWorkflowSendsInstanceTokenAndClientCert(t *testing.T) {
|
func TestCloneRemoteReusableWorkflowSendsInstanceTokenAndClientCertTrustingCA(t *testing.T) {
|
||||||
var gotCert bool
|
var gotCert bool
|
||||||
var gotToken string
|
var gotToken string
|
||||||
server := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
server := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
@@ -150,12 +150,12 @@ func TestCloneRemoteReusableWorkflowSendsInstanceTokenAndClientCert(t *testing.T
|
|||||||
require.NoError(t, os.WriteFile(keyFile, pem.EncodeToMemory(&pem.Block{Type: "PRIVATE KEY", Bytes: keyDER}), 0o600))
|
require.NoError(t, os.WriteFile(keyFile, pem.EncodeToMemory(&pem.Block{Type: "PRIVATE KEY", Bytes: keyDER}), 0o600))
|
||||||
rc := &RunContext{
|
rc := &RunContext{
|
||||||
Config: &Config{
|
Config: &Config{
|
||||||
Env: testCheckoutEnv(),
|
Env: testCheckoutEnv(),
|
||||||
GitHubInstance: server.URL,
|
GitHubInstance: server.URL,
|
||||||
Secrets: map[string]string{"GITEA_TOKEN": "token"},
|
Secrets: map[string]string{"GITEA_TOKEN": "token"},
|
||||||
InsecureSkipTLS: true,
|
ClientCertFile: certFile,
|
||||||
ClientCertFile: certFile,
|
ClientKeyFile: keyFile,
|
||||||
ClientKeyFile: keyFile,
|
CAFile: certFile,
|
||||||
},
|
},
|
||||||
Run: &model.Run{JobID: "j1", Workflow: &model.Workflow{Jobs: map[string]*model.Job{"j1": {}}}},
|
Run: &model.Run{JobID: "j1", Workflow: &model.Workflow{Jobs: map[string]*model.Job{"j1": {}}}},
|
||||||
}
|
}
|
||||||
@@ -188,11 +188,12 @@ func TestInstanceAuthAndTransportOnlyApplyToTheInstance(t *testing.T) {
|
|||||||
InsecureSkipTLS: true,
|
InsecureSkipTLS: true,
|
||||||
ClientCertFile: "/cert",
|
ClientCertFile: "/cert",
|
||||||
ClientKeyFile: "/key",
|
ClientKeyFile: "/key",
|
||||||
|
CAFile: "/ca",
|
||||||
InstanceTransport: &http.Transport{},
|
InstanceTransport: &http.Transport{},
|
||||||
}
|
}
|
||||||
want := git.NewGitCloneExecutorInput{URL: tt.cloneURL, InsecureSkipTLS: tt.insecure}
|
want := git.NewGitCloneExecutorInput{URL: tt.cloneURL, InsecureSkipTLS: tt.insecure}
|
||||||
if tt.insecure {
|
if tt.insecure {
|
||||||
want.Transport = conf.InstanceTransport
|
want.CAFile, want.Transport = conf.CAFile, conf.InstanceTransport
|
||||||
}
|
}
|
||||||
if tt.token {
|
if tt.token {
|
||||||
want.Token = "token"
|
want.Token = "token"
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ type RunContext struct {
|
|||||||
kubernetes bool
|
kubernetes bool
|
||||||
containerSpec model.ContainerSpec // container:, resolved once with platformImage
|
containerSpec model.ContainerSpec // container:, resolved once with platformImage
|
||||||
containerEnv yaml.Node // container.env of the kept containerSpec, decoded once the job env resolves
|
containerEnv yaml.Node // container.env of the kept containerSpec, decoded once the job env resolves
|
||||||
|
caEnv map[string]string // NODE_EXTRA_CA_CERTS for the runner CA, beneath any env the job and its image set
|
||||||
JobName string
|
JobName string
|
||||||
ActionPath string
|
ActionPath string
|
||||||
Parent *RunContext
|
Parent *RunContext
|
||||||
@@ -278,11 +279,37 @@ func (rc *RunContext) validVolumes() []string {
|
|||||||
if rc.dockerProxy != nil {
|
if rc.dockerProxy != nil {
|
||||||
volumes = append(volumes, rc.dockerProxy.Socket)
|
volumes = append(volumes, rc.dockerProxy.Socket)
|
||||||
}
|
}
|
||||||
|
volumes = append(volumes, rc.Config.containerVolumeSources()...)
|
||||||
// TODO: add a new configuration to control whether the docker daemon can be mounted
|
// TODO: add a new configuration to control whether the docker daemon can be mounted
|
||||||
return append(volumes, name, name+"-env",
|
return append(volumes, name, name+"-env",
|
||||||
getDockerDaemonSocketMountPath(rc.containerDaemonSocket()))
|
getDockerDaemonSocketMountPath(rc.containerDaemonSocket()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// containerVolumeSources lets workflows mount the container.volumes sources with no more access than they give.
|
||||||
|
func (c *Config) containerVolumeSources() []string {
|
||||||
|
var sources []string
|
||||||
|
for _, spec := range c.ContainerVolumes {
|
||||||
|
parsed, _ := container.ParseVolume(spec) // validated on config load
|
||||||
|
if parsed.ReadOnly {
|
||||||
|
parsed.Source += ":ro"
|
||||||
|
}
|
||||||
|
sources = append(sources, parsed.Source)
|
||||||
|
}
|
||||||
|
return sources
|
||||||
|
}
|
||||||
|
|
||||||
|
// mountVolumes sanitizes volumes and adds the container.volumes on the targets they leave unclaimed.
|
||||||
|
func (rc *RunContext) mountVolumes(ctx context.Context, validVolumes, volumes []string) ([]string, map[string]string, map[string]bool) {
|
||||||
|
binds, mounts, claimed := splitVolumes(container.SanitizeBinds(ctx, validVolumes, volumes))
|
||||||
|
for _, spec := range rc.Config.ContainerVolumes {
|
||||||
|
if parsed, _ := container.ParseVolume(spec); !claimed[parsed.Target] { // validated on config load
|
||||||
|
claimed[parsed.Target] = true
|
||||||
|
binds = append(binds, spec)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return binds, mounts, claimed
|
||||||
|
}
|
||||||
|
|
||||||
func (rc *RunContext) workdirMountRoot() string {
|
func (rc *RunContext) workdirMountRoot() string {
|
||||||
if rc.Config.PresetGitHubContext != nil {
|
if rc.Config.PresetGitHubContext != nil {
|
||||||
return filepath.Dir(filepath.Dir(rc.Config.Workdir)) // only the daemon presets, its workdir is <parent>/<owner>/<repo>
|
return filepath.Dir(filepath.Dir(rc.Config.Workdir)) // only the daemon presets, its workdir is <parent>/<owner>/<repo>
|
||||||
@@ -357,7 +384,7 @@ func (rc *RunContext) GetBindsAndMounts(ctx context.Context) ([]string, map[stri
|
|||||||
ext := container.LinuxContainerEnvironmentExtensions{}
|
ext := container.LinuxContainerEnvironmentExtensions{}
|
||||||
|
|
||||||
// the runner's own mounts below yield to the targets the job claims
|
// the runner's own mounts below yield to the targets the job claims
|
||||||
binds, mounts, claimed := splitVolumes(container.SanitizeBinds(ctx, rc.validVolumes(), rc.containerSpec.Volumes))
|
binds, mounts, claimed := rc.mountVolumes(ctx, rc.validVolumes(), rc.containerSpec.Volumes)
|
||||||
|
|
||||||
if rc.containerDaemonSocket() != "-" && !claimed["/var/run/docker.sock"] {
|
if rc.containerDaemonSocket() != "-" && !claimed["/var/run/docker.sock"] {
|
||||||
binds = append(binds, rc.jobDockerSocket()+":/var/run/docker.sock")
|
binds = append(binds, rc.jobDockerSocket()+":/var/run/docker.sock")
|
||||||
@@ -705,7 +732,12 @@ func (rc *RunContext) jobServices(ctx context.Context, networkName string) (map[
|
|||||||
entrypoint = []string{spec.Entrypoint}
|
entrypoint = []string{spec.Entrypoint}
|
||||||
}
|
}
|
||||||
|
|
||||||
serviceBinds, serviceMounts, _ := splitVolumes(spec.Volumes)
|
serviceBinds, serviceMounts, _ := splitVolumes(spec.Volumes) // as given on Kubernetes, which rejects them
|
||||||
|
validVolumes := rc.Config.ValidVolumes // not validVolumes(), a service gets no docker socket
|
||||||
|
if !rc.kubernetes {
|
||||||
|
validVolumes = append(slices.Clone(validVolumes), rc.Config.containerVolumeSources()...)
|
||||||
|
serviceBinds, serviceMounts, _ = rc.mountVolumes(ctx, validVolumes, spec.Volumes)
|
||||||
|
}
|
||||||
|
|
||||||
exposedPorts, portBindings, err := nat.ParsePortSpecs(spec.Ports)
|
exposedPorts, portBindings, err := nat.ParsePortSpecs(spec.Ports)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -734,7 +766,7 @@ func (rc *RunContext) jobServices(ctx context.Context, networkName string) (map[
|
|||||||
NetworkAliases: []string{serviceID},
|
NetworkAliases: []string{serviceID},
|
||||||
ExposedPorts: exposedPorts,
|
ExposedPorts: exposedPorts,
|
||||||
PortBindings: portBindings,
|
PortBindings: portBindings,
|
||||||
ValidVolumes: rc.Config.ValidVolumes, // not validVolumes(), a service gets no docker socket
|
ValidVolumes: validVolumes,
|
||||||
AllocatePTY: rc.Config.AllocatePTY,
|
AllocatePTY: rc.Config.AllocatePTY,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1119,10 +1151,35 @@ func (svc *serviceContainer) healthOutputSuffix() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (rc *RunContext) copyWorkflowFiles() common.Executor {
|
func (rc *RunContext) copyWorkflowFiles() common.Executor {
|
||||||
return rc.JobContainer.Copy(rc.JobContainer.GetActPath()+"/",
|
return func(ctx context.Context) error {
|
||||||
&container.FileEntry{Name: "workflow/event.json", Mode: 0o644, Body: rc.EventJSON},
|
files := []*container.FileEntry{
|
||||||
&container.FileEntry{Name: "workflow/envs.txt", Mode: 0o666},
|
{Name: "workflow/event.json", Mode: 0o644, Body: rc.EventJSON},
|
||||||
)
|
{Name: "workflow/envs.txt", Mode: 0o666},
|
||||||
|
}
|
||||||
|
if rc.Config.CAFile != "" {
|
||||||
|
ca, err := os.ReadFile(rc.Config.CAFile)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("read runner CA file: %w", err)
|
||||||
|
}
|
||||||
|
files = append(files, &container.FileEntry{Name: "ca.crt", Mode: 0o644, Body: string(ca)})
|
||||||
|
imageEnv := map[string]string{}
|
||||||
|
if err = rc.JobContainer.UpdateFromImageEnv(&imageEnv)(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if _, set := imageEnv["NODE_EXTRA_CA_CERTS"]; !set {
|
||||||
|
rc.caEnv = map[string]string{"NODE_EXTRA_CA_CERTS": rc.jobCAFile()}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rc.JobContainer.Copy(rc.JobContainer.GetActPath()+"/", files...)(ctx)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// jobCAFile is where copyWorkflowFiles puts the runner CA in the job, empty without one.
|
||||||
|
func (rc *RunContext) jobCAFile() string {
|
||||||
|
if rc.Config.CAFile == "" {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return rc.JobContainer.GetActPath() + "/ca.crt"
|
||||||
}
|
}
|
||||||
|
|
||||||
// captureJobContainerInfo is a convenience: failing to describe the container must not
|
// captureJobContainerInfo is a convenience: failing to describe the container must not
|
||||||
|
|||||||
@@ -277,25 +277,38 @@ jobs:
|
|||||||
require.Equal(t, [2]string{"", ""}, credentials["redis:latest"])
|
require.Equal(t, [2]string{"", ""}, credentials["redis:latest"])
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStartJobContainerGivesServicesTheirVolumes(t *testing.T) {
|
func TestStartJobContainerMountsWorkflowVolumesAndContainerVolumesOnUnclaimedTargets(t *testing.T) {
|
||||||
redis := startJobContainerInputs(t, `
|
const ca, certs = "/host/ca.crt:/etc/ssl/certs/ca-certificates.crt:ro", "/host/certs:/certs"
|
||||||
|
inputs := startJobContainerInputs(t, `
|
||||||
jobs:
|
jobs:
|
||||||
job:
|
job:
|
||||||
|
container:
|
||||||
|
image: node:24
|
||||||
|
volumes:
|
||||||
|
- /job/certs:/certs
|
||||||
services:
|
services:
|
||||||
redis:
|
redis:
|
||||||
image: redis:latest
|
image: redis:latest
|
||||||
volumes:
|
volumes:
|
||||||
- data:/data
|
- data:/data
|
||||||
- data:/backup
|
- data:/backup
|
||||||
`, &Config{ValidVolumes: []string{"data"}})[0]
|
- /blocked/ca.crt:/etc/ssl/certs/ca-certificates.crt:ro
|
||||||
|
- blocked:/certs
|
||||||
|
`, &Config{ValidVolumes: []string{"data", "/job/certs"}, ContainerVolumes: []string{ca, certs}})
|
||||||
|
require.Len(t, inputs, 2)
|
||||||
|
redis, job := inputs[0], inputs[1]
|
||||||
|
|
||||||
require.Equal(t, "redis:latest", redis.Image)
|
require.Equal(t, "redis:latest", redis.Image)
|
||||||
require.Equal(t, []string{"data"}, redis.ValidVolumes)
|
require.Equal(t, []string{"data", "/job/certs", "/host/ca.crt:ro", "/host/certs"}, redis.ValidVolumes)
|
||||||
require.Equal(t, map[string]string{"data": "/data"}, redis.Mounts)
|
require.Equal(t, map[string]string{"data": "/data"}, redis.Mounts)
|
||||||
require.Equal(t, []string{"data:/backup"}, redis.Binds)
|
require.Equal(t, []string{"data:/backup", ca, certs}, redis.Binds)
|
||||||
require.Empty(t, redis.WorkingDir)
|
require.Empty(t, redis.WorkingDir)
|
||||||
require.Nil(t, redis.Entrypoint)
|
require.Nil(t, redis.Entrypoint)
|
||||||
require.Nil(t, redis.Cmd)
|
require.Nil(t, redis.Cmd)
|
||||||
|
assert.Subset(t, job.Binds, []string{"/job/certs:/certs", ca})
|
||||||
|
assert.NotContains(t, job.Binds, certs)
|
||||||
|
assert.Subset(t, job.ValidVolumes, []string{"/job/certs", "/host/ca.crt:ro", "/host/certs"})
|
||||||
|
assert.NotContains(t, job.ValidVolumes, "/host/ca.crt", "a workflow must not mount a read-only source writable")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStartJobContainerBuildsEvaluatedJobAndServiceInputs(t *testing.T) {
|
func TestStartJobContainerBuildsEvaluatedJobAndServiceInputs(t *testing.T) {
|
||||||
@@ -304,7 +317,7 @@ jobs:
|
|||||||
job:
|
job:
|
||||||
container: ${{ fromJSON('{"image":"docker://node:20","options":"--label ${{ github.job }}","credentials":{"username":"user","password":"${{ vars.TITLE }}"}}') }}
|
container: ${{ fromJSON('{"image":"docker://node:20","options":"--label ${{ github.job }}","credentials":{"username":"user","password":"${{ vars.TITLE }}"}}') }}
|
||||||
services: ${{ fromJSON('{"redis":{"image":"docker://redis:latest","volumes":["data:/data"],"env":{"TITLE":"${{ github.job }}"},"credentials":{"username":"user","password":"${{ github.job }}"},"entrypoint":"/entry.sh","command":"redis-server --port 6380"}}') }}
|
services: ${{ fromJSON('{"redis":{"image":"docker://redis:latest","volumes":["data:/data"],"env":{"TITLE":"${{ github.job }}"},"credentials":{"username":"user","password":"${{ github.job }}"},"entrypoint":"/entry.sh","command":"redis-server --port 6380"}}') }}
|
||||||
`, &Config{})
|
`, &Config{ValidVolumes: []string{"data"}})
|
||||||
redis, job := inputs[0], inputs[1]
|
redis, job := inputs[0], inputs[1]
|
||||||
|
|
||||||
require.Equal(t, "redis:latest", redis.Image)
|
require.Equal(t, "redis:latest", redis.Image)
|
||||||
@@ -1450,6 +1463,43 @@ func TestGetJobContextReportsContainers(t *testing.T) {
|
|||||||
}, jobContext.Services)
|
}, jobContext.Services)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type imageEnvContainer struct {
|
||||||
|
*container.HostEnvironment
|
||||||
|
imageEnv map[string]string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c imageEnvContainer) UpdateFromImageEnv(env *map[string]string) common.Executor {
|
||||||
|
return func(_ctx context.Context) error { maps.Copy(*env, c.imageEnv); return nil }
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCopyWorkflowFilesHandsNodeTheRunnerCAUnlessTheJobOrImageSetsIt(t *testing.T) {
|
||||||
|
caFile, actPath := filepath.Join(t.TempDir(), "ca.crt"), t.TempDir()
|
||||||
|
require.NoError(t, os.WriteFile(caFile, []byte("PEM\n"), 0o600))
|
||||||
|
own := map[string]string{"NODE_EXTRA_CA_CERTS": "/own.pem"}
|
||||||
|
stepEnv := func(caFile string, jobEnv, containerEnv, imageEnv map[string]string) map[string]string {
|
||||||
|
rc := &RunContext{
|
||||||
|
Config: &Config{CAFile: caFile},
|
||||||
|
Run: &model.Run{JobID: "job", Workflow: &model.Workflow{Jobs: map[string]*model.Job{"job": {}}}},
|
||||||
|
Env: maps.Clone(jobEnv),
|
||||||
|
JobContainer: imageEnvContainer{&container.HostEnvironment{Path: t.TempDir(), ActPath: actPath, StdOut: io.Discard}, imageEnv},
|
||||||
|
}
|
||||||
|
rc.containerSpec.Env = containerEnv
|
||||||
|
require.NoError(t, rc.copyWorkflowFiles()(t.Context()))
|
||||||
|
env := map[string]string{}
|
||||||
|
require.NoError(t, setupEnv(t.Context(), &stepRun{RunContext: rc, Step: &model.Step{}, env: env}))
|
||||||
|
return env
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.Equal(t, actPath+"/ca.crt", stepEnv(caFile, nil, nil, nil)["NODE_EXTRA_CA_CERTS"])
|
||||||
|
ca, err := os.ReadFile(filepath.Join(actPath, "ca.crt"))
|
||||||
|
require.NoError(t, err)
|
||||||
|
assert.Equal(t, "PEM\n", string(ca))
|
||||||
|
assert.Equal(t, "/own.pem", stepEnv(caFile, own, nil, nil)["NODE_EXTRA_CA_CERTS"])
|
||||||
|
assert.Equal(t, "/own.pem", stepEnv(caFile, nil, own, nil)["NODE_EXTRA_CA_CERTS"])
|
||||||
|
assert.NotContains(t, stepEnv(caFile, nil, nil, own), "NODE_EXTRA_CA_CERTS")
|
||||||
|
assert.NotContains(t, stepEnv("", nil, nil, nil), "NODE_EXTRA_CA_CERTS")
|
||||||
|
}
|
||||||
|
|
||||||
func TestCaptureJobContainerInfoExportsDockerWorkspace(t *testing.T) {
|
func TestCaptureJobContainerInfoExportsDockerWorkspace(t *testing.T) {
|
||||||
workdir := t.TempDir()
|
workdir := t.TempDir()
|
||||||
job := &containerMock{}
|
job := &containerMock{}
|
||||||
|
|||||||
@@ -83,9 +83,11 @@ type Config struct {
|
|||||||
InstanceTransport http.RoundTripper
|
InstanceTransport http.RoundTripper
|
||||||
JobLoggerLevel *logging.Level // the level of job logger
|
JobLoggerLevel *logging.Level // the level of job logger
|
||||||
ValidVolumes []string // only volumes (and bind mounts) in this slice can be mounted on the job container or service containers
|
ValidVolumes []string // only volumes (and bind mounts) in this slice can be mounted on the job container or service containers
|
||||||
|
ContainerVolumes []string // mounted into every job, service and docker action container
|
||||||
SharedToolCache bool // one tool cache for all jobs instead of one per job
|
SharedToolCache bool // one tool cache for all jobs instead of one per job
|
||||||
InsecureSkipTLS bool // whether to skip verifying TLS certificate of the Gitea instance
|
InsecureSkipTLS bool // whether to skip verifying TLS certificate of the Gitea instance
|
||||||
ClientCertFile, ClientKeyFile string // PEM client certificate for the Gitea instance
|
ClientCertFile, ClientKeyFile string // PEM client certificate for the Gitea instance
|
||||||
|
CAFile string // PEM CA certificates the Gitea instance's certificate chains to
|
||||||
MaxParallel int // max parallel jobs to run across all workflows (0 = no limit, uses CPU count)
|
MaxParallel int // max parallel jobs to run across all workflows (0 = no limit, uses CPU count)
|
||||||
AllocatePTY bool // allocate a pseudo-TTY for each step's process
|
AllocatePTY bool // allocate a pseudo-TTY for each step's process
|
||||||
ServiceReadyTimeout time.Duration // how long a job waits for its service containers to report healthy (0 uses the default)
|
ServiceReadyTimeout time.Duration // how long a job waits for its service containers to report healthy (0 uses the default)
|
||||||
|
|||||||
+1
-1
@@ -263,7 +263,7 @@ func setupEnv(ctx context.Context, step step) error {
|
|||||||
|
|
||||||
env := step.getEnv()
|
env := step.getEnv()
|
||||||
// container env is the image's baseline, which job env and $GITHUB_ENV override
|
// container env is the image's baseline, which job env and $GITHUB_ENV override
|
||||||
mergeIntoMap(step, env, rc.containerSpec.Env, rc.GetEnv())
|
mergeIntoMap(step, env, rc.caEnv, rc.containerSpec.Env, rc.GetEnv())
|
||||||
rc.withGithubEnv(ctx, getStepGithubContext(ctx, step), *env)
|
rc.withGithubEnv(ctx, getStepGithubContext(ctx, step), *env)
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ func (sab *stepActionBuiltin) main() common.Executor {
|
|||||||
InsecureSkipTLS: rc.Config.InsecureSkipTLS,
|
InsecureSkipTLS: rc.Config.InsecureSkipTLS,
|
||||||
ClientCertFile: rc.Config.ClientCertFile,
|
ClientCertFile: rc.Config.ClientCertFile,
|
||||||
ClientKeyFile: rc.Config.ClientKeyFile,
|
ClientKeyFile: rc.Config.ClientKeyFile,
|
||||||
|
CAFile: rc.jobCAFile(),
|
||||||
Env: sab.env,
|
Env: sab.env,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ type stepFactoryImpl struct{}
|
|||||||
func (sf *stepFactoryImpl) newStep(stepModel *model.Step, rc *RunContext) (step, error) {
|
func (sf *stepFactoryImpl) newStep(stepModel *model.Step, rc *RunContext) (step, error) {
|
||||||
switch stepModel.Type() {
|
switch stepModel.Type() {
|
||||||
case model.StepTypeInvalid:
|
case model.StepTypeInvalid:
|
||||||
return nil, fmt.Errorf("invalid run/uses syntax for job:%s step:%+v", rc.Run, stepModel)
|
return nil, fmt.Errorf("invalid run/uses syntax for job:%s step:%+v", rc.Name, stepModel)
|
||||||
case model.StepTypeRun:
|
case model.StepTypeRun:
|
||||||
return &stepRun{
|
return &stepRun{
|
||||||
Step: stepModel,
|
Step: stepModel,
|
||||||
@@ -40,7 +40,7 @@ func (sf *stepFactoryImpl) newStep(stepModel *model.Step, rc *RunContext) (step,
|
|||||||
run, ok := builtinActions[name]
|
run, ok := builtinActions[name]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("unknown built-in action %q (known: %v) for job:%s step:%+v",
|
return nil, fmt.Errorf("unknown built-in action %q (known: %v) for job:%s step:%+v",
|
||||||
name, slices.Sorted(maps.Keys(builtinActions)), rc.Run, stepModel)
|
name, slices.Sorted(maps.Keys(builtinActions)), rc.Name, stepModel)
|
||||||
}
|
}
|
||||||
return &stepActionBuiltin{
|
return &stepActionBuiltin{
|
||||||
Step: stepModel,
|
Step: stepModel,
|
||||||
@@ -61,5 +61,5 @@ func (sf *stepFactoryImpl) newStep(stepModel *model.Step, rc *RunContext) (step,
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, fmt.Errorf("unable to determine how to run job:%s step:%+v", rc.Run, stepModel)
|
return nil, fmt.Errorf("unable to determine how to run job:%s step:%+v", rc.Name, stepModel)
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@ func TestStepFactoryInvalidStep(t *testing.T) {
|
|||||||
{Uses: "remote/action@v1", Run: "cmd"},
|
{Uses: "remote/action@v1", Run: "cmd"},
|
||||||
{Uses: "builtin:unknown"},
|
{Uses: "builtin:unknown"},
|
||||||
} {
|
} {
|
||||||
_, err := (&stepFactoryImpl{}).newStep(stepModel, &RunContext{})
|
_, err := (&stepFactoryImpl{}).newStep(stepModel, &RunContext{Name: "build"})
|
||||||
assert.Error(t, err, stepModel.Uses)
|
assert.ErrorContains(t, err, "job:build ", stepModel.Uses)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,6 +34,6 @@ Works like `actions/checkout` with these inputs. Any other input fails the step.
|
|||||||
|
|
||||||
A branch is checked out as a local branch tracking `origin`, a tag or commit as a detached `HEAD`. A triggering tag that moved since the event fails the step. The step outputs `ref` and `commit` like `actions/checkout`.
|
A branch is checked out as a local branch tracking `origin`, a tag or commit as a detached `HEAD`. A triggering tag that moved since the event fails the step. The step outputs `ref` and `commit` like `actions/checkout`.
|
||||||
|
|
||||||
Persisted credentials end with the job. `token` is only sent to `github.server_url`, while `ssh-key` is offered to any SSH host, as with `actions/checkout`. The runner's `client_cert_file` is only offered to `github.server_url` and only during the step, so later steps do not get it. Without `ssh-key`, submodule URLs of the form `git@<server host>:` are fetched from `github.server_url` with `token`. With `ssh-key`, the repository is fetched from the SSH URL in the event's `repository.ssh_url`, or from the server's host on port 22.
|
Persisted credentials end with the job. `token` is only sent to `github.server_url`, while `ssh-key` is offered to any SSH host, as with `actions/checkout`. The runner's `client_cert_file` is only offered to `github.server_url` and only during the step, so later steps do not get it. Its `ca_file` replaces the job image's CA bundle for `github.server_url`, in later steps too when credentials persist. Without `ssh-key`, submodule URLs of the form `git@<server host>:` are fetched from `github.server_url` with `token`. With `ssh-key`, the repository is fetched from the SSH URL in the event's `repository.ssh_url`, or from the server's host on port 22.
|
||||||
|
|
||||||
With `gitea-runner exec`, checking out the workflow's own repository copies your local working directory, unless `--no-skip-checkout` or `ssh-key` is set.
|
With `gitea-runner exec`, checking out the workflow's own repository copies your local working directory, unless `--no-skip-checkout` or `ssh-key` is set.
|
||||||
+4
-4
@@ -1,6 +1,6 @@
|
|||||||
# Host-mode background processes on Windows
|
# Host-mode background processes
|
||||||
|
|
||||||
Windows host jobs clean up background step processes at job completion. A step can opt out:
|
Host jobs clean up background step processes at job completion. A step can opt out:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
@@ -10,8 +10,8 @@ steps:
|
|||||||
run: Start-Process vendor-helper.exe
|
run: Start-Process vendor-helper.exe
|
||||||
```
|
```
|
||||||
|
|
||||||
- Set the `RUNNER_TRACKING_ID` override in the step's `env` before it starts. Any value different from the job's ID opts out, including an empty string.
|
- Set the `RUNNER_TRACKING_ID` override in the step's `env` before it starts. Any value different from the job's ID opts out, including an empty string. On Linux and macOS a script can also set it before starting a process.
|
||||||
- Opted-out processes and descendants that inherit the override survive normal job cleanup, including workspace process sweeps and expired output waits. Detach helper output because the runner closes leftover output pipes after a bounded wait.
|
- Opted-out processes and descendants that inherit the override survive normal job cleanup and expired output waits. Detach helper output because the runner closes leftover output pipes after a bounded wait.
|
||||||
- Cancelling or timing out an active step still terminates its process tree.
|
- Cancelling or timing out an active step still terminates its process tree.
|
||||||
- The override does not preserve workspace or temporary files. Store persistent helper files outside those directories and arrange the helper's eventual shutdown.
|
- The override does not preserve workspace or temporary files. Store persistent helper files outside those directories and arrange the helper's eventual shutdown.
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -109,4 +109,4 @@ Services share the pod's network, so a step reaches one by its id or `localhost`
|
|||||||
|
|
||||||
## Unsupported
|
## Unsupported
|
||||||
|
|
||||||
Docker actions, `docker://` steps, and the `options`, `volumes` and `credentials` of the job container fail the job, as do `volumes` and `credentials` of services. Run such workflows on a [Docker in Docker](../examples/kubernetes/README.md) runner. Pull private images with `imagePullSecrets` in `pod_template`.
|
Docker actions, `docker://` steps, and the `options`, `volumes` and `credentials` of the job container fail the job, as do `volumes` and `credentials` of services. Run such workflows on a [Docker in Docker](../examples/kubernetes/README.md) runner. Pull private images with `imagePullSecrets` in `pod_template`, and mount what `container.volumes` would through its `volumes`.
|
||||||
@@ -8,7 +8,7 @@ docker run --privileged \
|
|||||||
-e GITEA_RUNNER_REGISTRATION_TOKEN=<runner_token> \
|
-e GITEA_RUNNER_REGISTRATION_TOKEN=<runner_token> \
|
||||||
-v "$PWD/data:/data" \
|
-v "$PWD/data:/data" \
|
||||||
-v runner-docker:/var/lib/docker \
|
-v runner-docker:/var/lib/docker \
|
||||||
--name my_runner gitea/runner:nightly-dind
|
--name my_runner gitea/runner:latest-dind
|
||||||
```
|
```
|
||||||
|
|
||||||
The volumes keep the runner's registration and the job image cache. See [image flavours](../../README.md#image-flavours) for alternatives.
|
The volumes keep the runner's registration and the job image cache. See [image flavours](../../README.md#image-flavours) for alternatives.
|
||||||
@@ -85,7 +85,7 @@ spec:
|
|||||||
restartPolicy: Always
|
restartPolicy: Always
|
||||||
containers:
|
containers:
|
||||||
- name: runner
|
- name: runner
|
||||||
image: gitea/runner:nightly
|
image: gitea/runner:latest
|
||||||
env:
|
env:
|
||||||
- name: GITEA_INSTANCE_URL
|
- name: GITEA_INSTANCE_URL
|
||||||
value: http://gitea-http.gitea.svc.cluster.local:3000
|
value: http://gitea-http.gitea.svc.cluster.local:3000
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ spec:
|
|||||||
terminationGracePeriodSeconds: 10800 # keep above runner.shutdown_timeout, see README
|
terminationGracePeriodSeconds: 10800 # keep above runner.shutdown_timeout, see README
|
||||||
containers:
|
containers:
|
||||||
- name: runner
|
- name: runner
|
||||||
image: gitea/runner:nightly
|
image: gitea/runner:latest
|
||||||
env:
|
env:
|
||||||
- name: GITEA_INSTANCE_URL
|
- name: GITEA_INSTANCE_URL
|
||||||
value: http://gitea-http.gitea.svc.cluster.local:3000
|
value: http://gitea-http.gitea.svc.cluster.local:3000
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ spec:
|
|||||||
fsGroup: 1000
|
fsGroup: 1000
|
||||||
containers:
|
containers:
|
||||||
- name: runner
|
- name: runner
|
||||||
image: gitea/runner:nightly-dind-rootless
|
image: gitea/runner:latest-dind-rootless
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
env:
|
env:
|
||||||
- name: DOCKER_HOST
|
- name: DOCKER_HOST
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ spec:
|
|||||||
restartPolicy: Always
|
restartPolicy: Always
|
||||||
containers:
|
containers:
|
||||||
- name: runner
|
- name: runner
|
||||||
image: gitea/runner:nightly
|
image: gitea/runner:latest
|
||||||
env:
|
env:
|
||||||
- name: GITEA_INSTANCE_URL
|
- name: GITEA_INSTANCE_URL
|
||||||
value: http://gitea-http.gitea.svc.cluster.local:3000
|
value: http://gitea-http.gitea.svc.cluster.local:3000
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ toolchain go1.27.3
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
connectrpc.com/connect/v2 v2.0.2
|
connectrpc.com/connect/v2 v2.0.2
|
||||||
gitea.dev/actionslib v1.5.1
|
gitea.dev/actionslib v1.5.2
|
||||||
github.com/bmatcuk/doublestar/v4 v4.10.4
|
github.com/bmatcuk/doublestar/v4 v4.10.4
|
||||||
github.com/coder/websocket v1.8.15
|
github.com/coder/websocket v1.8.15
|
||||||
github.com/containerd/errdefs v1.0.0
|
github.com/containerd/errdefs v1.0.0
|
||||||
@@ -32,7 +32,7 @@ require (
|
|||||||
go.opentelemetry.io/otel/sdk v1.47.0
|
go.opentelemetry.io/otel/sdk v1.47.0
|
||||||
go.opentelemetry.io/otel/trace v1.47.0
|
go.opentelemetry.io/otel/trace v1.47.0
|
||||||
go.opentelemetry.io/proto/otlp v1.11.1
|
go.opentelemetry.io/proto/otlp v1.11.1
|
||||||
go.yaml.in/yaml/v4 v4.0.0-rc.6.0.20261013184558-04dd63131525
|
go.yaml.in/yaml/v4 v4.0.0
|
||||||
golang.org/x/net v0.62.0
|
golang.org/x/net v0.62.0
|
||||||
golang.org/x/sync v0.24.0
|
golang.org/x/sync v0.24.0
|
||||||
golang.org/x/sys v0.49.0
|
golang.org/x/sys v0.49.0
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
connectrpc.com/connect/v2 v2.0.2 h1:PoPDmOlhc46elsuCdKCKTxjNBb3HJlKF+s/sP2oucPw=
|
connectrpc.com/connect/v2 v2.0.2 h1:PoPDmOlhc46elsuCdKCKTxjNBb3HJlKF+s/sP2oucPw=
|
||||||
connectrpc.com/connect/v2 v2.0.2/go.mod h1:N32OLrstcPUzkykFynnefFro3+xzSdOrZlK2jHmS/xo=
|
connectrpc.com/connect/v2 v2.0.2/go.mod h1:N32OLrstcPUzkykFynnefFro3+xzSdOrZlK2jHmS/xo=
|
||||||
gitea.dev/actionslib v1.5.1 h1:QVOaENNWx4EFRlZvrWmMTKaKLbaqxdlhWLtsI4kf2v8=
|
gitea.dev/actionslib v1.5.2 h1:PSSUd+4jIjI+ycqo62+BRgAWkBnzjgeGQAcI3ZqH7LY=
|
||||||
gitea.dev/actionslib v1.5.1/go.mod h1:C9wmOFgDBCXyRvg4A3KTX8Vszs8v9+elH4QLGVDolqU=
|
gitea.dev/actionslib v1.5.2/go.mod h1:i8wUQMnvGwT13f2re2ZTMCFL/TyauQLeOb1L4ngjtPk=
|
||||||
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
|
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
|
||||||
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
|
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
|
||||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||||
@@ -109,8 +109,8 @@ go.yaml.in/yaml/v2 v2.4.4/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ=
|
|||||||
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
||||||
go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw=
|
go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw=
|
||||||
go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
|
go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
|
||||||
go.yaml.in/yaml/v4 v4.0.0-rc.6.0.20261013184558-04dd63131525 h1:FtzHH3s777Nx50YcPAcodAPm1mNakc228nMYbr3f+90=
|
go.yaml.in/yaml/v4 v4.0.0 h1:/LG1pNO84Z4l603j/xMn69CcS5OYhMQ/f7l2LoQUGuw=
|
||||||
go.yaml.in/yaml/v4 v4.0.0-rc.6.0.20261013184558-04dd63131525/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0=
|
go.yaml.in/yaml/v4 v4.0.0/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0=
|
||||||
golang.org/x/net v0.62.0 h1:18ELalfM5+XNRwzM2nYqXsZQ9ByS1uhj2O/U7+5jqRY=
|
golang.org/x/net v0.62.0 h1:18ELalfM5+XNRwzM2nYqXsZQ9ByS1uhj2O/U7+5jqRY=
|
||||||
golang.org/x/net v0.62.0/go.mod h1:WgDCOTH8iwtB66T4/GfI94AHo/hhdb7Hah9NDseQfiI=
|
golang.org/x/net v0.62.0/go.mod h1:WgDCOTH8iwtB66T4/GfI94AHo/hhdb7Hah9NDseQfiI=
|
||||||
golang.org/x/sync v0.24.0 h1:iqiDrGoDgyuvAKrhLQthUEzU/R378N78gXbBjxed7oA=
|
golang.org/x/sync v0.24.0 h1:iqiDrGoDgyuvAKrhLQthUEzU/R378N78gXbBjxed7oA=
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
"encoding/json/v2"
|
"encoding/json/v2"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"maps"
|
"maps"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
@@ -228,7 +229,7 @@ func (i *executeArgs) resolve(path string) string {
|
|||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
|
|
||||||
func printList(plan *model.Plan) {
|
func printList(out io.Writer, plan *model.Plan) {
|
||||||
type lineInfoDef struct {
|
type lineInfoDef struct {
|
||||||
jobID string
|
jobID string
|
||||||
jobName string
|
jobName string
|
||||||
@@ -288,7 +289,7 @@ func printList(plan *model.Plan) {
|
|||||||
wfNameMaxWidth += 2
|
wfNameMaxWidth += 2
|
||||||
wfFileMaxWidth += 2
|
wfFileMaxWidth += 2
|
||||||
|
|
||||||
fmt.Printf("%*s%*s%*s%*s%*s%*s\n",
|
fmt.Fprintf(out, "%*s%*s%*s%*s%*s%*s\n",
|
||||||
-stageMaxWidth, header.stage,
|
-stageMaxWidth, header.stage,
|
||||||
-jobIDMaxWidth, header.jobID,
|
-jobIDMaxWidth, header.jobID,
|
||||||
-jobNameMaxWidth, header.jobName,
|
-jobNameMaxWidth, header.jobName,
|
||||||
@@ -297,7 +298,7 @@ func printList(plan *model.Plan) {
|
|||||||
-eventsMaxWidth, header.events,
|
-eventsMaxWidth, header.events,
|
||||||
)
|
)
|
||||||
for _, line := range lineInfos {
|
for _, line := range lineInfos {
|
||||||
fmt.Printf("%*s%*s%*s%*s%*s%*s\n",
|
fmt.Fprintf(out, "%*s%*s%*s%*s%*s%*s\n",
|
||||||
-stageMaxWidth, line.stage,
|
-stageMaxWidth, line.stage,
|
||||||
-jobIDMaxWidth, line.jobID,
|
-jobIDMaxWidth, line.jobID,
|
||||||
-jobNameMaxWidth, line.jobName,
|
-jobNameMaxWidth, line.jobName,
|
||||||
@@ -307,11 +308,11 @@ func printList(plan *model.Plan) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
if duplicateJobIDs {
|
if duplicateJobIDs {
|
||||||
fmt.Print("\nDetected multiple jobs with the same job name, use `-W` to specify the path to the specific workflow.\n")
|
fmt.Fprint(out, "\nDetected multiple jobs with the same job name, use `-W` to specify the path to the specific workflow.\n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func runExecList(planner model.WorkflowPlanner, execArgs *executeArgs) error {
|
func runExecList(out io.Writer, planner model.WorkflowPlanner, execArgs *executeArgs) error {
|
||||||
// plan with filtered jobs - to be used for filtering only
|
// plan with filtered jobs - to be used for filtering only
|
||||||
var filterPlan *model.Plan
|
var filterPlan *model.Plan
|
||||||
|
|
||||||
@@ -347,7 +348,7 @@ func runExecList(planner model.WorkflowPlanner, execArgs *executeArgs) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
printList(filterPlan)
|
printList(out, filterPlan)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -405,7 +406,7 @@ func runExec(ctx context.Context, execArgs *executeArgs) func(cmd *cobra.Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
if execArgs.runList {
|
if execArgs.runList {
|
||||||
return runExecList(planner, execArgs)
|
return runExecList(cmd.OutOrStdout(), planner, execArgs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// plan with triggered jobs
|
// plan with triggered jobs
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -182,19 +181,18 @@ func TestRunExecListUsesJobEventAndAllPlans(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
out := captureStdout(t, func() {
|
var out bytes.Buffer
|
||||||
require.NoError(t, runExecList(planner, &executeArgs{job: "build"}))
|
require.NoError(t, runExecList(&out, planner, &executeArgs{job: "build"}))
|
||||||
require.NoError(t, runExecList(planner, &executeArgs{event: "push"}))
|
require.NoError(t, runExecList(&out, planner, &executeArgs{event: "push"}))
|
||||||
require.NoError(t, runExecList(planner, &executeArgs{autodetectEvent: true}))
|
require.NoError(t, runExecList(&out, planner, &executeArgs{autodetectEvent: true}))
|
||||||
require.NoError(t, runExecList(planner, &executeArgs{}))
|
require.NoError(t, runExecList(&out, planner, &executeArgs{}))
|
||||||
emptyPlanner, err := model.NewWorkflowPlanner(t.TempDir(), false)
|
emptyPlanner, err := model.NewWorkflowPlanner(t.TempDir(), false)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, runExecList(emptyPlanner, &executeArgs{autodetectEvent: true}))
|
require.NoError(t, runExecList(&out, emptyPlanner, &executeArgs{autodetectEvent: true}))
|
||||||
})
|
|
||||||
|
|
||||||
require.Contains(t, out, "Build")
|
require.Contains(t, out.String(), "Build")
|
||||||
require.Contains(t, out, "Test")
|
require.Contains(t, out.String(), "Test")
|
||||||
require.Contains(t, out, "Lint")
|
require.Contains(t, out.String(), "Lint")
|
||||||
require.Equal(t, []string{"job:build", "event:push", "event:push", "all"}, planner.calls)
|
require.Equal(t, []string{"job:build", "event:push", "event:push", "all"}, planner.calls)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,14 +206,13 @@ func TestPrintListReportsDuplicateJobIDs(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}}}
|
}}}
|
||||||
|
|
||||||
out := captureStdout(t, func() {
|
var out bytes.Buffer
|
||||||
printList(plan)
|
printList(&out, plan)
|
||||||
})
|
|
||||||
|
|
||||||
require.Contains(t, out, "Workflow file")
|
require.Contains(t, out.String(), "Workflow file")
|
||||||
require.Contains(t, out, "Build A")
|
require.Contains(t, out.String(), "Build A")
|
||||||
require.Contains(t, out, "Build B")
|
require.Contains(t, out.String(), "Build B")
|
||||||
require.Contains(t, out, "Detected multiple jobs with the same job name")
|
require.Contains(t, out.String(), "Detected multiple jobs with the same job name")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLoadExecCmdDefinesExpectedFlags(t *testing.T) {
|
func TestLoadExecCmdDefinesExpectedFlags(t *testing.T) {
|
||||||
@@ -293,26 +290,6 @@ func rawOnNode(event string) yaml.Node {
|
|||||||
return *node.Content[0]
|
return *node.Content[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
func captureStdout(t *testing.T, fn func()) string {
|
|
||||||
t.Helper()
|
|
||||||
|
|
||||||
old := os.Stdout
|
|
||||||
r, w, err := os.Pipe()
|
|
||||||
require.NoError(t, err)
|
|
||||||
os.Stdout = w
|
|
||||||
|
|
||||||
fn()
|
|
||||||
|
|
||||||
require.NoError(t, w.Close())
|
|
||||||
os.Stdout = old
|
|
||||||
|
|
||||||
var buf bytes.Buffer
|
|
||||||
_, err = io.Copy(&buf, r)
|
|
||||||
require.NoError(t, err)
|
|
||||||
require.NoError(t, r.Close())
|
|
||||||
return buf.String()
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestExecuteArgsLoadEnvsResultsOrigin(t *testing.T) {
|
func TestExecuteArgsLoadEnvsResultsOrigin(t *testing.T) {
|
||||||
t.Setenv("ACTIONS_RESULTS_URL", "") // the default is only supplied when nothing else does
|
t.Setenv("ACTIONS_RESULTS_URL", "") // the default is only supplied when nothing else does
|
||||||
handler, err := artifactcache.StartHandler(artifactcache.Options{Dir: t.TempDir(), OutboundIP: "127.0.0.1"})
|
handler, err := artifactcache.StartHandler(artifactcache.Options{Dir: t.TempDir(), OutboundIP: "127.0.0.1"})
|
||||||
|
|||||||
@@ -98,18 +98,20 @@ func NewRunner(cfg *config.Config, reg *config.Registration, cli client.Client)
|
|||||||
}
|
}
|
||||||
envs := make(map[string]string, len(cfg.Runner.Envs))
|
envs := make(map[string]string, len(cfg.Runner.Envs))
|
||||||
maps.Copy(envs, cfg.Runner.Envs)
|
maps.Copy(envs, cfg.Runner.Envs)
|
||||||
|
instanceTransport := client.NewTransport(cli.Address(), cfg.Runner.TLSConfig())
|
||||||
var cacheHandler *artifactcache.Handler
|
var cacheHandler *artifactcache.Handler
|
||||||
if cfg.Cache.Enabled == nil || *cfg.Cache.Enabled {
|
if cfg.Cache.Enabled == nil || *cfg.Cache.Enabled {
|
||||||
warnIgnoredCachePolicy(cfg)
|
warnIgnoredCachePolicy(cfg)
|
||||||
warnIgnoredCacheSecret(cfg)
|
warnIgnoredCacheSecret(cfg)
|
||||||
handler, err := artifactcache.StartHandler(artifactcache.Options{
|
handler, err := artifactcache.StartHandler(artifactcache.Options{
|
||||||
Dir: cfg.Cache.Dir,
|
Dir: cfg.Cache.Dir,
|
||||||
OutboundIP: cfg.Cache.Host,
|
OutboundIP: cfg.Cache.Host,
|
||||||
Port: cfg.Cache.Port,
|
Port: cfg.Cache.Port,
|
||||||
Upstream: cfg.Cache.ExternalServer,
|
Upstream: cfg.Cache.ExternalServer,
|
||||||
S3: cacheS3(cfg),
|
S3: cacheS3(cfg),
|
||||||
Policy: CachePolicy(cfg),
|
Policy: CachePolicy(cfg),
|
||||||
Logger: logging.Default().With("module", "cache_request"),
|
Logger: logging.Default().With("module", "cache_request"),
|
||||||
|
InstanceTransport: instanceTransport,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logging.Errorf("cannot init cache server, it will be disabled: %v", err)
|
logging.Errorf("cannot init cache server, it will be disabled: %v", err)
|
||||||
@@ -140,7 +142,7 @@ func NewRunner(cfg *config.Config, reg *config.Registration, cli client.Client)
|
|||||||
runHealthCheck: executeHealthCheck,
|
runHealthCheck: executeHealthCheck,
|
||||||
}
|
}
|
||||||
runner.isolatedCacheContainer = sync.OnceValue(runner.detectIsolatedCacheContainer)
|
runner.isolatedCacheContainer = sync.OnceValue(runner.detectIsolatedCacheContainer)
|
||||||
runner.instanceTransport = client.NewTransport(cli.Address(), cfg.Runner.TLSConfig())
|
runner.instanceTransport = instanceTransport
|
||||||
return runner
|
return runner
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -620,10 +622,12 @@ func (r *Runner) run(ctx context.Context, task *runnerv1.Task, reporter *report.
|
|||||||
JobCompletedHook: r.cfg.Runner.Hooks.JobCompleted,
|
JobCompletedHook: r.cfg.Runner.Hooks.JobCompleted,
|
||||||
Vars: task.Vars,
|
Vars: task.Vars,
|
||||||
ValidVolumes: r.cfg.Container.ValidVolumes,
|
ValidVolumes: r.cfg.Container.ValidVolumes,
|
||||||
|
ContainerVolumes: r.cfg.Container.Volumes,
|
||||||
SharedToolCache: r.cfg.Runner.ToolCacheMode == config.ToolCacheModeShared,
|
SharedToolCache: r.cfg.Runner.ToolCacheMode == config.ToolCacheModeShared,
|
||||||
InsecureSkipTLS: r.cfg.Runner.Insecure,
|
InsecureSkipTLS: r.cfg.Runner.Insecure,
|
||||||
ClientCertFile: r.cfg.Runner.ClientCertFile,
|
ClientCertFile: r.cfg.Runner.ClientCertFile,
|
||||||
ClientKeyFile: r.cfg.Runner.ClientKeyFile,
|
ClientKeyFile: r.cfg.Runner.ClientKeyFile,
|
||||||
|
CAFile: r.cfg.Runner.CAFile,
|
||||||
InstanceTransport: r.instanceTransport,
|
InstanceTransport: r.instanceTransport,
|
||||||
RunnerName: r.name,
|
RunnerName: r.name,
|
||||||
KubernetesPicker: r.kubernetesOptions,
|
KubernetesPicker: r.kubernetesOptions,
|
||||||
|
|||||||
Loaded 50 of 75 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user