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

Matrix include error #2648

Open
silky1313 opened this issue Feb 7, 2025 · 3 comments
Open

Matrix include error #2648

silky1313 opened this issue Feb 7, 2025 · 3 comments
Labels
kind/bug Something isn't working

Comments

@silky1313
Copy link

silky1313 commented Feb 7, 2025

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 silky1313 added the kind/bug Something isn't working label Feb 7, 2025
@silky1313
Copy link
Author

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

@silky1313
Copy link
Author

@unvermuthet
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants