From 91e7940947e15b5dc768c0a0a28ffb58efe7b640 Mon Sep 17 00:00:00 2001 From: Mathieu Fenniak Date: Wed, 20 Aug 2025 19:46:03 +0000 Subject: [PATCH] test: add an integration test for embedded runner cache (#889) Adds a limited integration test in the runner which verifies that the embedded cache server starts up, can be written to by an action, and can be read by a subsequent action. This is a solid base foundation for future nearly-end-to-end tests. - other - [PR](https://code.forgejo.org/forgejo/runner/pulls/889): test: add an integration test for embedded runner cache Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/889 Reviewed-by: earl-warren Co-authored-by: Mathieu Fenniak Co-committed-by: Mathieu Fenniak --- .forgejo/workflows/test.yml | 38 +++++++ Makefile | 5 +- internal/app/run/runner_test.go | 181 ++++++++++++++++++++++++++++++++ 3 files changed, 223 insertions(+), 1 deletion(-) diff --git a/.forgejo/workflows/test.yml b/.forgejo/workflows/test.yml index 3e1466bf..3a1d5abe 100644 --- a/.forgejo/workflows/test.yml +++ b/.forgejo/workflows/test.yml @@ -149,6 +149,44 @@ jobs: go test ./act/container go test -timeout 30m ./act/runner/... + runner-integration-tests: + name: runner integration tests + if: vars.ROLE == 'forgejo-coding' + runs-on: lxc-bookworm + needs: [build-and-tests] + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + + - name: install docker + run: | + mkdir /etc/docker + cat > /etc/docker/daemon.json < cache_path_1/cache_content_1 +` + runWorkflow(populateYaml, "push", "refs/heads/main", "step 1: push cache populate expected to succeed") + + // Step 2: Validate that cache is accessible; mostly a sanity check that the test environment and mock context + // provides everything needed for the cache setup. + checkYaml := ` +name: Cache Testing Action +on: + push: +jobs: + job-cache-check-2: + runs-on: ubuntu-latest + steps: + - uses: actions/cache@v4 + with: + path: cache_path_1 + key: cache-key-1 + - run: | + [[ -f cache_path_1/cache_content_1 ]] && echo "Step 2: cache file found." || echo "Step 2: cache file missing!" + [[ -f cache_path_1/cache_content_1 ]] || exit 1 +` + runWorkflow(checkYaml, "push", "refs/heads/main", "step 2: push cache check expected to succeed") +}