Check the repository's shell scripts for problems:
- Static analysis using ShellCheck.
- Formatting using shfmt.
- Forgotten executable script file permissions.
This is the version of the workflow for projects using the Task task runner tool.
Install the check-shell-task.yml GitHub Actions workflow to .github/workflows/
.editorconfig-shfmtwill use this configuration file.- Install to: repository root
Taskfile.yml- Tasks for checking shell scripts.- Install to: repository root (or merge into the existing
Taskfile.yml).
- Install to: repository root (or merge into the existing
The formatting style defined in .editorconfig is the official standardized style to be used in all Arduino tooling projects and should not be modified.
The tool dependencies of this workflow are managed by Go.
If the project does not already have a go.mod file, install Go and then run the following command:
go mod init <module path>
(where <module path> is the URL of the project repository without the scheme e.g., github.com/foo/bar)
Add the tool dependencies by running the following command:
go get -tool github.com/go-task/task/v3/cmd/task@v3.44.1
Commit the resulting changes to the go.mod and go.sum files.
Configure the paths of the shell scripts to be checked as elements in the job matrices of check-shell-task.yml at:
jobs.lint.strategy.matrix.script[]jobs.formatting.strategy.matrix.script[]jobs.executable.strategy.matrix.script[]
matrix:
script:
- path/to/some-script.sh
- path/to/another-script.shThe workflow is configured to be triggered on changes to any files in the repository that have a .sh or .bash file extension. If the project contains shell scripts without a file extension, the path to those scripts must be added to the following keys in check-shell-task.yml:
on.push.paths[]on.pull_request.paths[]
Markdown badge:
[](https://github.com/TODO_REPO_OWNER/TODO_REPO_NAME/actions/workflows/check-shell-task.yml)Replace the TODO_REPO_OWNER and TODO_REPO_NAME placeholders in the URLs with the final repository owner and name (example).
Asciidoc badge:
image:https://github.com/{repository-owner}/{repository-name}/actions/workflows/check-shell-task.yml/badge.svg["Check Shell Scripts status", link="https://github.com/{repository-owner}/{repository-name}/actions/workflows/check-shell-task.yml"]Define the {repository-owner} and {repository-name} attributes and use them throughout the readme (example).
Add infrastructure to check for problems with shell scripts
Tasks are provided to facilitate the development of the project's shell scripts:
- Detect common problems using ShellCheck.
- Format using shfmt.
- Check for forgotten executable script file permissions.
A GitHub Actions workflow is included to automatically run the tasks. The workflow is triggered on any push or pull that
changes relevant project files, in order to avoid the introduction of problems with the project filesystem. It is also
triggered periodically, in order to catch breakage caused by external changes.
Tasks are provided to facilitate the development of the project's shell scripts:
- Detect common problems using [**ShellCheck**](https://github.com/koalaman/shellcheck).
- Format using [**shfmt**](https://github.com/mvdan/sh).
- Check for forgotten executable script file permissions.
A GitHub Actions workflow is included to automatically run the tasks. The workflow is triggered on any push or pull that changes relevant project files, in order to avoid the introduction of problems with the project filesystem. It is also triggered periodically, in order to catch breakage caused by external changes.In addition to the automated checks provided by the GitHub Actions workflow, the tasks can be ran locally.
The following development tools must be available in your local environment:
- ShellCheck - shell script static analysis tool.
- shfmt - shell script formatting tool.
- Task task runner tool.
task shell:check SCRIPT_PATH="<script path>"
(where <script path> is the path to the script file)
task shell:check-mode SCRIPT_PATH="<script path>"
(where <script path> is the path to the script file)
task shell:format SCRIPT_PATH="<script path>"
(where <script path> is the path to the script file)