actionlint icon indicating copy to clipboard operation
actionlint copied to clipboard

Not truly useable as a tool for developers of reusable actions

Open douglascamata opened this issue 2 years ago • 7 comments

I tried using actionlint in a small reusable Github Action that I develop and I got a lot of false positives (see below).

$ actionlint action.yml 
action.yml:1:1: "on" section is missing in workflow [syntax-check]
  |
1 | name: "Setup Docker on macOS"
  | ^~~~~
action.yml:1:1: "jobs" section is missing in workflow [syntax-check]
  |
1 | name: "Setup Docker on macOS"
  | ^~~~~
action.yml:2:1: unexpected key "description" for "workflow" section. expected one of "concurrency", "defaults", "env", "jobs", "name", "on", "permissions", "run-name" [syntax-check]
  |
2 | description: "Setup Docker on macOS using Colima, Lima-VM, and Homebrew."
  | ^~~~~~~~~~~~
action.yml:3:1: unexpected key "inputs" for "workflow" section. expected one of "concurrency", "defaults", "env", "jobs", "name", "on", "permissions", "run-name" [syntax-check]
  |
3 | inputs:
  | ^~~~~~~
action.yml:8:1: unexpected key "outputs" for "workflow" section. expected one of "concurrency", "defaults", "env", "jobs", "name", "on", "permissions", "run-name" [syntax-check]
  |
8 | outputs:
  | ^~~~~~~~
action.yml:18:1: unexpected key "runs" for "workflow" section. expected one of "concurrency", "defaults", "env", "jobs", "name", "on", "permissions", "run-name" [syntax-check]
   |
18 | runs:
   | ^~~~~

All these missing sections and unexpected keys are completely fine when you are developing a reusable Github Action that gets published in the marketplace. For reference, I ran the tool over this file.

I would love if this tool had a toggle to tell it the action being linted is a reusable one and it could adapt accordingly to such scenario.

Thanks!

douglascamata avatar Sep 05 '23 12:09 douglascamata

AFAIK actionlint is used to lint workflow files, not action files...

AlexandreDecan avatar Sep 06 '23 08:09 AlexandreDecan

Very likely, that's its current state, yes. But why not cover both? 😄

douglascamata avatar Sep 06 '23 09:09 douglascamata

Because linting an Action is different than linting a workflow. The name of the tool is maybe a bit misleading, but its purpose is well defined on the homepage: "actionlint is a static checker for GitHub Actions workflow files."

AlexandreDecan avatar Sep 06 '23 10:09 AlexandreDecan

@AlexandreDecan it's not much different (did I ever say they were the same thing?), besides a few schema items. Anyway, this issue is a suggestion/feature request to the project. A project's purpose might change over time. :)

douglascamata avatar Sep 06 '23 12:09 douglascamata

Indeed :-) But remember you started your message with "I got a lot of false positives", my point was it's not surprising to have false positives if the tool is applied on the wrong file :-D

AlexandreDecan avatar Sep 06 '23 12:09 AlexandreDecan

This might be a duplicate of https://github.com/rhysd/actionlint/issues/46 ?

cmotsn avatar Oct 27 '23 08:10 cmotsn