mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-09-15 18:57:01 +00:00
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.  <!--start release-notes-assistant--> <!--URL:https://code.forgejo.org/forgejo/runner--> - other - [PR](https://code.forgejo.org/forgejo/runner/pulls/894): <!--number 894 --><!--line 0 --><!--description Y2hvcmU6IG1lcmdlIEFDVCBhbmQgcnVubmVyIHVuaXQgJiBpbnRlZ3JhdGlvbiB0ZXN0cyB0b2dldGhlcg==-->chore: merge ACT and runner unit & integration tests together<!--description--> <!--end release-notes-assistant--> Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/894 Reviewed-by: Mathieu Fenniak <mfenniak@noreply.code.forgejo.org> Co-authored-by: Earl Warren <contact@earl-warren.org> Co-committed-by: Earl Warren <contact@earl-warren.org>
This commit is contained in:
parent
8ce7965030
commit
22762480d8
3 changed files with 30 additions and 90 deletions
|
@ -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/...
|
|
|
@ -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'
|
- '/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:
|
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:
|
with:
|
||||||
go-version-file: go.mod
|
go-version-file: go.mod
|
||||||
|
|
||||||
|
@ -74,11 +74,10 @@ jobs:
|
||||||
- run: make FORGEJO_URL=http://$FORGEJO_HOST_PORT test
|
- run: make FORGEJO_URL=http://$FORGEJO_HOST_PORT test
|
||||||
|
|
||||||
runner-exec-tests:
|
runner-exec-tests:
|
||||||
needs: [build-and-tests]
|
|
||||||
name: runner exec tests
|
name: runner exec tests
|
||||||
if: vars.ROLE == 'forgejo-coding'
|
if: vars.ROLE == 'forgejo-coding'
|
||||||
runs-on: lxc-bookworm
|
runs-on: lxc-bookworm
|
||||||
|
needs: [build-and-tests]
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- uses: actions/checkout@v4
|
- 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
|
./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
|
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:
|
validate-mocks:
|
||||||
needs:
|
|
||||||
- build-and-tests
|
|
||||||
name: validate mocks
|
name: validate mocks
|
||||||
if: vars.ROLE == 'forgejo-coding'
|
if: vars.ROLE == 'forgejo-coding'
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
|
@ -138,13 +157,12 @@ jobs:
|
||||||
image: 'code.forgejo.org/oci/ci:1'
|
image: 'code.forgejo.org/oci/ci:1'
|
||||||
|
|
||||||
steps:
|
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:
|
with:
|
||||||
go-version-file: go.mod
|
go-version-file: go.mod
|
||||||
|
|
||||||
|
|
||||||
- name: generate mocks
|
- name: generate mocks
|
||||||
run: |
|
run: |
|
||||||
set -ex
|
set -ex
|
||||||
|
|
4
Makefile
4
Makefile
|
@ -106,7 +106,9 @@ fmt-check:
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
test: lint-check fmt-check
|
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
|
.PHONY: vet
|
||||||
vet:
|
vet:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue