From 6c9959d7a96a7876f3c51f834f3a11d98eca621e Mon Sep 17 00:00:00 2001 From: Kwonunn Date: Mon, 28 Oct 2024 08:58:35 +0100 Subject: [PATCH 1/6] Cherry-pick gitea act_runner #543 From: https://gitea.com/gitea/act_runner/commit/1735b26e66f8e81c526204c128f1bcfd7f578906 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 --- internal/app/run/logging.go | 24 ++++++++++++++++++++++++ internal/app/run/runner.go | 4 ++++ 2 files changed, 28 insertions(+) create mode 100644 internal/app/run/logging.go diff --git a/internal/app/run/logging.go b/internal/app/run/logging.go new file mode 100644 index 0000000..d0e6d1c --- /dev/null +++ b/internal/app/run/logging.go @@ -0,0 +1,24 @@ +// Copyright 2024 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package run + +import ( + "io" + + log "github.com/sirupsen/logrus" +) + +// NullLogger is used to create a new JobLogger to discard logs. This +// will prevent these logs from being logged to the stdout, but +// forward them to the Reporter via its hook. +type NullLogger struct{} + +// WithJobLogger creates a new logrus.Logger that will discard all logs. +func (n NullLogger) WithJobLogger() *log.Logger { + logger := log.New() + logger.SetOutput(io.Discard) + logger.SetLevel(log.TraceLevel) + + return logger +} diff --git a/internal/app/run/runner.go b/internal/app/run/runner.go index e774786..9eaf37e 100644 --- a/internal/app/run/runner.go +++ b/internal/app/run/runner.go @@ -252,6 +252,10 @@ func (r *Runner) run(ctx context.Context, task *runnerv1.Task, reporter *report. // add logger recorders ctx = common.WithLoggerHook(ctx, reporter) + if !log.IsLevelEnabled(log.DebugLevel) { + ctx = runner.WithJobLoggerFactory(ctx, NullLogger{}) + } + execErr := executor(ctx) reporter.SetOutputs(job.Outputs) return execErr From 0ba115ba6789411868fa92ec882470bc3307b664 Mon Sep 17 00:00:00 2001 From: Kwonunn Date: Sun, 3 Nov 2024 15:10:54 +0100 Subject: [PATCH 2/6] Version bump and add release notes --- RELEASE-NOTES.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index f899d14..01fcf39 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -1,8 +1,9 @@ # Release Notes -## 4.1.0 +## 5.0.0 * [Add job_level logging option to config](https://code.forgejo.org/forgejo/runner/pulls/299) to make the logging level of jobs configurable. Change default from "trace" to "info". +* [Don't log job output when debug logging is not enabled](https://code.forgejo.org/forgejo/runner/pulls/303). This reduces the default amount of log output of the runner. ## 4.0.1 From 0658d72b3f25a8d18fdf4e7da01a65fda6114273 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Wed, 6 Nov 2024 23:35:14 +0000 Subject: [PATCH 3/6] Update dependency go to v1.23.3 --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index f8f6982..28c3f2e 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module gitea.com/gitea/act_runner go 1.21.13 -toolchain go1.23.2 +toolchain go1.23.3 require ( code.gitea.io/actions-proto-go v0.4.0 From 228e0025657576ad666b4a2756b1e3f26743661c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Kro=CC=88ner?= Date: Thu, 7 Nov 2024 07:30:12 +0000 Subject: [PATCH 4/6] Add support for windows build on GitHub (#312) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR adds a Windows build pipeline running on GitHub. Currently it runs on the repository https://github.com/Crown0815/forgejo-runner-windows. So far the build does not include tests, but I am working on a solution. For the time being we can release the windows builds easily though. Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/312 Co-authored-by: Felix Kröner Co-committed-by: Felix Kröner --- .github/workflows/build-release.yml | 48 +++++++++++++++++++++++++++++ .gitignore | 3 ++ 2 files changed, 51 insertions(+) create mode 100644 .github/workflows/build-release.yml diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml new file mode 100644 index 0000000..8086590 --- /dev/null +++ b/.github/workflows/build-release.yml @@ -0,0 +1,48 @@ +# This workflow will build a Windows binary for each architecture and upload it as an artifact. +# If the push is a tag, it will create a release with the binaries attached. +# This build is currently supported on https://github.com/Crown0815/forgejo-runner-windows + +name: Build release + +on: + push: + tags: 'v*' +jobs: + build: + name: Build ${{matrix.architecture}} + runs-on: ubuntu-latest + strategy: + matrix: + architecture: ['386', amd64, arm, arm64] + steps: + - uses: actions/checkout@v4 + - name: Build for ${{matrix.architecture}} + run: | + env GOOS=windows GOARCH=${{matrix.architecture}} \ + go build -o forgejo-runner-windows-${{matrix.architecture}}.exe + + - uses: actions/upload-artifact@v4 + with: + name: forgejo-runner-windows-${{matrix.architecture}} + path: forgejo-runner-windows-${{matrix.architecture}}.exe + + release: + runs-on: ubuntu-latest + needs: build + if: github.event_name == 'push' && github.ref_type == 'tag' + steps: + - uses: actions/download-artifact@v4 + with: + path: . + + - name: Create Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ github.ref_name }} + files: forgejo-runner-windows-*/forgejo-runner-windows-*.exe + draft: false + prerelease: ${{ contains(github.ref, 'beta') || contains(github.ref, 'alpha') }} + token: ${{ secrets.RELEASE_TOKEN }} + fail_on_unmatched_files: true + body: See [original release notes](https://code.forgejo.org/forgejo/runner/releases/tag/${{ github.ref_name }}). + diff --git a/.gitignore b/.gitignore index 3a3808c..57ec96d 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,6 @@ coverage.txt __debug_bin # gorelease binary folder dist + +# Jetbrains IDE +.idea From 9510276a99e87fbf60bdd8fc5b26003d5858f1ce Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 8 Nov 2024 00:05:20 +0000 Subject: [PATCH 5/6] Update module golang.org/x/term to v0.26.0 --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 28c3f2e..4f8f6c1 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/sirupsen/logrus v1.9.3 github.com/spf13/cobra v1.8.1 github.com/stretchr/testify v1.9.0 - golang.org/x/term v0.25.0 + golang.org/x/term v0.26.0 golang.org/x/time v0.7.0 google.golang.org/protobuf v1.35.1 gopkg.in/yaml.v3 v3.0.1 @@ -96,7 +96,7 @@ require ( golang.org/x/mod v0.13.0 // indirect golang.org/x/net v0.23.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.26.0 // indirect + golang.org/x/sys v0.27.0 // indirect golang.org/x/tools v0.14.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index 76d4a2c..5b7a1f8 100644 --- a/go.sum +++ b/go.sum @@ -274,15 +274,15 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= -golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= +golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= -golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= +golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU= +golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= From 4a57d4acf9acae45e0dea50e39c86d5777cbe322 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 8 Nov 2024 07:54:54 +0000 Subject: [PATCH 6/6] Update module golang.org/x/time to v0.8.0 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 4f8f6c1..9969f26 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/spf13/cobra v1.8.1 github.com/stretchr/testify v1.9.0 golang.org/x/term v0.26.0 - golang.org/x/time v0.7.0 + golang.org/x/time v0.8.0 google.golang.org/protobuf v1.35.1 gopkg.in/yaml.v3 v3.0.1 gotest.tools/v3 v3.5.1 diff --git a/go.sum b/go.sum index 5b7a1f8..290783c 100644 --- a/go.sum +++ b/go.sum @@ -292,8 +292,8 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ= -golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= +golang.org/x/time v0.8.0 h1:9i3RxcPv3PZnitoVGMPDKZSq1xW1gK1Xy3ArNOGZfEg= +golang.org/x/time v0.8.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200325010219-a49f79bcc224/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=