actions-linter icon indicating copy to clipboard operation
actions-linter copied to clipboard

Enhancement: check syntax of `run` steps using bash

Open Mr0grog opened this issue 3 years ago • 0 comments

First, this action is absolutely fantastic, thank you! I plan to add it most places I use workflows. 😄

A lot of Workflows I’ve seen use plenty of run steps with small amounts of logic, usually written in bash. It would be really lovely if it could also check the syntax of those scripts for obvious errors. I’m not sure if this fits best here (because it’s somewhat separate from parsing) or https://github.com/cschleiden/github-actions-parser (happy to re-file this there if so).

If helpful, I threw together a poor prototype of this using bash -n here: https://github.com/Mr0grog/actions-sandbox/pull/7

It prints out results like so:

Validating workflows in .github/workflows...
✘ ERROR: covid-data-data.yml job "build", step "Install Data Scraper & Dependencies"
  line 9: syntax error near unexpected token `fi'
  line 9: `fi'
  
✔︎ covid-data-data.yml job "build", step "Scrape Data"
✔︎ covid-data-news.yml job "build", step "Log workspace path"
✔︎ covid-data-news.yml job "build", step "Install Data Scraper & Dependencies"
✔︎ covid-data-news.yml job "build", step "Scrape News"
✔︎ covid-data-news.yml job "build", step "Scrape Data"
✔︎ validate-workflows.yml job "lint_workflow_run_steps_node", step "Install Dependencies"
✔︎ validate-workflows.yml job "lint_workflow_run_steps_node", step "Lint Workflow Scripts"
✔︎ validate-workflows.yml job "lint_workflow_run_steps_python", step "Install Dependencies"
✔︎ validate-workflows.yml job "lint_workflow_run_steps_python", step "Lint Workflow Scripts"

But obviously would be even nicer if they showed up as checks like you’re already doing with existing validation errors in this action.

Mr0grog avatar Mar 03 '21 05:03 Mr0grog