shellcheck pipeline
Initial work for #129 (closed) for a shellcheck
pipeline step, the general idea is to add it to a breader lint
or codequality
stage.
I got the idea from here: https://gitlab.com/pipeline-components/shellcheck
To be fair, I could've just used that project, but I didn't feel like pulling a specialised image just for this simple task.
The step goes trough every file in the repository (excluding .git), detects scripts based on the file's shebang, and run shellcheck on it. This avoids having to hardcode a list of files to be linted: that would require manual intervention on the pipeline on every new script being added, and potentially missing new scripts from merge requests.
Currently, ash
scripts will be validated as dash
, since ShellCheck has no first class support for ash scripts. We can explicitly specify we want dash validation by adding # shellcheck shell=dash
directive in every ash script, or alternatively I could process hooks/
separately and passing the desired shell from the cli itself.
I originally thought about leveraging gitlab's artifacts and reports, unfortunately shellcheck only produces checkstyle
reports. Their wiki suggests using an xslt to transform the report to junit xml, however I've tried that and the result was less than stellar, it's actually more readable as console output.