mpalmer / action-validator

Tool to validate GitHub Action and Workflow YAML files
GNU General Public License v3.0
282 stars 23 forks source link

Ability to restrict runs-on #66

Open TWiStErRob opened 10 months ago

TWiStErRob commented 10 months ago

Intro

Hey, following recent changes, essentially any value of runs-on: is accepted. Since one of the outcomes of this action is to reduce the possibility of broken workflows, I think it would be very beneficial to validate runs-on somehow.

Proposal

Syntax

Built-in groups

(might be more):

Custom groups

If there's a known list of self hosted runners, it's possible to just list them all and use no groups. That is, to define a custom group, users need to list all runners explicitly.

For reusability the custom groups could be extracted into environment variables / organization level variables, like ACTION_VALIDATOR_ALLOWED_RUNNERS, and then that used in CLI with shell expansion: --allowed-runners=${ACTION_VALIDATOR_ALLOWED_RUNNERS},-ubuntu-latest.

Calculation

i.e. order of flags doesn't matter.

Examples

  1. the default when no argument provided

    --allowed-runners=!github-free
  2. a GitHub Enterprise user might validate like this, if they allow 2 self-hosted runners, and want to be explicit about versions:

--allowed-runners=!github-free,@github-large,-@github-latest,my-special-runner1,my-special-runner2
  1. an open-source community member GitHub user, who wants to use latest without automagic updates:
    --allowed-runners=ubuntu-22.04,windows-2022,macos-12
mpalmer commented 10 months ago

Hi Robert, thanks for starting this convo.

I'm definitely in favour of introducing a way to better validate runs-on values. Not being a custom runner user myself, I'm probably not in a strong position to define a specification for how to do it. Thus, I can at best kibbitz on the work of others.

The only feedback I've got on your proposal so far is that I'm wary of using ! in a command-line argument, as shells have a habit of treating that character specially. I know of programs that use @ as a prefix for group-like behaviour; would that be an acceptable prefix in this case?

TWiStErRob commented 10 months ago

Thanks. I agree with @, changed above and reformatted a bit.

I'm not a self-hosted user either, so let's get opinions from those who do: @MPV (#59), @mathew-fleisch (#5), @deviantintegral (#51)

deviantintegral commented 10 months ago

👏 This all looks good to me. It gives us a way in CI to make sure runners are valid, catching typos in custom runner names.