From bcddcef2b91f724b29a1581a49e99fe9c8d57f65 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Mon, 28 Jul 2025 18:49:35 +0200 Subject: [PATCH] chore: import the ACT test workflow - remove go vet and build as they are now redundant - replace ./pkg with ./act - rename the workflow from test to act to distinguish it from the runner workflow cleanup and factorization with the runner workflow is left for later --- .forgejo/workflows/act.yml | 78 ++++++++++++++++++++++++++++ act/runner/run_context_test.go | 2 +- act/runner/step_action_local_test.go | 2 +- 3 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 .forgejo/workflows/act.yml diff --git a/.forgejo/workflows/act.yml b/.forgejo/workflows/act.yml new file mode 100644 index 00000000..8ae625ff --- /dev/null +++ b/.forgejo/workflows/act.yml @@ -0,0 +1,78 @@ +name: act +on: + push: + branches: + - 'main' + pull_request: + +env: + GOPROXY: https://goproxy.io,direct + GOPATH: /go_path + GOCACHE: /go_cache + +jobs: + unit: + runs-on: docker + container: + image: 'code.forgejo.org/oci/node:22-bookworm' + steps: + - name: cache go path + id: cache-go-path + uses: https://code.forgejo.org/actions/cache@v4 + with: + path: /go_path + key: go_path-${{ forge.repository }}-${{ forge.ref_name }} + restore-keys: | + go_path-${{ forge.repository }}- + go_path- + - name: cache go cache + id: cache-go-cache + uses: https://code.forgejo.org/actions/cache@v4 + with: + path: /go_cache + key: go_cache-${{ forge.repository }}-${{ forge.ref_name }} + restore-keys: | + go_cache-${{ forge.repository }}- + go_cache- + + - uses: https://code.forgejo.org/actions/checkout@v4 + + - uses: https://code.forgejo.org/actions/setup-go@v5 + with: + go-version-file: go.mod + + - name: validate go version + run: | + set -ex + toolchain=$(grep -oP '(?<=toolchain ).+' go.mod) + version=$(go version | cut -d' ' -f3) + if dpkg --compare-versions ${version#go} lt ${toolchain#go}; then + echo "go version too low: $toolchain >= $version" + exit 1 + fi + + - name: unit test + run: | + go test -short -v ./act/container + go test -v ./act/artifactcache/... ./act/workflowpattern/... ./act/filecollector/... ./act/common/... ./act/jobparser ./act/model ./act/exprparser ./act/schema + + integration: + runs-on: lxc-bookworm + needs: [unit] + steps: + - uses: https://code.forgejo.org/actions/checkout@v4 + + - uses: https://code.forgejo.org/actions/setup-go@v5 + with: + go-version-file: go.mod + + - name: apt install docker.io + run: | + export DEBIAN_FRONTEND=noninteractive + apt-get update -qq + apt-get -q install -qq -y docker.io + + - name: integration test + run: | + go test -v ./act/container + go test -v ./act/runner/... diff --git a/act/runner/run_context_test.go b/act/runner/run_context_test.go index 29879be1..1f443953 100644 --- a/act/runner/run_context_test.go +++ b/act/runner/run_context_test.go @@ -318,7 +318,7 @@ func TestRunContext_GetGitHubContext(t *testing.T) { actor = a } - repo := "forgejo/act" + repo := "forgejo/runner" if r := os.Getenv("ACT_REPOSITORY"); r != "" { repo = r } diff --git a/act/runner/step_action_local_test.go b/act/runner/step_action_local_test.go index 04a459cc..d62f118d 100644 --- a/act/runner/step_action_local_test.go +++ b/act/runner/step_action_local_test.go @@ -262,7 +262,7 @@ func TestStepActionLocalPost(t *testing.T) { return strings.HasSuffix(array[1], suffix) }) } - cm.On("Exec", suffixMatcher("pkg/runner/local/action/post.js"), sal.env, "", "").Return(func(ctx context.Context) error { return tt.err }) + cm.On("Exec", suffixMatcher("act/runner/local/action/post.js"), sal.env, "", "").Return(func(ctx context.Context) error { return tt.err }) cm.On("Copy", "/var/run/act", mock.AnythingOfType("[]*container.FileEntry")).Return(func(ctx context.Context) error { return nil