From d5798f067ab91e19e5aa76b9d40c65a2c5ffa6fc Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 22 Feb 2023 17:19:43 +0100 Subject: [PATCH 1/4] s|gitea.com/gitea/act_runner|codeberg.org/forgejo/runner| --- client/http.go | 2 +- cmd/daemon.go | 10 +++++----- cmd/register.go | 6 +++--- config/config.go | 2 +- go.mod | 2 +- main.go | 2 +- poller/poller.go | 2 +- register/register.go | 6 +++--- runtime/reporter.go | 2 +- runtime/runtime.go | 2 +- runtime/task.go | 2 +- 11 files changed, 19 insertions(+), 19 deletions(-) diff --git a/client/http.go b/client/http.go index 2c2d628..0f08f81 100644 --- a/client/http.go +++ b/client/http.go @@ -8,7 +8,7 @@ import ( "code.gitea.io/actions-proto-go/ping/v1/pingv1connect" "code.gitea.io/actions-proto-go/runner/v1/runnerv1connect" - "gitea.com/gitea/act_runner/core" + "codeberg.org/forgejo/runner/core" "github.com/bufbuild/connect-go" ) diff --git a/cmd/daemon.go b/cmd/daemon.go index 46d78ad..79e6a34 100644 --- a/cmd/daemon.go +++ b/cmd/daemon.go @@ -5,11 +5,11 @@ import ( "os" "strings" - "gitea.com/gitea/act_runner/client" - "gitea.com/gitea/act_runner/config" - "gitea.com/gitea/act_runner/engine" - "gitea.com/gitea/act_runner/poller" - "gitea.com/gitea/act_runner/runtime" + "codeberg.org/forgejo/runner/client" + "codeberg.org/forgejo/runner/config" + "codeberg.org/forgejo/runner/engine" + "codeberg.org/forgejo/runner/poller" + "codeberg.org/forgejo/runner/runtime" "github.com/joho/godotenv" "github.com/mattn/go-isatty" diff --git a/cmd/register.go b/cmd/register.go index 8990f0f..b123db4 100644 --- a/cmd/register.go +++ b/cmd/register.go @@ -11,9 +11,9 @@ import ( "time" pingv1 "code.gitea.io/actions-proto-go/ping/v1" - "gitea.com/gitea/act_runner/client" - "gitea.com/gitea/act_runner/config" - "gitea.com/gitea/act_runner/register" + "codeberg.org/forgejo/runner/client" + "codeberg.org/forgejo/runner/config" + "codeberg.org/forgejo/runner/register" "github.com/bufbuild/connect-go" "github.com/joho/godotenv" diff --git a/config/config.go b/config/config.go index 53a4cf1..607df95 100644 --- a/config/config.go +++ b/config/config.go @@ -7,7 +7,7 @@ import ( "runtime" "strconv" - "gitea.com/gitea/act_runner/core" + "codeberg.org/forgejo/runner/core" "github.com/joho/godotenv" "github.com/kelseyhightower/envconfig" diff --git a/go.mod b/go.mod index 994c70c..7393925 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module gitea.com/gitea/act_runner +module codeberg.org/forgejo/runner go 1.18 diff --git a/main.go b/main.go index 333e615..8562842 100644 --- a/main.go +++ b/main.go @@ -6,7 +6,7 @@ import ( "os/signal" "syscall" - "gitea.com/gitea/act_runner/cmd" + "codeberg.org/forgejo/runner/cmd" ) func withContextFunc(ctx context.Context, f func()) context.Context { diff --git a/poller/poller.go b/poller/poller.go index abb96c8..1600dc4 100644 --- a/poller/poller.go +++ b/poller/poller.go @@ -7,7 +7,7 @@ import ( "time" runnerv1 "code.gitea.io/actions-proto-go/runner/v1" - "gitea.com/gitea/act_runner/client" + "codeberg.org/forgejo/runner/client" "github.com/bufbuild/connect-go" log "github.com/sirupsen/logrus" diff --git a/register/register.go b/register/register.go index 3c5e7d1..4458174 100644 --- a/register/register.go +++ b/register/register.go @@ -8,9 +8,9 @@ import ( "strings" runnerv1 "code.gitea.io/actions-proto-go/runner/v1" - "gitea.com/gitea/act_runner/client" - "gitea.com/gitea/act_runner/config" - "gitea.com/gitea/act_runner/core" + "codeberg.org/forgejo/runner/client" + "codeberg.org/forgejo/runner/config" + "codeberg.org/forgejo/runner/core" "github.com/bufbuild/connect-go" log "github.com/sirupsen/logrus" diff --git a/runtime/reporter.go b/runtime/reporter.go index b6d38bf..544852a 100644 --- a/runtime/reporter.go +++ b/runtime/reporter.go @@ -8,7 +8,7 @@ import ( "time" runnerv1 "code.gitea.io/actions-proto-go/runner/v1" - "gitea.com/gitea/act_runner/client" + "codeberg.org/forgejo/runner/client" retry "github.com/avast/retry-go/v4" "github.com/bufbuild/connect-go" diff --git a/runtime/runtime.go b/runtime/runtime.go index 4bac678..e5e096b 100644 --- a/runtime/runtime.go +++ b/runtime/runtime.go @@ -5,7 +5,7 @@ import ( "strings" runnerv1 "code.gitea.io/actions-proto-go/runner/v1" - "gitea.com/gitea/act_runner/client" + "codeberg.org/forgejo/runner/client" ) // Runner runs the pipeline. diff --git a/runtime/task.go b/runtime/task.go index b899c5b..7d6bb6d 100644 --- a/runtime/task.go +++ b/runtime/task.go @@ -11,7 +11,7 @@ import ( "time" runnerv1 "code.gitea.io/actions-proto-go/runner/v1" - "gitea.com/gitea/act_runner/client" + "codeberg.org/forgejo/runner/client" "github.com/nektos/act/pkg/artifacts" "github.com/nektos/act/pkg/common" From c81e7d4beb3b0695d2ef60d4f32bdfd5dc3f0bf4 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 22 Feb 2023 17:20:57 +0100 Subject: [PATCH 2/4] upgrade to codeberg.org/forgejo/act v1.0.0 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 7393925..5a657ea 100644 --- a/go.mod +++ b/go.mod @@ -77,4 +77,4 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/nektos/act => gitea.com/gitea/act v0.234.2 +replace github.com/nektos/act => codeberg.org/forgejo/act v1.0.0 diff --git a/go.sum b/go.sum index a81ca83..84dbf55 100644 --- a/go.sum +++ b/go.sum @@ -24,9 +24,9 @@ cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0Zeo cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= code.gitea.io/actions-proto-go v0.2.0 h1:nYh9nhhfk67YA4wVNLsCzd//RCvXnljwXClJ33+HPVk= code.gitea.io/actions-proto-go v0.2.0/go.mod h1:00ys5QDo1iHN1tHNvvddAcy2W/g+425hQya1cCSvq9A= +codeberg.org/forgejo/act v1.0.0 h1:XtlEFX+wKgd+RiGr/ITRB2kATkubValgGaLEWv5WRDI= +codeberg.org/forgejo/act v1.0.0/go.mod h1:2C/WbTalu1VPNgbVaZJaZDzlOtAKqkXJhdOClxkMy14= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -gitea.com/gitea/act v0.234.2 h1:bayHPYv545SurAe4z9hMiX7kOafE3SnMvpS9llZ+ik0= -gitea.com/gitea/act v0.234.2/go.mod h1:2C/WbTalu1VPNgbVaZJaZDzlOtAKqkXJhdOClxkMy14= github.com/Azure/azure-sdk-for-go v16.2.1+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= From 956fe61fb9e4407a1bb339305599c7b4c0ca4b03 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 22 Feb 2023 18:45:54 +0100 Subject: [PATCH 3/4] Update README --- README.md | 62 +++---------------------------------------------------- 1 file changed, 3 insertions(+), 59 deletions(-) diff --git a/README.md b/README.md index b5cf959..b233ded 100644 --- a/README.md +++ b/README.md @@ -1,61 +1,5 @@ -# act runner +# Forgejo Actions runner -Act runner is a runner for Gitea based on [act](https://gitea.com/gitea/act). +Runs workflows found in `.forgejo/workflows`, using a format similar to GitHub actions but with a Free Software implementation. -## Prerequisites - -Docker Engine Community version is required. To install Docker CE, follow the official [install instructions](https://docs.docker.com/engine/install/). - -## Quickstart - -### Build - -```bash -make build -``` - -### Register - -```bash -./act_runner register -``` - -And you will be asked to input: - -1. Gitea instance URL, like `http://192.168.8.8:3000/`. You should use your gitea instance ROOT_URL as the instance argument - and you should not use `localhost` or `127.0.0.1` as instance IP; -2. Runner token, you can get it from `http://192.168.8.8:3000/admin/runners`; -3. Runner name, you can just leave it blank; -4. Runner labels, you can just leave it blank. - -The process looks like: - -```text -INFO Registering runner, arch=amd64, os=darwin, version=0.1.5. -WARN Runner in user-mode. -INFO Enter the Gitea instance URL (for example, https://gitea.com/): -http://192.168.8.8:3000/ -INFO Enter the runner token: -fe884e8027dc292970d4e0303fe82b14xxxxxxxx -INFO Enter the runner name (if set empty, use hostname:Test.local ): - -INFO Enter the runner labels, leave blank to use the default labels (comma-separated, for example, self-hosted,ubuntu-20.04:docker://node:16-bullseye,ubuntu-18.04:docker://node:16-buster): - -INFO Registering runner, name=Test.local, instance=http://192.168.8.8:3000/, labels=[ubuntu-latest:docker://node:16-bullseye ubuntu-22.04:docker://node:16-bullseye ubuntu-20.04:docker://node:16-bullseye ubuntu-18.04:docker://node:16-buster]. -DEBU Successfully pinged the Gitea instance server -INFO Runner registered successfully. -``` - -You can also register with command line arguments. - -```bash -./act_runner register --instance http://192.168.8.8:3000 --token --no-interactive -``` - -If the registry succeed, it will run immediately. Next time, you could run the runner directly. - -### Run - -```bash -./act_runner daemon -``` \ No newline at end of file +It is compatible with Forgejo v1.19.0-0-rc0 From 97fb2000e346f52af51c9cb698448c325a8a92ca Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Fri, 24 Feb 2023 23:30:09 +0800 Subject: [PATCH 4/4] Enable action as CI to test/build/release (#26) Reviewed-on: https://gitea.com/gitea/act_runner/pulls/26 --- .gitea/workflows/lint.yml | 21 --------------------- .gitea/workflows/test.yml | 23 +++++++++++++++++++++++ .gitignore | 1 + Makefile | 4 ++-- 4 files changed, 26 insertions(+), 23 deletions(-) delete mode 100644 .gitea/workflows/lint.yml create mode 100644 .gitea/workflows/test.yml diff --git a/.gitea/workflows/lint.yml b/.gitea/workflows/lint.yml deleted file mode 100644 index 97e5326..0000000 --- a/.gitea/workflows/lint.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: checks -on: [push] - -env: - GOPROXY: https://goproxy.io,direct - -jobs: - lint: - name: lint - runs-on: ubuntu-latest - steps: - - uses: actions/setup-go@v3 - with: - go-version: 1.17 - - uses: actions/checkout@v3 - - uses: Jerome1337/golint-action@v1.0.2 - #- name: golangci-lint - # uses: golangci/golangci-lint-action@v3 - # with: - # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version - # version: v1.29 \ No newline at end of file diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml new file mode 100644 index 0000000..bf34338 --- /dev/null +++ b/.gitea/workflows/test.yml @@ -0,0 +1,23 @@ +name: checks +on: + - push + - pull_request + +env: + GOPROXY: https://goproxy.io,direct + +jobs: + lint: + name: check and test + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v3 + with: + go-version: 1.20 + - uses: actions/checkout@v3 + - name: vet checks + run: make vet + - name: build + run: make build + - name: test + run: make test \ No newline at end of file diff --git a/.gitignore b/.gitignore index 4bd1d0b..82ec058 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ act_runner .env .runner +coverage.txt \ No newline at end of file diff --git a/Makefile b/Makefile index 3092f42..d5a1805 100644 --- a/Makefile +++ b/Makefile @@ -67,7 +67,7 @@ all: build fmt: @hash gofumpt > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ - $(GO) install -u mvdan.cc/gofumpt; \ + $(GO) install mvdan.cc/gofumpt@latest; \ fi $(GOFMT) -w $(GOFILES) @@ -77,7 +77,7 @@ vet: .PHONY: fmt-check fmt-check: @hash gofumpt > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ - $(GO) install -u mvdan.cc/gofumpt; \ + $(GO) install mvdan.cc/gofumpt@latest; \ fi @diff=$$($(GOFMT) -d $(GOFILES)); \ if [ -n "$$diff" ]; then \