nektos / act

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

Parsing of Yaml workflow file fails with valid github action syntax #1216

Closed jazanne closed 2 years ago

jazanne commented 2 years ago

Bug report info

act version:            0.2.26
GOOS:                   darwin
GOARCH:                 amd64
NumCPU:                 16
Docker host:            DOCKER_HOST environment variable is unset/empty.
Sockets found:
    /var/run/docker.sock
Config files:           
    /Users/jwhite/.actrc:
        -P ubuntu-latest=node:16-buster-slim
        -P ubuntu-20.04=node:16-buster-slim
        -P ubuntu-18.04=node:16-buster-slim
Docker Engine:
    Engine version:        20.10.14
    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:               x86_64
    OS kernel:             5.10.104-linuxkit
    OS CPU:                8
    OS memory:             9963 MB
    Security options:
        name=seccomp,profile=default
        name=cgroupns

Command used with act

act -j smoke-test-test -s SDK_KEY=<SOME KEY>

Describe issue

YAML linting of workflow files is too aggressive and doesn't respect valid input

According to GHA docs, an expression is valid for timeout-minutes.

Link to GitHub repository

No response

Workflow content

name: Smoke test Production
on: workflow_dispatch

jobs:
  smoke-test-test:
    runs-on: ubuntu-latest
    name: Smoke test production
    steps:
      - name: Checkout GitHub Action Repo
        uses: actions/checkout@v3
        with:
          repository: launchdarkly/gha-flags
          path: .github/actions/gha-flags
      - name: Evaluate flags
        id: flags
        uses: ./gha-flags
        with:
          base-uri: 'https://app.ld.catamorphic.com'
          events-uri: 'https://events.ld.catamorphic.com'
          stream-uri: 'https://stream.ld.catamorphic.com'
          sdk-key: ${{ secrets.LD_SDK_KEY_PROD }}
          flag-keys: |
            gha-smoke-test-timeout
      - name: Checkout
        uses: actions/checkout@v3
      - name: Cypress run
        timeout-minutes: ${{ fromJSON(steps.flags.outputs.gha-smoke-test-timeout) }}
        uses: cypress-io/github-action@v3.1.0 # must be locked because of yarn berry issue
        with:
          # Note: this is used because of cypress yarn berry issue
          # https://github.com/cypress-io/github-action/issues/430#issuecomment-1144054512
          command: yarn dlx cypress@v9 run --headless --record --tag production,smoke --config baseUrl=https://docs.launchdarkly.com,retries=2 --spec cypress/integration/smoke.test.ts --config-file cypress.json
          install-command: yarn install --immutable
          build: yarn build-nav-data
          config: baseUrl=https://docs.launchdarkly.com,retries=2
          wait-on: 'https://docs.launchdarkly.com/home'
        env:
          CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}
          CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: Check Cypress outcome
        if: steps.cypress.outcome == 'failure' || steps.cypress.outcome == 'cancelled'
        run: exit 1

Relevant log output

DEBU[0000] Loading environment from /Users/jwhite/code/launchdarkly/git-gatsby/.env 
DEBU[0000] Loading secrets from /Users/jwhite/code/launchdarkly/git-gatsby/.secrets 
DEBU[0000] Loading workflows from '/Users/jwhite/code/launchdarkly/git-gatsby/.github/workflows' 
DEBU[0000] Loading workflows recursively                 
DEBU[0000] Found workflow 'smoke-test-prod.yml' in '/Users/jwhite/code/launchdarkly/git-gatsby/.github/workflows/smoke-test-prod.yml' 
DEBU[0000] Reading workflow '/Users/jwhite/code/launchdarkly/git-gatsby/.github/workflows/smoke-test-prod.yml' 
Error: yaml: unmarshal errors:
  line 27: cannot unmarshal !!str `${{ fro...` into int64

Additional information

Is there a work-around to disable linting? It's putting me in a position where I need to do testing on github itself.

catthehacker commented 2 years ago

It's not linting, it's parsing the yaml

jazanne commented 2 years ago

well either way it's incorrect, because it throws an error for valid github workflow syntax.

rainabba commented 1 year ago

Why was this closed? I'm experiencing the same due to the following, which is valid and used in production workflows.

image

Error: yaml: unmarshal errors:
  line 58: cannot unmarshal !!str `fromJso...` into []interface {}
KnisterPeter commented 1 year ago

You need write valid yaml syntax. Use a yaml linter.