actions / runner

The Runner for GitHub Actions :rocket:
https://github.com/features/actions
MIT License
4.78k stars 934 forks source link

Action matrix schema is invalid #2366

Open ben-wilson-peak opened 1 year ago

ben-wilson-peak commented 1 year ago

Describe the bug The schema for validating actions is invalid for matrices. In the online editor it marks a job as invalid, but the runner understands the syntax and is arguably a completely valid and useful way to define the matrix

To Reproduce Steps to reproduce the behavior:

  1. Using the online action editor
  2. Create a new action
  3. Add a matrix like this:
    strategy:
      matrix:
        bar:
          - os: macos-latest
            version: 12
            environment: prod
          - os: windows-latest
            version: 16
          - os: ubuntu-latest
            version: 16
  4. You should see (in the example foo) is underlined with Matrix options must only contain primitive values

Expected behavior Linting should not highlight the matrix as invalid, the runner accepts it and is presumably supported syntax

Runner Version and Platform

N/A

What's not working?

See instructions

image

Job Log Output

N/A

Runner and Worker's Diagnostic Logs

N/A

Adding the term "Matrix options must only contain primitive values" as plain text so google can pick it up for indexing if others have the problem. You're welcome :D

ben-wilson-peak commented 1 year ago

I've filed this as a bug under this repository because the schema is located here, nor is this a support request. I'd like clarification on if it is intended to be supported and if so this should be considered a valid bug request. Much appreciated for any help!

ruvceskistefan commented 1 year ago

Hey @ben-wilson-peak,

custom names are for primitive values, for example

os: [macos-latest, windows-latest, ubuntu-latest]

If you want array of objects you can use include as shown below

matrix:
  include:
       - os: macos-latest
          version: 12
          environment: prod
       - os: windows-latest
          version: 16
       - os: ubuntu-latest
          version: 16
ben-wilson-peak commented 1 year ago

Hey @ben-wilson-peak,

custom names are for primitive values, for example

os: [macos-latest, windows-latest, ubuntu-latest]

If you want array of objects you can use include as shown below

matrix:
  include:
       - os: macos-latest
          version: 12
          environment: prod
       - os: windows-latest
          version: 16
       - os: ubuntu-latest
          version: 16

Hi, the runner supports more than primitives in custom names, it's just the json spec which is suggesting otherwise. I'm using it right now, as are many others. The only problem is it's not documented, it shows up as invalid in the editor and in the long run we don't know that it's supported (which is silly since include is just a merge).

I use this currently in json payloads to configure the matrix dynamically

rotu commented 1 year ago

Related: the matrix context documentation says that all properties are string-valued, which is even more restrictive than primitive values.

https://github.com/github/docs/issues/26469

github-actions[bot] commented 1 month ago

This issue is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 15 days.

rotu commented 1 month ago

🍞