1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-08-26 18:20:59 +00:00

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
This commit is contained in:
Earl Warren 2025-07-28 18:49:35 +02:00
parent ebc7758c1f
commit bcddcef2b9
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
3 changed files with 80 additions and 2 deletions

View file

@ -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/...

View file

@ -318,7 +318,7 @@ func TestRunContext_GetGitHubContext(t *testing.T) {
actor = a actor = a
} }
repo := "forgejo/act" repo := "forgejo/runner"
if r := os.Getenv("ACT_REPOSITORY"); r != "" { if r := os.Getenv("ACT_REPOSITORY"); r != "" {
repo = r repo = r
} }

View file

@ -262,7 +262,7 @@ func TestStepActionLocalPost(t *testing.T) {
return strings.HasSuffix(array[1], suffix) 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 { cm.On("Copy", "/var/run/act", mock.AnythingOfType("[]*container.FileEntry")).Return(func(ctx context.Context) error {
return nil return nil