act icon indicating copy to clipboard operation
act copied to clipboard

Matrix include error

Open silky1313 opened this issue 10 months ago • 4 comments

Bug report info

act version:            0.2.71
GOOS:                   linux
GOARCH:                 amd64
NumCPU:                 8
Docker host:            DOCKER_HOST environment variable is not set
Sockets found:
        /var/run/docker.sock
Config files:           
        /home/silky/.config/act/actrc:
                -P ubuntu-latest=catthehacker/ubuntu:act-latest
                -P ubuntu-22.04=catthehacker/ubuntu:act-22.04
                -P ubuntu-20.04=catthehacker/ubuntu:act-20.04
                -P ubuntu-18.04=catthehacker/ubuntu:act-18.04
Build info:
        Go version:            go1.23.5
        Module path:           github.com/nektos/act
        Main version:          (devel)
        Main path:             github.com/nektos/act
        Main checksum:         
        Build settings:
                -buildmode:           exe
                -compiler:            gc
                CGO_ENABLED:          0
                GOARCH:               amd64
                GOOS:                 linux
                GOAMD64:              v1
                vcs:                  git
                vcs.revision:         a9e31cde304fb989e59068c6b1cb2f04a5fa5931
                vcs.time:             2025-01-13T02:27:17Z
                vcs.modified:         true
Docker Engine:
        Engine version:        27.4.1
        Engine runtime:        runc
        Cgroup version:        2
        Cgroup driver:         systemd
        Storage driver:        overlay2
        Registry URI:          https://index.docker.io/v1/
        OS:                    Ubuntu 22.04.5 LTS
        OS type:               linux
        OS version:            22.04
        OS arch:               x86_64
        OS kernel:             6.8.0-52-generic
        OS CPU:                8
        OS memory:             15946 MB
        Security options:
                name=apparmor
                name=seccomp,profile=builtin
                name=cgroupns

Command used with act

act --action-offline-mode --verbose push

Describe issue

My own example

When I run the following workflow

name: test matrix
on:
  push:

jobs:
  echo-color:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        os: [macos-latest, windows-latest]
        version: [12, 14]
        include:
          - color: green
    steps:
      - name: echo color
        run: |
          echo 'os is ${{ matrix.os }}, version is ${{ matrix.version }}, color is ${{matrix.color}}'

The following is a relevant log of act

DEBU[0000] Final matrix after applying user inclusions '[map[os:macos-latest version:12] map[os:macos-latest version:14] map[os:windows-latest version:12] map[os:windows-latest version:14] map[color:green]]' 

But when I put this on github and run,results are as follows https://github.com/silky1313/matrix/actions/runs/13193098626 When I run it on github, there are only four jobs, but when I run it with act, there are five jobs In summary, I think this is a bug。

Test bug

In act/pkg/model/workflow_test.go.#TestReadWorkflow_Strategy The result of the following matrix is

  matrix:
    datacenter:
      - site-c
      - site-d
    exclude:
      - datacenter: site-d
        node-version: 14.x
        site: staging
    include:
      - php-version: 5.4
      - datacenter: site-a
        node-version: 10.x
        site: prod
      - datacenter: site-b
        node-version: 12.x
        site: dev
    node-version: [14.x, 16.x]
    site:
      - staging
assert.Equal(t, matrixes,
		[]map[string]interface{}{
			{"datacenter": "site-c", "node-version": "14.x", "site": "staging"},
			{"datacenter": "site-c", "node-version": "16.x", "site": "staging"},
			{"datacenter": "site-d", "node-version": "16.x", "site": "staging"},
			{"php-version": 5.4},
			{"datacenter": "site-a", "node-version": "10.x", "site": "prod"},
			{"datacenter": "site-b", "node-version": "12.x", "site": "dev"},
		},
	)

But the map should actually get is

[]map[string]interface{}{
			{"datacenter": "site-c", "node-version": "14.x", "site": "staging", "php-version": 5.4},
			{"datacenter": "site-c", "node-version": "16.x", "site": "staging", "php-version": 5.4},
			{"datacenter": "site-d", "node-version": "16.x", "site": "staging", "php-version": 5.4},
			{"datacenter": "site-a", "node-version": "10.x", "site": "prod"},
			{"datacenter": "site-b", "node-version": "12.x", "site": "dev"},
		},

Link to GitHub repository

https://github.com/silky1313/matrix

Workflow content

name: test matrix
on:
  push:

jobs:
  echo-color:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        os: [macos-latest, windows-latest]
        version: [12, 14]
        include:
          - color: green
#        exclude:
#          - os: macos-latest
#            version: 12
#          - os: windows-latest
#            version: 14
    steps:
      - name: echo color
        run: |
          echo 'os is ${{ matrix.os }}, version is ${{ matrix.version }}, color is ${{matrix.color}}'
# 发现一些bug
# 按理来说应该是
# macos-latest, 12, green
# windows-latest, 12, green
# macos-latest, 14, green
# windows-latest, 14, green

Relevant log output

DEBU[0000] Job Matrices: [map[os:macos-latest version:12] map[os:macos-latest version:14] map[os:windows-latest version:12] map[os:windows-latest version:14] map[color:green]] 
DEBU[0000] Runner Matrices: map[]                       
DEBU[0000] Final matrix after applying user inclusions '[map[os:macos-latest version:12] map[os:macos-latest version:14] map[os:windows-latest version:12] map[os:windows-latest version:14] map[color:green]]'

Additional information

No response

silky1313 avatar Feb 07 '25 06:02 silky1313

If it is a real problem, I can submit a Pull request to solve it.

silky1313 avatar Feb 07 '25 06:02 silky1313

  • https://github.com/silky1313/matrix/actions/runs/13194792191/job/36833994613 The above workflow confirms that the bug does exist

silky1313 avatar Feb 07 '25 06:02 silky1313

I just ran into this too while trying to have the include entires augmented by the matrix. Glad to see that you already fixed this. Thanks!

unvermuthet avatar Feb 07 '25 13:02 unvermuthet

I just crossed this issue as well and would be nice to have a fix for it as it's creating an extra job for no reason. Thanks again!

julianxhokaxhiu avatar Apr 17 '25 22:04 julianxhokaxhiu