Skip to content

Conversation

@TheFynx
Copy link

@TheFynx TheFynx commented Jun 21, 2025

Description

Fixes segmentation fault that occurs when running act -n (dry-run mode) with GitHub Actions workflows containing service containers.

Fixes #2607

Problem

When running workflows with service containers in dry-run mode, Act would crash with a segmentation fault at pkg/container/docker_run.go:173 in the GetHealth() method. This happened because:

  1. In dry-run mode, service containers are not actually created (no Docker client connection)
  2. The health checking code still attempted to inspect non-existent containers via cr.cli.ContainerInspect(ctx, cr.id)
  3. This resulted in a nil pointer dereference when cr.cli was nil

Solution

Added dry-run mode protection at two critical points:

  1. GetHealth() method - Returns HealthHealthy immediately in dry-run mode instead of attempting Docker inspection
  2. waitForServiceContainer() function - Skips all health checking in dry-run mode

The fix ensures that act's dry-run mode works consistently with service containers by providing appropriate mock responses instead of attempting real Docker operations.

Testing

  • Added regression test TestServiceContainerWorkflowDryRun to prevent future regressions
  • Manually validated that act -n with service containers no longer crashes
  • All existing service container tests continue to pass:
    • TestRunEvent/services
    • TestRunEvent/services-empty-image
    • TestRunEvent/services-host-network
    • TestRunEvent/services-with-container
    • TestRunEvent/mysql-service-container-with-health-check

Compliance

  • Code formatted with go fmt ./...
  • Ran go mod tidy (why go.mod was altered)
  • Includes test coverage of change

@ChristopherHX
Copy link
Contributor

I would have added an integration test for dryrun in this list

{workdir, "local-action-js", "push", "", platforms, secrets},

Possibly just copying these lines below into the dryrun test above would resolve my concerns

{workdir, "services", "push", "", platforms, secrets},
{workdir, "services-empty-image", "push", "", platforms, secrets},
{workdir, "services-host-network", "push", "", platforms, secrets},
{workdir, "services-with-container", "push", "", platforms, secrets},
{workdir, "mysql-service-container-with-health-check", "push", "", platforms, secrets},

As far as I understand your (very likely via help of an AI agent generated) test especially tests the method I have introduced does work for dryrun. However this does not prevent me from breaking service container in dryrun again, like chainging the methods I call in setupjobconatiner.

Yes I almost always forget that dryrun even exists, so it is possible this feature is entire unmaintained for much longer period of time than would be healthy for this feature

@TheFynx
Copy link
Author

TheFynx commented Jul 23, 2025

Thanks for the review! I will try to circle back to this, this weekend. I'll get the changes sorted and tested.

@codecov
Copy link

codecov bot commented Jul 28, 2025

Codecov Report

❌ Patch coverage is 63.63636% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.76%. Comparing base (bd4bc99) to head (d704c91).
⚠️ Report is 18 commits behind head on master.

Files with missing lines Patch % Lines
pkg/container/docker_run.go 46.66% 6 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5782      +/-   ##
==========================================
+ Coverage   74.65%   74.76%   +0.10%     
==========================================
  Files          73       73              
  Lines       11139    11211      +72     
==========================================
+ Hits         8316     8382      +66     
- Misses       2186     2191       +5     
- Partials      637      638       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Including workflow services crashes with invalid memory address or nil pointer dereference for dry-run

2 participants