Skip to content

[BUG] github-workflows-require-timeout.json: timeout-minutes should allow expressions #354

@webknjaz

Description

@webknjaz

$sbj. I want to have timeout-minutes: ${{ inputs.qemu && '60' || '20' }} set for a job. The inputs is a context that exists in reusable workflows. Here's the table of context availability FTR: https://docs.github.com/en/actions/learn-github-actions/contexts.

Here's how it fails for me:

  .github/workflows/reusable-build-wheel.yml::$.jobs.build-wheel: {'name': 'Build wheels on ${{ inputs.os }} ${{ inputs.qemu }}', 'runs-on': '${{ inputs.os }}-latest', 'timeout-minutes': '${{ inputs.qemu && 60 || 20 }}', 'steps': [{'name': 'Retrieve the project source from an sdist inside the GHA artifact', 'uses': 're-actors/checkout-python-sdist@release/v1', 'with': {'source-tarball-name': '${{ inputs.source-tarball-name }}', 'workflow-artifact-name': '${{ inputs.dists-artifact-name }}'}}, {'name': 'Set up QEMU', 'if': 'inputs.qemu', 'uses': 'docker/setup-qemu-action@v3', 'with': {'platforms': 'all'}, 'id': 'qemu'}, {'name': 'Prepare emulation', 'if': 'inputs.qemu', 'run': '# Build emulated architectures only if QEMU is set,\n# use default "auto" otherwise\necho "CIBW_ARCHS_LINUX=${{ inputs.qemu }}" >> "${GITHUB_ENV}"\n', 'shell': 'bash'}, {'name': 'Setup Python', 'uses': 'actions/setup-python@v4'}, {'name': 'Build wheels', 'uses': 'pypa/cibuildwheel@v2.16.2', 'env': {'CIBW_ARCHS_MACOS': 'x86_64 arm64 universal2'}}, {'name': 'Upload built artifacts for testing and publishing', 'uses': 'actions/upload-artifact@v3', 'with': {'name': '${{ inputs.dists-artifact-name }}', 'path': './wheelhouse/*.whl'}}]} is not valid under any of the given schemas
  Underlying errors caused this.

  Best Match:
    $.jobs.build-wheel: 'uses' is a required property
  Best Deep Match:
    $.jobs.build-wheel.timeout-minutes: '${{ inputs.qemu && 60 || 20 }}' is not of type 'number'

Approximate reusable workflow look:

# partial file, specific bit that is failing
on:
  workflow-call:
    inputs:
      ...
      qemu:
          default: ''
          ...
          required: false
          ...
      ...
...
jobs:
  job-id:
    ...
    timeout-minutes: ${{ inputs.qemu && '60' || '20' }}
    ...

Haven't looked into how to fix this, but the upstream github-workflow.json doesn't error out, so this custom schema must be too strict...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions