1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-07-27 17:28:35 +00:00
Commit graph

113 commits

Author SHA1 Message Date
Earl Warren
22a9c49672
fix: reporter.SetOutputs must ignore values that overflow the size (#662)
Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/662
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-07-08 09:02:50 +00:00
Earl Warren
c17d65711b
chore(tests): coverage for Reporter.ReportLog
go test  -cover -coverprofile coverage.txt -v ./internal/pkg/report/...

go tool cover -html=coverage.txt -o coverage.html
xdg-open coverage.html

$ go run github.com/gregoryv/uncover/cmd/uncover@latest coverage.txt ReportLog
total:    (statements)    100.0%
2025-07-07 17:28:22 +02:00
Earl Warren
57716748c6
fix: mask multiline secrets
- do not try to mask a secret when a log line is received
- try to mask secrets before before sending a batch of log
  lines to the Forgejo instance (every second)
- if masking a multiline secret needs more log lines to decide
  if it needs to be masked, do not attempt to send anything to
  the Forgejo instance, just wait until there are more log lines

Closes forgejo/runner#57
2025-07-07 17:28:10 +02:00
Earl Warren
b842a66be2
fix: ReportLog retry if noMore && more rows are to be sent
r.logOffset = ack
ack < r.logOffset+len(rows)

can be simplified as

len(rows) > 0

which is only false if there were no rows to send. It follows
that

if noMore && ack < r.logOffset+len(rows) {

is can be simplified as

if noMore {

is always true if rows were sent.

The intent was apparently to return on error and retry if only
part of the rows were sent but not all of them. To achieve that
the expression is replaced with:

if noMore && len(r.logRows) > 0 {
2025-07-07 17:28:10 +02:00
Earl Warren
45fae19e5b
chore: refactor Report{Log,State} retry errors
Introduce ErrRetry to distinguish errors that are wort a retry from
the others.
2025-07-07 17:28:10 +02:00
Earl Warren
7ccc32744a
fix: ReportLog must do nothing if there is nothing to send
It saves a call to the Forgejo server when no new row was added in
within the interval to report the logs (1s by default).
2025-07-07 17:28:10 +02:00
Earl Warren
190079b7f3
feat: reporter helper to mask secrets, including multiline
- the longest secret is masked first
- multiline secrets are masked before single line secrets
- O(multiline * log rows) to not degrade performances when there are
  no multiline secrets
2025-07-07 17:28:10 +02:00
Earl Warren
9650eb8a46
chore(tests): MockVariable helper 2025-07-06 08:59:18 +02:00
earl-warren
df2524586e
assorted set of fixes and features for rebranding (#652)
Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/652
Reviewed-by: Gusted <gusted@noreply.code.forgejo.org>
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
2025-07-06 06:59:00 +00:00
Earl Warren
31626146c2
chore(cleanup): remove tests that will be obsoleted (#664)
and it is kind of useless anyway because invalid workflows are currently failing in very inconsistent and unpredictable ways.

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/664
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-07-05 22:05:25 +00:00
Earl Warren
ed79677232
chore(tests): make generate (#659)
Refs forgejo/runner#658

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/659
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-07-05 21:45:39 +00:00
Earl Warren
eb1becd4b8
chore: s|gitea.com/gitea/act_runner|runner.forgejo.org| 2025-07-03 19:07:02 +02:00
Earl Warren
8cb450ffe0
feat: add forgejo_default_actions_url + forgejo_runtime_token
the context sent from the Forgejo instance is expected to have

gitea_default_actions_url
gitea_runtime_token

add support for

forgejo_default_actions_url
forgejo_runtime_token

as well so that future Forgejo versions can make the change.
2025-07-03 18:58:11 +02:00
Earl Warren
42cacd47c2
feat: add FORGEJO_ACTIONS{,_RUNNER_VERSION} to jobs env 2025-07-03 18:58:11 +02:00
Earl Warren
f1b67559b1
chore: remove gitea from variable names etc. with no functional change 2025-07-03 18:58:11 +02:00
Earl Warren
96a453c015
fix!: replace CLI --gitea-instance with --forgejo-instance 2025-07-03 18:58:11 +02:00
Earl Warren
22ae656783
chore: remove unused code and comments including gitea 2025-07-03 18:58:11 +02:00
Earl Warren
44d9d4f453
chore: upgrade to code.forgejo.org/forgejo/actions-proto (#655)
In replacement of code.gitea.io/actions-proto-go

- https://gitea.com/gitea/actions-proto-def and https://gitea.com/gitea/actions-proto-go were merged into https://code.forgejo.org/forgejo/actions-proto to facilitate maintenance
- the generated go code is different because the package name is different
    - f4285dfc28 shows they compare exactly identical before the name change
    - a3c95cb82f is the generated code right after the name change
- the cascading pull request further shows the protocol is compatible by running [end-to-end actions tests](https://code.forgejo.org/forgejo/end-to-end/src/branch/main/actions) that rely on it, using a runner binary built from [this pull request](https://code.forgejo.org/forgejo/end-to-end/actions/runs/3329/jobs/2#jobstep-4-640) `0296d988d65e66b8d8a7951d0d7d7f8c6cf78b44` matches `v0.0.1+576-g0296d98`
    - `time="2025-07-03T12:53:50Z" level=info msg="runner: runner, with version: v0.0.1+576-g0296d98, with labels: [docker], declared successfully" func="[func6]" file="[daemon.go:108]"`

A similar pull request will be sent to Forgejo once this one is merged (less risky environment)

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/655
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-07-03 16:55:53 +00:00
Earl Warren
51e0bc0e53
feat: support for forgejo-exec --var (#645)
Refs forgejo/runner#387

https://code.forgejo.org/forgejo/runner/actions/runs/4284/jobs/1#jobstep-6-25

![image](/attachments/cf804b2b-e4c3-46a8-afac-27cfdb1fe6c2)

Co-authored-by: lautriva <lautriva@noreply.gitea.com>
Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/645
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-07-03 16:37:30 +00:00
Earl Warren
7f29fd815a
fix(docs): better example for the default config file (#630)
--add-host name not work depending on the network mode chosen.

Closes forgejo/runner#213

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/630
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-07-01 17:51:05 +00:00
Christoph Heiss
efa324d16a
chore: fix typos and add type checking to port/addr args (#576)
Hi!

~~ba2fc1273ce5cb04d96cfdbb47ebad929dcbd96f goes in tandem with https://code.forgejo.org/forgejo/act/pulls/135 and adapts to the API changes for `runner.Config.`~~

I dropped the act interface changes according to https://code.forgejo.org/forgejo/act/pulls/135#issuecomment-40695, but kept the CLI changes here - as they are not breaking here.

Other three commits just fix up some typos around the tree - bit of a pet peeve of mine, sorry :^)

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/576
Reviewed-by: earl-warren <earl-warren@noreply.code.forgejo.org>
Co-authored-by: Christoph Heiss <christoph@c8h4.io>
Co-committed-by: Christoph Heiss <christoph@c8h4.io>
2025-06-01 15:03:22 +00:00
Gusted
6245f71556
Remove unused header (#496)
- Forgejo (since v8, 38ea77ebbe) does not use the value of this header, it was [introduced in v1.20](371520d7ab).
- Older forgejo version than v8 handle it gracefully if this value is not sent.

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/496
Reviewed-by: earl-warren <earl-warren@noreply.code.forgejo.org>
Co-authored-by: Gusted <postmaster@gusted.xyz>
Co-committed-by: Gusted <postmaster@gusted.xyz>
2025-05-24 08:31:05 +00:00
Earl Warren
e57a12dac9
fix: if insecure == true, get proxy too (#535)
Fixes https://code.forgejo.org/forgejo/runner/issues/534

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/535
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-05-02 21:54:37 +00:00
Kwonunn
46eb63a952 Fix security issues with cache by proxying access (#503)
This is the forgejo-runner-side patch for a partial overhaul of the cache system to fix some access control issues with caches.

This code depends on changes in act which are being reviewed here: forgejo/act#107

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/502
Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/503
Reviewed-by: Gusted <gusted@noreply.code.forgejo.org>
Co-authored-by: Kwonunn <kwonunnx@gmail.com>
Co-committed-by: Kwonunn <kwonunnx@gmail.com>
2025-03-22 00:03:09 +00:00
Earl Warren
ee7b68842d
fix: use data.forgejo.org/oci
Otherwise it may get rate limited in the CI verifying it works
2025-01-15 14:44:16 +01:00
cobak78
ba78c11326 New "one shot" type of execution by adding a new command called one-job. (#423)
As commented here https://code.forgejo.org/forgejo/runner/issues/422, this PR aims to allow a new type of one shot execution compatible with autoscaling features and other job types.

Co-authored-by: jaime merino <jaime.merino_mora@mail.schwarzª>
Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/423
Reviewed-by: earl-warren <earl-warren@noreply.code.forgejo.org>
Co-authored-by: cobak78 <cobak78@noreply.code.forgejo.org>
Co-committed-by: cobak78 <cobak78@noreply.code.forgejo.org>
2025-01-15 12:29:07 +00:00
gratux
3947276c79 expose "ForceRebuild" as a config option 2024-12-29 17:13:04 +01:00
earl-warren
c9265044b5 Merge pull request 'Rebrand container prefix to Forgejo' (#377) from fnetx/rebrand-prefix into main
Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/377
Reviewed-by: earl-warren <earl-warren@noreply.code.forgejo.org>
2024-12-15 07:42:00 +00:00
xtex
3068bebfcb
feat: use FORGEJO_TOKEN as runtime token
Link: https://codeberg.org/forgejo/forgejo/pulls/6199
2024-12-13 20:24:01 +08:00
Otto Richter
a2ce5d9f8b
Rebrand container prefix to Forgejo 2024-12-09 16:21:04 +01:00
Earl Warren
279faefa08
fix: [container].docker_host = "" is now "automount"
The empty string is always replaced with "-" and there no longer is
any way to specify that the docker socket is to be mounted in the
container automatically.

The "automount" value is introduced as a replacement.

https://code.forgejo.org/forgejo/act/pulls/67 and
https://code.forgejo.org/forgejo/runner/pulls/305 introduced this regression.
2024-11-27 01:36:18 +00:00
Earl Warren
b33e155709
fix: make container.docker_host default to - (part two)
If --config is not specified, the default must also be "-" and not ""
2024-11-15 22:48:56 +01:00
Kwonunn
6c9959d7a9 Cherry-pick gitea act_runner #543
From: 1735b26e66

Don't log job output when debug logging is not enabled

We wanted the ability to disable outputting the logs from the individual job to the console. This changes the logging so that job logs are only output to the console whenever debug logging is enabled in `act_runner`, while still allowing the `Reporter` to receive these logs and forward them to Gitea when debug logging is not enabled.

Signed-off-by: Kwonunn <kwonunnx@gmail.com>
2024-11-03 13:57:34 +00:00
Thorben Günther
846ff2a616
Add simple test 2024-11-02 17:49:38 +01:00
Thorben Günther
71149e36fa
Add configurable logging level for jobs
This changes the default for JobLoggerLevel from "trace" to "info".

Closes #298
2024-11-02 17:49:34 +01:00
Earl Warren
2b64f15543
fix: make container.docker_host default to -
Otherwise containers will be running by default with a socket to the
docker host which is insecure. The default must be secure.
2024-10-29 11:39:13 +01:00
Earl Warren
b1d9d52b6f
chore: add test for unexpected YAML type in top level env 2024-09-15 16:05:01 +02:00
Mike Rochefort
93bced9c7b chore: bump actions-proto-go to v0.4.0
bufbuild/connect-go was archived with maintenance transferred to the
ConnectRPC organization. Gitea's protobuf library for actions now uses
the ConnectRPC dependency as of v0.4.0, removing the need to continue
using the dead package.
2024-07-31 01:20:20 -04:00
Lennart Austenfeld
705f59f3e4
Add report_interval option to config 2024-07-27 17:53:43 +02:00
9pfs
7e1ddcb5cc Fix typo in create-runner-file help text (Frogejo -> Forgejo) 2024-06-27 23:50:52 +00:00
Earl Warren
e02e0fc5f5
wait for jobs to complete when stopping the runner
When receiving a signal (INT or TERM) wait for running jobs to
complete instead of terminating them right away.

The new shutdown_timeout configuration setting can be used to force
the termination after a grace delay. If not specified or zero it will
shutdown immediately, for backward compatibility. It will be the case
with existing configuration files or when a configuration file is not
specified.

The config.yml created with the generate-config subcommand will
however default shutdown_timeout to 3h (same as timeout) because it is
likely what a new admin would expect: shutting down waits for jobs to
complete and not abort them.
2024-06-07 12:33:34 +02:00
Earl Warren
9774b35d75
Upgrade the default container to node:20
Fixes: https://code.forgejo.org/forgejo/runner/issues/168
2024-06-07 11:41:14 +02:00
Mai-Lapyst
f3861e60fc
Add support for workflow inputs
This is a somewhat "hacky" way; it copies the inputs from the "event"
object's "inputs" field when the event is a "workflow_dispatch".

But this way we do not need to change the protobuf powered runner
protocol to also include the inputs. Espc. since they're also present
inside the event anyway.
2024-05-24 17:27:55 +02:00
Andreas Wachter
9e521434a4 typo in error message 2024-05-03 09:54:34 +02:00
Mai-Lapyst
f45d0855ad
Update tests 2024-04-20 08:21:35 +02:00
Mai-Lapyst
3b24b73988
Handle group commands
Add handling of the `::group::` and `::endgroup::` command to produce
github like results.
2024-04-20 04:41:52 +02:00
TheFox0x7
599c75c167
replace Nil with NoError 2024-04-10 23:55:42 +02:00
TheFox0x7
5660e21fb8
added simple test to label update 2024-04-10 23:55:42 +02:00
TheFox0x7
7abbd84a8a
add label change post runner creation 2024-04-10 23:55:40 +02:00
TheFox0x7
f1181cc62a
after reading labels, load them into registration 2024-04-10 23:53:50 +02:00