Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remote docker actions new action cache and dry run mode #2513

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/container/docker_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,9 @@
}

func (cr *containerReference) CopyTarStream(ctx context.Context, destPath string, tarStream io.Reader) error {
if common.Dryrun(ctx) {
return nil
}

Check warning on line 704 in pkg/container/docker_run.go

View check run for this annotation

Codecov / codecov/patch

pkg/container/docker_run.go#L703-L704

Added lines #L703 - L704 were not covered by tests
// Mkdir
buf := &bytes.Buffer{}
tw := tar.NewWriter(buf)
Expand Down
24 changes: 12 additions & 12 deletions pkg/runner/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,11 @@

return rc.execJobContainer(containerArgs, *step.getEnv(), "", "")(ctx)
case model.ActionRunsUsingDocker:
location := actionLocation
if remoteAction == nil {
location = containerActionDir
actionDir = ""
actionPath = containerActionDir
}
return execAsDocker(ctx, step, actionName, location, remoteAction == nil, "entrypoint")
return execAsDocker(ctx, step, actionName, actionDir, actionPath, remoteAction == nil, "entrypoint")
case model.ActionRunsUsingComposite:
if err := maybeCopyToActionDir(ctx, step, actionDir, actionPath, containerActionDir); err != nil {
return err
Expand Down Expand Up @@ -243,7 +243,7 @@
// TODO: break out parts of function to reduce complexicity
//
//nolint:gocyclo
func execAsDocker(ctx context.Context, step actionStep, actionName string, basedir string, localAction bool, entrypointType string) error {
func execAsDocker(ctx context.Context, step actionStep, actionName, basedir, subpath string, localAction bool, entrypointType string) error {
logger := common.Logger(ctx)
rc := step.getRunContext()
action := step.getActionModel()
Expand All @@ -260,7 +260,7 @@
image = fmt.Sprintf("%s-dockeraction:%s", regexp.MustCompile("[^a-zA-Z0-9]").ReplaceAllString(actionName, "-"), "latest")
image = fmt.Sprintf("act-%s", strings.TrimLeft(image, "-"))
image = strings.ToLower(image)
contextDir, fileName := filepath.Split(filepath.Join(basedir, action.Runs.Image))
contextDir, fileName := path.Split(path.Join(subpath, action.Runs.Image))

anyArchExists, err := container.ImageExistsLocally(ctx, image, "any")
if err != nil {
Expand Down Expand Up @@ -300,7 +300,7 @@
defer buildContext.Close()
}
prepImage = container.NewDockerBuildExecutor(container.NewDockerBuildExecutorInput{
ContextDir: contextDir,
ContextDir: filepath.Join(basedir, contextDir),
Dockerfile: fileName,
ImageTag: image,
BuildContext: buildContext,
Expand Down Expand Up @@ -557,11 +557,11 @@
return rc.execJobContainer(containerArgs, *step.getEnv(), "", "")(ctx)

case model.ActionRunsUsingDocker:
location := actionLocation
if remoteAction == nil {
location = containerActionDir
actionDir = ""
actionPath = containerActionDir

Check warning on line 562 in pkg/runner/action.go

View check run for this annotation

Codecov / codecov/patch

pkg/runner/action.go#L561-L562

Added lines #L561 - L562 were not covered by tests
}
return execAsDocker(ctx, step, actionName, location, remoteAction == nil, "pre-entrypoint")
return execAsDocker(ctx, step, actionName, actionDir, actionPath, remoteAction == nil, "pre-entrypoint")

Check warning on line 564 in pkg/runner/action.go

View check run for this annotation

Codecov / codecov/patch

pkg/runner/action.go#L564

Added line #L564 was not covered by tests

case model.ActionRunsUsingComposite:
if step.getCompositeSteps() == nil {
Expand Down Expand Up @@ -662,11 +662,11 @@
return rc.execJobContainer(containerArgs, *step.getEnv(), "", "")(ctx)

case model.ActionRunsUsingDocker:
location := actionLocation
if remoteAction == nil {
location = containerActionDir
actionDir = ""
actionPath = containerActionDir

Check warning on line 667 in pkg/runner/action.go

View check run for this annotation

Codecov / codecov/patch

pkg/runner/action.go#L666-L667

Added lines #L666 - L667 were not covered by tests
}
return execAsDocker(ctx, step, actionName, location, remoteAction == nil, "post-entrypoint")
return execAsDocker(ctx, step, actionName, actionDir, actionPath, remoteAction == nil, "post-entrypoint")

Check warning on line 669 in pkg/runner/action.go

View check run for this annotation

Codecov / codecov/patch

pkg/runner/action.go#L669

Added line #L669 was not covered by tests

case model.ActionRunsUsingComposite:
if err := maybeCopyToActionDir(ctx, step, actionDir, actionPath, containerActionDir); err != nil {
Expand Down
Loading