From 22762480d887632134b37168cdfd52b368906704 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 20 Aug 2025 17:09:04 +0000 Subject: [PATCH] chore: merge ACT and runner unit & integration tests together (#894) When run in parallel they will race to populate the Go cache in a different way (GOPROXY is not configured the same) and that will lead to transient errors when one job tries to use the cache that is populated differently by the other job. The chain of `needs` is adjusted accordingly and the required checks too. ![image](/attachments/4b83fc9d-d5f8-497e-9e94-976fcf52f088) - other - [PR](https://code.forgejo.org/forgejo/runner/pulls/894): chore: merge ACT and runner unit & integration tests together Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/894 Reviewed-by: Mathieu Fenniak Co-authored-by: Earl Warren Co-committed-by: Earl Warren --- .forgejo/workflows/act.yml | 80 ------------------------------------- .forgejo/workflows/test.yml | 36 ++++++++++++----- Makefile | 4 +- 3 files changed, 30 insertions(+), 90 deletions(-) delete mode 100644 .forgejo/workflows/act.yml diff --git a/.forgejo/workflows/act.yml b/.forgejo/workflows/act.yml deleted file mode 100644 index 1a1b149b..00000000 --- a/.forgejo/workflows/act.yml +++ /dev/null @@ -1,80 +0,0 @@ -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 - if: vars.ROLE == 'forgejo-coding' - 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 ./act/container - go test ./act/artifactcache/... ./act/workflowpattern/... ./act/filecollector/... ./act/common/... ./act/jobparser ./act/model ./act/exprparser ./act/schema - - integration: - runs-on: lxc-bookworm - if: vars.ROLE == 'forgejo-coding' - 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 ./act/container - go test -timeout 30m ./act/runner/... diff --git a/.forgejo/workflows/test.yml b/.forgejo/workflows/test.yml index 06132260..3e1466bf 100644 --- a/.forgejo/workflows/test.yml +++ b/.forgejo/workflows/test.yml @@ -40,9 +40,9 @@ jobs: - '/usr/bin/s6-svscan /etc/s6 & sleep 10 ; su -c "forgejo admin user create --admin --username $FORGEJO_ADMIN_USER --password $FORGEJO_ADMIN_PASSWORD --email root@example.com" git && su -c "forgejo forgejo-cli actions register --labels docker --name therunner --secret $FORGEJO_RUNNER_SECRET" git && sleep infinity' steps: - - uses: actions/checkout@v4 + - uses: https://data.forgejo.org/actions/checkout@v4 - - uses: actions/setup-go@v5 + - uses: https://data.forgejo.org/actions/setup-go@v5 with: go-version-file: go.mod @@ -74,11 +74,10 @@ jobs: - run: make FORGEJO_URL=http://$FORGEJO_HOST_PORT test runner-exec-tests: - needs: [build-and-tests] name: runner exec tests if: vars.ROLE == 'forgejo-coding' runs-on: lxc-bookworm - + needs: [build-and-tests] steps: - uses: actions/checkout@v4 @@ -128,9 +127,29 @@ jobs: ./forgejo-runner exec --var MY_VAR=testvariable --workflows .forgejo/testdata/var.yml |& tee /tmp/var.out grep --quiet 'Success - Main echo "VAR -> testvariable"' /tmp/var.out + integration-tests: + name: integration tests + if: vars.ROLE == 'forgejo-coding' + runs-on: lxc-bookworm + steps: + - uses: https://data.forgejo.org/actions/checkout@v4 + + - uses: https://data.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 ./act/container + go test -timeout 30m ./act/runner/... + validate-mocks: - needs: - - build-and-tests name: validate mocks if: vars.ROLE == 'forgejo-coding' runs-on: docker @@ -138,13 +157,12 @@ jobs: image: 'code.forgejo.org/oci/ci:1' steps: - - uses: actions/checkout@v4 + - uses: https://data.forgejo.org/actions/checkout@v4 - - uses: actions/setup-go@v5 + - uses: https://data.forgejo.org/actions/setup-go@v5 with: go-version-file: go.mod - - name: generate mocks run: | set -ex diff --git a/Makefile b/Makefile index 3d751aa1..1d2c8565 100644 --- a/Makefile +++ b/Makefile @@ -106,7 +106,9 @@ fmt-check: fi; test: lint-check fmt-check - @$(GO) test -v -cover -coverprofile coverage.txt ./internal/... && echo "\n==>\033[32m Ok\033[m\n" || exit 1 + $(GO) test -v -cover -coverprofile coverage.txt ./internal/... + $(GO) test -short ./act/container + $(GO) test ./act/artifactcache/... ./act/workflowpattern/... ./act/filecollector/... ./act/common/... ./act/jobparser ./act/model ./act/exprparser ./act/schema .PHONY: vet vet: