1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-08-01 17:38:36 +00:00
Commit graph

22 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
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
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
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
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
sillyguodong
82c30f5cf7
Set the status of steps to skipped if job is skipped (#500)
If a job is detected as skipped, its steps should also be `skipped`.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/500
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: sillyguodong <gedong_1994@163.com>
Co-committed-by: sillyguodong <gedong_1994@163.com>
(cherry picked from commit 45270656dfb7a0c8b382df3a9e8a212dbe5615d8)
2024-03-11 22:10:26 +07:00
Christopher Homberger
1c20916144
Use artifacts v4 jwt if available (#471)
Needs https://github.com/go-gitea/gitea/pull/28885 to provide jwt if sent by server

Could fix #459, but that has not been verified.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/471
Reviewed-by: delvh <dev.lh@web.de>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Christopher Homberger <christopher.homberger@web.de>
Co-committed-by: Christopher Homberger <christopher.homberger@web.de>
(cherry picked from commit e6630e2e369f41fc9d9f9e570610611da18dda1d)
2024-03-11 22:10:26 +07:00
hakito
0d5eb12574
Sanitize UFT-8 content in logs (#453)
I accidently closed my previous PR #384

This PR replaces invalid UTF-8 character in a stream with `?` character. On Windows Server 2019 other characters are replaced by `?` as well so it's consistent.

fixes #452

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/453
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: Jason Song <i@wolfogre.com>
Co-authored-by: hakito <hakito@noreply.gitea.com>
Co-committed-by: hakito <hakito@noreply.gitea.com>
(cherry picked from commit daf52d0e628d2d57b9f50a2556e404a3f05c34aa)
2024-03-11 22:10:26 +07:00
Jason Song
de4160b023 Skip counting log length when parseLogRow return nil (#176)
Fix:
![image](/attachments/93e29bc0-3599-4f7e-8b90-512562a5d711)

Regression of #149, `LogLength` could be incorrect.

It may be related to https://github.com/go-gitea/gitea/issues/24458

Reviewed-on: https://gitea.com/gitea/act_runner/pulls/176
Reviewed-by: Zettat123 <zettat123@noreply.gitea.io>
Reviewed-by: wxiaoguang <wxiaoguang@noreply.gitea.io>
2023-05-06 17:00:52 +08:00
Søren L. Hansen
c8cc7b2448 Workflow commands (#149)
Establishes a simple framework for supporting workflow commands.

Fully implements `::add-mask::`, `::debug::`, and `::stop-commands::`.

Addresses #148

Co-authored-by: Jason Song <i@wolfogre.com>
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/149
Reviewed-by: Jason Song <i@wolfogre.com>
Co-authored-by: Søren L. Hansen <sorenisanerd@gmail.com>
Co-committed-by: Søren L. Hansen <sorenisanerd@gmail.com>
2023-04-27 12:32:48 +08:00
Jason Song
83ec0ba909 Support upload outputs and use needs context (#133)
See [Example usage of the needs context](https://docs.github.com/en/actions/learn-github-actions/contexts#example-usage-of-the-needs-context).

Related to:
- [actions-proto-def #5](https://gitea.com/gitea/actions-proto-def/pulls/5)
- [gitea #24230](https://github.com/go-gitea/gitea/pull/24230)

Reviewed-on: https://gitea.com/gitea/act_runner/pulls/133
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: Zettat123 <zettat123@noreply.gitea.io>
Co-authored-by: Jason Song <i@wolfogre.com>
Co-committed-by: Jason Song <i@wolfogre.com>
2023-04-20 23:27:46 +08:00
Zettat123
bc6031eff7 Fix reporting log in Reporter.Close (#126)
Previously, the `Close` func returns incorrectly so that the logs may not be reported.

This PR fixes the incorrect return and sets the `StoppedAt` to get the correct task duration.

Reviewed-on: https://gitea.com/gitea/act_runner/pulls/126
Reviewed-by: Jason Song <i@wolfogre.com>
Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-committed-by: Zettat123 <zettat123@gmail.com>
2023-04-19 11:17:49 +08:00
Jason Song
220efa69c0 Refactor to new framework (#98)
- Adjust directory structure
```text
├── internal
│   ├── app
│   │   ├── artifactcache
│   │   ├── cmd
│   │   ├── poll
│   │   └── run
│   └── pkg
│       ├── client
│       ├── config
│       ├── envcheck
│       ├── labels
│       ├── report
│       └── ver
└── main.go
```
- New pkg `labels` to parse label
- New pkg `report` to report logs to Gitea
- Remove pkg `engine`, use `envcheck` to check if docker running.
- Rewrite `runtime` to `run`
- Rewrite `poller` to `poll`
- Simplify some code and remove what's useless.

Reviewed-on: https://gitea.com/gitea/act_runner/pulls/98
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Jason Song <i@wolfogre.com>
Co-committed-by: Jason Song <i@wolfogre.com>
2023-04-04 21:32:04 +08:00