Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.
/ act-workflow-test Public archive

Demonstrate issue with nektos/act tool and reusable workflows with matrix builds. Fixed as of 0.2.54.

License

Notifications You must be signed in to change notification settings

Andy4495/act-workflow-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

act-workflow-test

Note: This issue has been fixed, merged, and released.


Small repo with with a minimal example to demonstrate issue 2003 submitted to act.

When using reusable workflows with a matrix strategy, act runs all the matrix combinations in a single container, which causes the following error (and therefore quits the test after the first matrix combination is run):

Error: failed to create container: 'Error response from daemon: Conflict. The container name "/act-call-reusable-workflow-reusable-workflow-reusable-workflow-c7535ef5a84abfd1f2412cceca72bd226072ccb44b16a59787972320d9cb1a2d" is already in use by container "d0baad951ea56daf6bd3097af098d08b22d726733e0e4a54120fe40c357874a0". You have to remove (or rename) that container to be able to reuse that name.'

See files calling-workfow.yml and reusable-flow.yml.

When doing the same thing from within a self-contained workflow (still using a matrix strategy), act creates a separate container for each run and does not have any errors. See standalone-workflow.yml.

Root Cause and Fix

In file pkg/runner/run_context.go, the function String() has a comment about creating a unique name:

func (rc *RunContext) String() string {
    name := fmt.Sprintf("%s/%s", rc.Run.Workflow.Name, rc.Name)
    if rc.caller != nil {
        // prefix the reusable workflow with the caller job
        // this is required to create unique container names
        name = fmt.Sprintf("%s/%s", rc.caller.runContext.Run.JobID, name)
    }
    return name
}

However, rc.caller.runContext.Run.JobID is not a unique name. Instead, rc.caller.runContext.Name should be used. It has an identifier (-1, -2, etc.) appended to the end of the name by function NewPlanExecutor() in file pkg/runner/runner.go, ensuring the name is unique.

So the fixed String() function should be:

func (rc *RunContext) String() string {
    name := fmt.Sprintf("%s/%s", rc.Run.Workflow.Name, rc.Name)
    if rc.caller != nil {
        // prefix the reusable workflow with the caller job
        // this is required to create unique container names
        name = fmt.Sprintf("%s/%s", rc.caller.runContext.Name, name)
    }
    return name
}

Pull request #2015 has been merged and and included in release 0.2.54.

License

The software and other files in this repository are released under what is commonly called the MIT License. See the file LICENSE in this repository.

About

Demonstrate issue with nektos/act tool and reusable workflows with matrix builds. Fixed as of 0.2.54.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published