nektos / act

Run your GitHub Actions locally 🚀
https://nektosact.com
MIT License
51.87k stars 1.3k forks source link

act fails to run bash passed as input to reusable workflow #2331

Closed higaski closed 1 month ago

higaski commented 1 month ago

Bug report info

act version:            0.2.62
GOOS:                   linux
GOARCH:                 amd64
NumCPU:                 16
Docker host:            DOCKER_HOST environment variable is not set
Sockets found:
        /var/run/docker.sock
Config files:           
        /home/vinci/.actrc:
                -P ubuntu-latest=catthehacker/ubuntu:full-latest
                -P ubuntu-22.04=catthehacker/ubuntu:full-22.04
                -P ubuntu-20.04=catthehacker/ubuntu:full-20.04
                -P ubuntu-18.04=catthehacker/ubuntu:full-18.04
Build info:
        Go version:            go1.22.2
        Module path:           github.com/nektos/act
        Main version:          (devel)
        Main path:             github.com/nektos/act
        Main checksum:         
        Build settings:
                -buildmode:           pie
                -compiler:            gc
                -trimpath:            true
                DefaultGODEBUG:       httplaxcontentlength=1,httpmuxgo121=1,tls10server=1,tlsrsakex=1,tlsunsafeekm=1
                CGO_ENABLED:          1
                GOARCH:               amd64
                GOOS:                 linux
                GOAMD64:              v1
Docker Engine:
        Engine version:        26.1.2
        Engine runtime:        runc
        Cgroup version:        2
        Cgroup driver:         systemd
        Storage driver:        overlay2
        Registry URI:          https://index.docker.io/v1/
        OS:                    Garuda Linux
        OS type:               linux
        OS version:            
        OS arch:               x86_64
        OS kernel:             6.8.9-zen1-2-zen
        OS CPU:                16
        OS memory:             31241 MB
        Security options:
                name=seccomp,profile=builtin
                name=cgroupns

Command used with act

act

Describe issue

I have a reusable workflow were certain prerequisites can be installed by passing a string to the workflow (e.g. sudo apt install stuff)

on:
  workflow_call:
    inputs:
      pre-build:
        description: 'Pre-build steps to run'
        default: ''
        required: false
        type: string

# see entire workflow below

    runs-on: ubuntu-22.04
    steps:
      - name: Run pre-build steps
        run: ${{ inputs.pre-build }} # this seems to fail?

This works on GitHub, but not locally. I get the following note: docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/2] user= workdir= Then the workflow continuous as if there hasn't been an error.

Link to GitHub repository

No response

Workflow content

name: x86_64-linux-gnu-gcc

on:
  workflow_call:
    inputs:
      pre-build:
        description: 'Pre-build steps to run'
        default: ''
        required: false
        type: string
      args:
        description: 'Additional CMake arguments -D <var>[:<type>]=<value>'
        default: ''
        required: false
        type: string
      target:
        description: 'CMake targets to build'
        default: 'all'
        required: false
        type: string
      post-build:
        description: 'Post-build steps to run'
        default: ''
        required: false
        type: string
      upload-artifact:
        description: 'Upload build folder as artifact "build.tar"'
        default: false
        required: false
        type: boolean

jobs:
  x86_64-linux-gnu-gcc:
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@v4.1.1
        with:
          fetch-depth: 0
      - name: Add toolchain PPA
        run: |
          sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
          sudo apt update -y
          sudo apt install -y gcc-13 g++-13
      - name: Run pre-build steps
        run: ${{ inputs.pre-build }}
      - run: cmake -Bbuild ${{ inputs.args }}
        env:
          CC:   gcc-13
          CXX:  g++-13
      - run: cmake --build build --parallel --target ${{ inputs.target }}
      - name: Run post-build steps
        run: ${{ inputs.post-build }}
      - if: ${{ inputs.upload-artifact }}
        run: tar -cvf build.tar build # https://github.com/actions/upload-artifact#limitations
      - if: ${{ inputs.upload-artifact }}
        uses: actions/upload-artifact@v3.1.3
        with:
          name: build.tar
          path: build.tar

Relevant log output

[tests/x86_64-linux-gnu-gcc/x86_64-linux-gnu-gcc]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/2] user= workdir=
[tests/x86_64-linux-gnu-gcc/x86_64-linux-gnu-gcc]   ✅  Success - Main Run pre-build steps

Additional information

No response

higaski commented 1 month ago

Hm, seems to have been some... caching issue? I'll need to further investigate.

lamhktommy commented 1 month ago

Hi, I got the same issue on this. Is there any workaround / updates on the issue?

higaski commented 1 month ago

Hi, I got the same issue on this. Is there any workaround / updates on the issue?

What recently worked for me was to explicitly pass the inputs to act, so, e.g., if we stick with my example above and we'd want to set the input string pre-build:

act --input pre-build=\"sudo apt install -y ninja-build\"

/edit Sorry, forgot to mention that workaround here.