support runner.arch (#1290)
* support runner.arch Signed-off-by: Fabian Kammel <fk@edgeless.systems> * add arch to runner definition Signed-off-by: Fabian Kammel <fk@edgeless.systems> * get architecture from docker Signed-off-by: Fabian Kammel <fk@edgeless.systems> * Update pkg/container/docker_run.go Co-authored-by: ChristopherHX <christopher.homberger@web.de> * lint: goimport file Signed-off-by: Fabian Kammel <fk@edgeless.systems> Co-authored-by: Casey Lee <caseypl@amazon.com> Co-authored-by: ChristopherHX <christopher.homberger@web.de> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
parent
8bad6aca50
commit
e1b906813e
5 changed files with 26 additions and 0 deletions
|
@ -276,6 +276,26 @@ func GetHostInfo(ctx context.Context) (info types.Info, err error) {
|
||||||
return info, nil
|
return info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Arch fetches values from docker info and translates architecture to
|
||||||
|
// GitHub actions compatible runner.arch values
|
||||||
|
// https://github.com/github/docs/blob/main/data/reusables/actions/runner-arch-description.md
|
||||||
|
func RunnerArch(ctx context.Context) string {
|
||||||
|
info, err := GetHostInfo(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
archMapper := map[string]string{
|
||||||
|
"x86_64": "X64",
|
||||||
|
"386": "x86",
|
||||||
|
"aarch64": "arm64",
|
||||||
|
}
|
||||||
|
if arch, ok := archMapper[info.Architecture]; ok {
|
||||||
|
return arch
|
||||||
|
}
|
||||||
|
return info.Architecture
|
||||||
|
}
|
||||||
|
|
||||||
func (cr *containerReference) connect() common.Executor {
|
func (cr *containerReference) connect() common.Executor {
|
||||||
return func(ctx context.Context) error {
|
return func(ctx context.Context) error {
|
||||||
if cr.cli != nil {
|
if cr.cli != nil {
|
||||||
|
|
|
@ -346,6 +346,7 @@ func newStepContainer(ctx context.Context, step step, image string, cmd []string
|
||||||
|
|
||||||
envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_TOOL_CACHE", "/opt/hostedtoolcache"))
|
envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_TOOL_CACHE", "/opt/hostedtoolcache"))
|
||||||
envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_OS", "Linux"))
|
envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_OS", "Linux"))
|
||||||
|
envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_ARCH", container.RunnerArch(ctx)))
|
||||||
envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_TEMP", "/tmp"))
|
envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_TEMP", "/tmp"))
|
||||||
|
|
||||||
binds, mounts := rc.GetBindsAndMounts()
|
binds, mounts := rc.GetBindsAndMounts()
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/nektos/act/pkg/common"
|
"github.com/nektos/act/pkg/common"
|
||||||
|
"github.com/nektos/act/pkg/container"
|
||||||
"github.com/nektos/act/pkg/exprparser"
|
"github.com/nektos/act/pkg/exprparser"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
@ -47,6 +48,7 @@ func (rc *RunContext) NewExpressionEvaluator(ctx context.Context) ExpressionEval
|
||||||
Steps: rc.getStepsContext(),
|
Steps: rc.getStepsContext(),
|
||||||
Runner: map[string]interface{}{
|
Runner: map[string]interface{}{
|
||||||
"os": "Linux",
|
"os": "Linux",
|
||||||
|
"arch": container.RunnerArch(ctx),
|
||||||
"temp": "/tmp",
|
"temp": "/tmp",
|
||||||
"tool_cache": "/opt/hostedtoolcache",
|
"tool_cache": "/opt/hostedtoolcache",
|
||||||
},
|
},
|
||||||
|
@ -92,6 +94,7 @@ func (rc *RunContext) NewStepExpressionEvaluator(ctx context.Context, step step)
|
||||||
Steps: rc.getStepsContext(),
|
Steps: rc.getStepsContext(),
|
||||||
Runner: map[string]interface{}{
|
Runner: map[string]interface{}{
|
||||||
"os": "Linux",
|
"os": "Linux",
|
||||||
|
"arch": container.RunnerArch(ctx),
|
||||||
"temp": "/tmp",
|
"temp": "/tmp",
|
||||||
"tool_cache": "/opt/hostedtoolcache",
|
"tool_cache": "/opt/hostedtoolcache",
|
||||||
},
|
},
|
||||||
|
|
|
@ -149,6 +149,7 @@ func (rc *RunContext) startJobContainer() common.Executor {
|
||||||
|
|
||||||
envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_TOOL_CACHE", "/opt/hostedtoolcache"))
|
envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_TOOL_CACHE", "/opt/hostedtoolcache"))
|
||||||
envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_OS", "Linux"))
|
envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_OS", "Linux"))
|
||||||
|
envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_ARCH", container.RunnerArch(ctx)))
|
||||||
envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_TEMP", "/tmp"))
|
envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_TEMP", "/tmp"))
|
||||||
|
|
||||||
binds, mounts := rc.GetBindsAndMounts()
|
binds, mounts := rc.GetBindsAndMounts()
|
||||||
|
|
|
@ -105,6 +105,7 @@ func (sd *stepDocker) newStepContainer(ctx context.Context, image string, cmd []
|
||||||
|
|
||||||
envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_TOOL_CACHE", "/opt/hostedtoolcache"))
|
envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_TOOL_CACHE", "/opt/hostedtoolcache"))
|
||||||
envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_OS", "Linux"))
|
envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_OS", "Linux"))
|
||||||
|
envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_ARCH", container.RunnerArch(ctx)))
|
||||||
envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_TEMP", "/tmp"))
|
envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_TEMP", "/tmp"))
|
||||||
|
|
||||||
binds, mounts := rc.GetBindsAndMounts()
|
binds, mounts := rc.GetBindsAndMounts()
|
||||||
|
|
Loading…
Reference in a new issue