Skip to content

Latest commit

 

History

History
126 lines (80 loc) · 4.32 KB

check-shell-task.md

File metadata and controls

126 lines (80 loc) · 4.32 KB

"Check Shell Scripts" workflow (Task)

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.

Installation

Workflow

Install the check-shell-task.yml GitHub Actions workflow to .github/workflows/

Assets

The formatting style defined in .editorconfig is the official standardized style to be used in all Arduino tooling projects and should not be modified.

Configuration

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[]

Example:

matrix:
  script:
    - path/to/some-script.sh
    - path/to/another-script.sh

Paths filters

The 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[]

Readme badge

Markdown badge:

[![Check Shell Scripts status](https://github.com/TODO_REPO_OWNER/TODO_REPO_NAME/actions/workflows/check-shell-task.yml/badge.svg)](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).

Commit message

Add CI workflow to check for problems with shell scripts

On every push or pull request that modifies one of the shell scripts in the repository, and periodically, the workflow:

- Runs ShellCheck to detect common problems.
- Runs shfmt to check formatting.
- Checks for forgotten executable script file permissions.

PR message

On every push or pull request that modifies one of the shell scripts in the repository, and periodically, the workflow:

- Runs [ShellCheck](https://github.com/koalaman/shellcheck) to detect common problems.
- Runs [`shfmt`](https://github.com/mvdan/sh) to check formatting.
- Checks for forgotten executable script file permissions.

Usage

In addition to the automated checks provided by the GitHub Actions workflow, the tasks can be ran locally.

Prerequisites

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.

Run static analysis

task shell:check SCRIPT_PATH="<script path>"

(where <script path> is the path to the script file)

Check file permissions

task shell:check-mode SCRIPT_PATH="<script path>"

(where <script path> is the path to the script file)

Format script

task shell:format SCRIPT_PATH="<script path>"

(where <script path> is the path to the script file)