Skip to content

runs-on does not accept array expressions #2080

@jenseng

Description

@jenseng

Bug report info

act version:            0.2.53
GOOS:                   darwin
GOARCH:                 arm64
NumCPU:                 12
Docker host:            DOCKER_HOST environment variable is not set
Sockets found:
	/var/run/docker.sock
	$HOME/.docker/run/docker.sock
Config files:
	/Users/jonj/.actrc:
		-P ubuntu-latest=node:16-buster-slim
		-P ubuntu-22.04=node:16-bullseye-slim
		-P ubuntu-20.04=node:16-buster-slim
		-P ubuntu-18.04=node:16-buster-slim
Build info:
	Go version:            go1.21.3
	Module path:           command-line-arguments
	Main version:
	Main path:
	Main checksum:
	Build settings:
		-buildmode:           exe
		-compiler:            gc
		-ldflags:             -X main.version=0.2.53
		DefaultGODEBUG:       panicnil=1
		CGO_ENABLED:          1
		CGO_CFLAGS:
		CGO_CPPFLAGS:
		CGO_CXXFLAGS:
		CGO_LDFLAGS:
		GOARCH:               arm64
		GOOS:                 darwin
Docker Engine:
	Engine version:        24.0.6
	Engine runtime:        runc
	Cgroup version:        2
	Cgroup driver:         cgroupfs
	Storage driver:        overlay2
	Registry URI:          https://index.docker.io/v1/
	OS:                    Docker Desktop
	OS type:               linux
	OS version:
	OS arch:               aarch64
	OS kernel:             6.4.16-linuxkit
	OS CPU:                12
	OS memory:             7844 MB
	Security options:
		name=seccomp,profile=unconfined
		name=cgroupns

Command used with act

act -vW .github/workflows/sample.yml

Describe issue

If runs-on receives an array expression, act incorrectly evaluates it to %!t(string=Array). act correctly handles string expressions, as well as static string and array yaml values.

I.e. these work:

  • runs-on: ubuntu-latest
  • runs-on: ${{ fromJSON('"ubuntu-latest"') }}
  • runs-on: [ubuntu-latest]

But this does not:

  • runs-on: ${{ fromJSON('["ubuntu-latest"]') }}

The bug isn't specific to fromJSON, as the same issue occurs if the expression is an array value from a matrix, e.g.

runs-on: ${{ matrix.runner }}
strategy:
  matrix:
    runner: [[ubuntu-latest], [self-hosted, my-cool-label]]

These scenarios all work as expected in actual GitHub Actions workflow runs.

Link to GitHub repository

https://github.com/jenseng/dynamic-uses/actions/runs/6801153354/job/18491354468

Workflow content

name: test
on: push
jobs:
  test:
    # runs-on: ubuntu-latest
    # runs-on: ${{ fromJSON('"ubuntu-latest"') }}
    # runs-on: [ubuntu-latest]
    runs-on: ${{ fromJSON('["ubuntu-latest"]') }}
    steps:
      - run: echo "Hello, world!"

Relevant log output

WARN  ⚠ You are using Apple M-series chip and you have not specified container architecture, you might encounter issues while running act. If so, try running it with '--container-architecture linux/amd64'. ⚠
DEBU[0000] Loading environment from /Users/jonj/projects/dynamic-uses/.env
DEBU[0000] Loading action inputs from /Users/jonj/projects/dynamic-uses/.input
DEBU[0000] Loading secrets from /Users/jonj/projects/dynamic-uses/.secrets
DEBU[0000] Loading vars from /Users/jonj/projects/dynamic-uses/.vars
DEBU[0000] Evaluated matrix inclusions: map[]
DEBU[0000] Loading workflow '/Users/jonj/projects/dynamic-uses/.github/workflows/sample.yml'
DEBU[0000] Reading workflow '/Users/jonj/projects/dynamic-uses/.github/workflows/sample.yml'
DEBU[0000] Preparing plan with all jobs
DEBU[0000] Using the only detected workflow event: push
DEBU[0000] Planning jobs for event: push
DEBU[0000] Conditional GET for notices etag=c694094f-9a86-4866-bf11-876c821d9fcb
DEBU[0000] gc: 2023-11-08 09:31:06.262245 -0700 MST m=+0.030477292  module=artifactcache
DEBU[0000] Plan Stages: [0x1400011ee10]
DEBU[0000] Stages Runs: [test]
DEBU[0000] Job.Name: test
DEBU[0000] Job.RawNeeds: {0 0    <nil> []    0 0}
DEBU[0000] Job.RawRunsOn: {8 0 !!str ${{ fromJSON('["ubuntu-latest"]') }}  <nil> []    8 14}
DEBU[0000] Job.Env: {0 0    <nil> []    0 0}
DEBU[0000] Job.If: {0 0  success()  <nil> []    0 0}
DEBU[0000] Job.Steps: echo "Hello, world!"
DEBU[0000] Job.TimeoutMinutes:
DEBU[0000] Job.Services: map[]
DEBU[0000] Job.Strategy: <nil>
DEBU[0000] Job.RawContainer: {0 0    <nil> []    0 0}
DEBU[0000] Job.Defaults.Run.Shell:
DEBU[0000] Job.Defaults.Run.WorkingDirectory:
DEBU[0000] Job.Outputs: map[]
DEBU[0000] Job.Uses:
DEBU[0000] Job.With: map[]
DEBU[0000] Job.Result:
DEBU[0000] Empty Strategy, matrixes=[map[]]
DEBU[0000] Job Matrices: [map[]]
DEBU[0000] Runner Matrices: map[]
DEBU[0000] Final matrix after applying user inclusions '[map[]]'
DEBU[0000] Loading revision from git directory
DEBU[0000] Found revision: 4af4b6a3356b02639095850fe2dce350906070ba
DEBU[0000] HEAD points to '4af4b6a3356b02639095850fe2dce350906070ba'
DEBU[0000] using github ref: refs/heads/debug-act-bug3
DEBU[0000] Found revision: 4af4b6a3356b02639095850fe2dce350906070ba
DEBU[0000] Detected CPUs: 12
[test/test] [DEBUG] evaluating expression 'success()'
[test/test] [DEBUG] expression 'success()' evaluated to 'true'
[test/test] [DEBUG] expression '${{ fromJSON('["ubuntu-latest"]') }}' rewritten to 'format('{0}', fromJSON('["ubuntu-latest"]'))'
[test/test] [DEBUG] evaluating expression 'format('{0}', fromJSON('["ubuntu-latest"]'))'
[test/test] [DEBUG] expression 'format('{0}', fromJSON('["ubuntu-latest"]'))' evaluated to '%!t(string=Array)'
[test/test] [DEBUG] expression '${{ fromJSON('["ubuntu-latest"]') }}' rewritten to 'format('{0}', fromJSON('["ubuntu-latest"]'))'
[test/test] [DEBUG] evaluating expression 'format('{0}', fromJSON('["ubuntu-latest"]'))'
[test/test] [DEBUG] expression 'format('{0}', fromJSON('["ubuntu-latest"]'))' evaluated to '%!t(string=Array)'
[test/test] 🚧  Skipping unsupported platform -- Try running with `-P Array=...`
DEBU[0000] Saving notices etag=c694094f-9a86-4866-bf11-876c821d9fcb
DEBU[0000] No new notices

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions