nektos / act

Run your GitHub Actions locally ๐Ÿš€
https://nektosact.com
MIT License
54.84k stars 1.37k forks source link

Unexpected matrix include behaviour #2220

Open jmount-boss opened 8 months ago

jmount-boss commented 8 months ago

Bug report info

act version:            0.2.59
GOOS:                   linux
GOARCH:                 amd64
NumCPU:                 12
Docker host:            DOCKER_HOST environment variable is not set
Sockets found:
    /var/run/docker.sock
Config files:           
    /home/james/.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.20.13
    Module path:           github.com/nektos/act
    Main version:          (devel)
    Main path:             github.com/nektos/act
    Main checksum:         
    Build settings:
        -buildmode:           exe
        -compiler:            gc
        -ldflags:             -s -w -X main.version=0.2.59 -X main.commit=b7a8145d09a7469e03c57e24230cbba109218faf -X main.date=2024-02-01T22:32:29Z -X main.builtBy=goreleaser
        CGO_ENABLED:          0
        GOARCH:               amd64
        GOOS:                 linux
        GOAMD64:              v1
        vcs:                  git
        vcs.revision:         b7a8145d09a7469e03c57e24230cbba109218faf
        vcs.time:             2024-02-01T22:32:06Z
        vcs.modified:         false
Docker Engine:
    Engine version:        25.0.1
    Engine runtime:        runc
    Cgroup version:        2
    Cgroup driver:         systemd
    Storage driver:        overlay2
    Registry URI:          https://index.docker.io/v1/
    OS:                    Ubuntu 22.04.3 LTS
    OS type:               linux
    OS version:            22.04
    OS arch:               x86_64
    OS kernel:             6.1.0-1033-oem
    OS CPU:                12
    OS memory:             39770 MB
    Security options:
        name=apparmor
        name=seccomp,profile=builtin
        name=cgroupns

Command used with act

act -W '.github/workflows/build.yml'

Describe issue

The matrix configuration appears to be inconsistent with the documentation provided by Github here. Expected only 6 configurations, yet Act runs 7. The matrix configuration '{color: green}' should not exist according to the Github documentation.

Link to GitHub repository

No response

Workflow content

name: Build & Test

on:
  push:

# Global environment variables

jobs:
  build:
    runs-on: ubuntu-20.04
    strategy:
      matrix:
        fruit: [apple, pear]
        animal: [cat, dog]
        include:
          - color: green
          - color: pink
            animal: cat
          - fruit: apple
            shape: circle
          - fruit: banana
          - fruit: banana
            animal: cat

    steps: 
      - name: Matrix Configuration
        run: |
          echo "Color: ${{ matrix.color }}"

Relevant log output

[Build & Test/build-1] ๐Ÿš€  Start image=catthehacker/ubuntu:act-20.04
[Build & Test/build-2] ๐Ÿš€  Start image=catthehacker/ubuntu:act-20.04
[Build & Test/build-3] ๐Ÿš€  Start image=catthehacker/ubuntu:act-20.04
[Build & Test/build-4] ๐Ÿš€  Start image=catthehacker/ubuntu:act-20.04
INFO[0000] Parallel tasks (0) below minimum, setting to 1 
[Build & Test/build-2]   ๐Ÿณ  docker pull image=catthehacker/ubuntu:act-20.04 platform= username= forcePull=true
INFO[0000] Parallel tasks (0) below minimum, setting to 1 
[Build & Test/build-4]   ๐Ÿณ  docker pull image=catthehacker/ubuntu:act-20.04 platform= username= forcePull=true
INFO[0000] Parallel tasks (0) below minimum, setting to 1 
[Build & Test/build-1]   ๐Ÿณ  docker pull image=catthehacker/ubuntu:act-20.04 platform= username= forcePull=true
INFO[0000] Parallel tasks (0) below minimum, setting to 1 
[Build & Test/build-3]   ๐Ÿณ  docker pull image=catthehacker/ubuntu:act-20.04 platform= username= forcePull=true
INFO[0003] Parallel tasks (0) below minimum, setting to 1 
[Build & Test/build-3]   ๐Ÿณ  docker create image=catthehacker/ubuntu:act-20.04 platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
INFO[0003] Parallel tasks (0) below minimum, setting to 1 
[Build & Test/build-4]   ๐Ÿณ  docker create image=catthehacker/ubuntu:act-20.04 platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
INFO[0003] Parallel tasks (0) below minimum, setting to 1 
[Build & Test/build-2]   ๐Ÿณ  docker create image=catthehacker/ubuntu:act-20.04 platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
INFO[0003] Parallel tasks (0) below minimum, setting to 1 
[Build & Test/build-1]   ๐Ÿณ  docker create image=catthehacker/ubuntu:act-20.04 platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
[Build & Test/build-3]   ๐Ÿณ  docker run image=catthehacker/ubuntu:act-20.04 platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
[Build & Test/build-4]   ๐Ÿณ  docker run image=catthehacker/ubuntu:act-20.04 platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
[Build & Test/build-2]   ๐Ÿณ  docker run image=catthehacker/ubuntu:act-20.04 platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
[Build & Test/build-1]   ๐Ÿณ  docker run image=catthehacker/ubuntu:act-20.04 platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
[Build & Test/build-2] ๐Ÿงช  Matrix: map[animal:dog fruit:apple shape:circle]
[Build & Test/build-3] ๐Ÿงช  Matrix: map[animal:cat color:pink fruit:pear]
[Build & Test/build-4] ๐Ÿงช  Matrix: map[animal:dog fruit:pear]
[Build & Test/build-3] โญ Run Main Matrix Configuration
[Build & Test/build-2] โญ Run Main Matrix Configuration
[Build & Test/build-1] ๐Ÿงช  Matrix: map[animal:cat color:pink fruit:apple shape:circle]
[Build & Test/build-4] โญ Run Main Matrix Configuration
[Build & Test/build-2]   ๐Ÿณ  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/0] user= workdir=
[Build & Test/build-3]   ๐Ÿณ  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/0] user= workdir=
[Build & Test/build-1] โญ Run Main Matrix Configuration
[Build & Test/build-4]   ๐Ÿณ  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/0] user= workdir=
| Object
[Build & Test/build-4]   โœ…  Success - Main Matrix Configuration
| Object
| Object
[Build & Test/build-2]   โœ…  Success - Main Matrix Configuration
[Build & Test/build-3]   โœ…  Success - Main Matrix Configuration
[Build & Test/build-4] Cleaning up container for job build
[Build & Test/build-1]   ๐Ÿณ  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/0] user= workdir=
[Build & Test/build-2] Cleaning up container for job build
[Build & Test/build-3] Cleaning up container for job build
| Object
[Build & Test/build-1]   โœ…  Success - Main Matrix Configuration
[Build & Test/build-1] Cleaning up container for job build
[Build & Test/build-4] ๐Ÿ  Job succeeded
[Build & Test/build-2] ๐Ÿ  Job succeeded
[Build & Test/build-5] ๐Ÿš€  Start image=catthehacker/ubuntu:act-20.04
[Build & Test/build-6] ๐Ÿš€  Start image=catthehacker/ubuntu:act-20.04
INFO[0003] Parallel tasks (0) below minimum, setting to 1 
[Build & Test/build-6]   ๐Ÿณ  docker pull image=catthehacker/ubuntu:act-20.04 platform= username= forcePull=true
INFO[0003] Parallel tasks (0) below minimum, setting to 1 
[Build & Test/build-5]   ๐Ÿณ  docker pull image=catthehacker/ubuntu:act-20.04 platform= username= forcePull=true
[Build & Test/build-1] ๐Ÿ  Job succeeded
[Build & Test/build-7] ๐Ÿš€  Start image=catthehacker/ubuntu:act-20.04
INFO[0003] Parallel tasks (0) below minimum, setting to 1 
[Build & Test/build-7]   ๐Ÿณ  docker pull image=catthehacker/ubuntu:act-20.04 platform= username= forcePull=true
[Build & Test/build-3] ๐Ÿ  Job succeeded
INFO[0006] Parallel tasks (0) below minimum, setting to 1 
[Build & Test/build-6]   ๐Ÿณ  docker create image=catthehacker/ubuntu:act-20.04 platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
INFO[0006] Parallel tasks (0) below minimum, setting to 1 
[Build & Test/build-7]   ๐Ÿณ  docker create image=catthehacker/ubuntu:act-20.04 platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
INFO[0006] Parallel tasks (0) below minimum, setting to 1 
[Build & Test/build-5]   ๐Ÿณ  docker create image=catthehacker/ubuntu:act-20.04 platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
[Build & Test/build-6]   ๐Ÿณ  docker run image=catthehacker/ubuntu:act-20.04 platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
[Build & Test/build-7]   ๐Ÿณ  docker run image=catthehacker/ubuntu:act-20.04 platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
[Build & Test/build-5]   ๐Ÿณ  docker run image=catthehacker/ubuntu:act-20.04 platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
[Build & Test/build-6] ๐Ÿงช  Matrix: map[fruit:banana]
[Build & Test/build-7] ๐Ÿงช  Matrix: map[animal:cat fruit:banana]
[Build & Test/build-5] ๐Ÿงช  Matrix: map[color:green]
[Build & Test/build-6] โญ Run Main Matrix Configuration
[Build & Test/build-7] โญ Run Main Matrix Configuration
[Build & Test/build-5] โญ Run Main Matrix Configuration
[Build & Test/build-6]   ๐Ÿณ  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/0] user= workdir=
[Build & Test/build-7]   ๐Ÿณ  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/0] user= workdir=
[Build & Test/build-5]   ๐Ÿณ  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/0] user= workdir=
| Object
[Build & Test/build-6]   โœ…  Success - Main Matrix Configuration
| Object
| Object
[Build & Test/build-7]   โœ…  Success - Main Matrix Configuration
[Build & Test/build-5]   โœ…  Success - Main Matrix Configuration
[Build & Test/build-6] Cleaning up container for job build
[Build & Test/build-7] Cleaning up container for job build
[Build & Test/build-5] Cleaning up container for job build
[Build & Test/build-6] ๐Ÿ  Job succeeded
[Build & Test/build-7] ๐Ÿ  Job succeeded
[Build & Test/build-5] ๐Ÿ  Job succeeded

Additional information

No response

jaraco commented 5 months ago

I believe I've also encountered a related issue when working on pypa/setuptools#4310, whose config has a distutils factor in the matrix config that is only set on one include. However, when I run this configuration with act --job test --matrix python:3.10 --matrix platform:ubuntu-latest --matrix distutils:stdlib, I get two jobs, one for distutils:stdlib and another for distutils being unset:

[tests/test-1] ๐Ÿงช  Matrix: map[platform:ubuntu-latest python:3.10]
[tests/test-2] ๐Ÿงช  Matrix: map[distutils:stdlib platform:ubuntu-latest python:3.10]

Best I can tell, it's not possible to run just the job for distutils:stdlib due to this bug.

act version 0.2.62

``` act version: 0.2.62 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/jaraco/Library/Application Support/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.22.2 Module path: command-line-arguments Main version: Main path: Main checksum: Build settings: -buildmode: exe -compiler: gc -ldflags: -X main.version=0.2.62 DefaultGODEBUG: httplaxcontentlength=1,httpmuxgo121=1,tls10server=1,tlsrsakex=1,tlsunsafeekm=1 CGO_ENABLED: 1 CGO_CFLAGS: CGO_CPPFLAGS: CGO_CXXFLAGS: CGO_LDFLAGS: GOARCH: arm64 GOOS: darwin Docker Engine: Engine version: 26.0.0 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.6.22-linuxkit OS CPU: 12 OS memory: 7840 MB Security options: name=seccomp,profile=unconfined name=cgroupns ```

I was able to temporarily work around the issue by making the distutils factor explicit in the matrix for the matching value:

 setuptools feature/pep-621 @ git diff
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index ec2e567a1..903c7060c 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -53,6 +53,7 @@ jobs:
           platform: ubuntu-latest
         - python: "3.10"
           platform: ubuntu-latest
+          distutils: local
         - python: "3.11"
           platform: ubuntu-latest
         - python: pypy3.10