From e049c82d9cc4bdcde14ccfca90d162ccca3b4635 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sun, 10 Aug 2025 15:10:30 +0000 Subject: [PATCH] chore: cancel context used in CI when running workflows (#831) the context obtained from context.Background() may otherwise survive the test instead. It is equivalent to t.Context() which is only available in go >= v1.24 --- It is suspected to be the cause of ``` 2025-08-10T13:01:08.5866723Z [services/Reproduction of failing Services interpolation] [DEBUG] Writing entry to tarball workflow/event.json len:2 2025-08-10T13:01:08.5866772Z [services/Reproduction of failing Services interpolation] [DEBUG] Writing entry to tarball workflow/envs.txt len:0 2025-08-10T13:01:08.5866818Z [services/Reproduction of failing Services interpolation] [DEBUG] Extracting content to '/var/run/act/' 2025-08-10T13:01:08.5866868Z [services/Reproduction of failing Services interpolation] service [postgres]: container health check a6b5d1443dd78f3d3aa244aeccabe72542f1c1ee33200f74a9ea33ae736f01f0 (code.forgejo.org/oci/postgres:16) is starting, waiting 10s 2025-08-10T13:01:08.5866919Z panic: test timed out after 10m0s 2025-08-10T13:01:08.5866984Z running tests: 2025-08-10T13:01:08.5867024Z TestRunner_RunWithService (2s) 2025-08-10T13:01:08.5867081Z 2025-08-10T13:01:08.5867142Z goroutine 55693 [running]: 2025-08-10T13:01:08.5867206Z testing.(*M).startAlarm.func1() 2025-08-10T13:01:08.5867250Z /go_path/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.12.linux-amd64/src/testing/testing.go:2373 +0x385 2025-08-10T13:01:08.5867300Z created by time.goFunc 2025-08-10T13:01:08.5867368Z /go_path/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.12.linux-amd64/src/time/sleep.go:215 +0x2d ... 2025-08-10T13:01:08.5878289Z goroutine 55692 [select]: 2025-08-10T13:01:08.5878350Z code.forgejo.org/forgejo/runner/v9/act/runner.waitForServiceContainer({0xf12e50, 0xc0006bbe30}, {0xf1e120, 0xc0003643c0}) 2025-08-10T13:01:08.5878402Z /home/debian/.cache/act/7ffa26f4231b52fa/hostexecutor/act/runner/run_context.go:757 +0xd7 2025-08-10T13:01:08.5878460Z code.forgejo.org/forgejo/runner/v9/act/runner.(*RunContext).waitForServiceContainers.func1.1({0xf12e50?, 0xc0006bbe30?}) 2025-08-10T13:01:08.5878524Z /home/debian/.cache/act/7ffa26f4231b52fa/hostexecutor/act/runner/run_context.go:770 +0x25 2025-08-10T13:01:08.5878592Z code.forgejo.org/forgejo/runner/v9/act/runner.(*RunContext).waitForServiceContainers.func1.NewParallelExecutor.2.1(0xc00015a5b0, 0xc00015a700) 2025-08-10T13:01:08.5878684Z /home/debian/.cache/act/7ffa26f4231b52fa/hostexecutor/act/common/executor.go:107 +0x52 2025-08-10T13:01:08.5878729Z created by code.forgejo.org/forgejo/runner/v9/act/runner.(*RunContext).waitForServiceContainers.func1.NewParallelExecutor.2 in goroutine 55682 2025-08-10T13:01:08.5878777Z /home/debian/.cache/act/7ffa26f4231b52fa/hostexecutor/act/common/executor.go:105 +0xf4 2025-08-10T13:01:08.5878821Z ... ``` - other - [PR](https://code.forgejo.org/forgejo/runner/pulls/831): chore: cancel context used in CI when running workflows [skip cascade] Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/831 Reviewed-by: Michael Kriese Co-authored-by: Earl Warren Co-committed-by: Earl Warren --- act/runner/runner_test.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/act/runner/runner_test.go b/act/runner/runner_test.go index be3dd501..86f06fcf 100644 --- a/act/runner/runner_test.go +++ b/act/runner/runner_test.go @@ -229,7 +229,8 @@ func TestRunner_RunEvent(t *testing.T) { t.Skip("skipping integration test") } - ctx := context.Background() + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() tables := []TestJobFileInfo{ // Shells @@ -365,7 +366,8 @@ func TestRunner_DryrunEvent(t *testing.T) { t.Skip("skipping integration test") } - ctx := common.WithDryrun(context.Background(), true) + ctx, cancel := context.WithCancel(common.WithDryrun(context.Background(), true)) + defer cancel() tables := []TestJobFileInfo{ // Shells @@ -394,7 +396,8 @@ func TestRunner_DockerActionForcePullForceRebuild(t *testing.T) { t.Skip("skipping integration test") } - ctx := context.Background() + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() config := &Config{ ForcePull: true, @@ -542,7 +545,8 @@ func TestRunner_RunWithService(t *testing.T) { } log.SetLevel(log.DebugLevel) - ctx := context.Background() + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() platforms := map[string]string{ "ubuntu-latest": "code.forgejo.org/oci/node:22",