rhysd / actionlint

:octocat: Static checker for GitHub Actions workflow files
https://rhysd.github.io/actionlint/
MIT License
2.49k stars 149 forks source link

[BUG] `timeout-minutes` should allow expressions (but it demands `floats`) #384

Closed webknjaz closed 4 weeks ago

webknjaz commented 5 months ago

The same problem has just been fixed in the jsonschema based linter: https://github.com/python-jsonschema/check-jsonschema/issues/354.

TL;DR the field should be either an expression or an integer. I don't think GHA actually allows floats in there like the error implies:

$ pre-commit run actionlint-docker --all-files -v 
Lint GitHub Actions workflow files.......................................Failed
- hook id: actionlint-docker
- duration: 1.03s
- exit code: 1

.github/workflows/reusable-build-wheel.yml:42:22: type of expression at "float number value" must be number but found type string [expression]
   |
42 |     timeout-minutes: ${{ inputs.qemu && 60 || 20 }}
   |                      ^~~
rhysd commented 2 months ago
on: push
jobs:
  test:
    runs-on: ubuntu-latest
    timeout-minutes: ${{ true && 60 || 20 }}
    steps:
      - run: echo hello

I tried this workflow and actionlint reported no error. What is the type of inputs.qemu?

webknjaz commented 2 months ago

It's a string, so it's falsy when empty: https://github.com/aio-libs/yarl/blob/bd5ff24/.github/workflows/reusable-build-wheel.yml#L26

rhysd commented 4 weeks ago

Thanks. I could reproduce it.

on: push
jobs:
  test:
    runs-on: ubuntu-latest
    timeout-minutes: ${{ '...' && 60 || 20 }}
    steps:
      - run: echo hello