Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# http://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.json]
insert_final_newline = ignore

[Makefile]
indent_style = tab

# Shell scripts — shfmt reads these properties
[*.sh]
switch_case_indent = true

[*.md]
trim_trailing_whitespace = false
57 changes: 57 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: check

on:
push:

concurrency:
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.sha || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Find bash scripts
id: find-bash
run: |
bash_files=""
# .sh files with bash shebangs
for f in $(find . -name '*.sh' -not -path './.git/*' -not -path './node_modules/*'); do
shebang=$(head -1 "$f")
if echo "$shebang" | grep -qE '(bash|^#!/bin/sh)'; then
bash_files="$bash_files $f"
fi
done
# bin/ scripts without .sh extension
for f in $(find ./bin -maxdepth 1 -type f -not -name '*.sh' -not -path './.git/*'); do
shebang=$(head -1 "$f")
if echo "$shebang" | grep -qE '(bash|^#!/bin/sh)'; then
bash_files="$bash_files $f"
fi
done
echo "files=$bash_files" >> "$GITHUB_OUTPUT"
echo "Found bash files:$bash_files"

- name: ShellCheck
if: steps.find-bash.outputs.files != ''
run: |
bash_files="${{ steps.find-bash.outputs.files }}"
echo "Running ShellCheck on:$bash_files"
shellcheck $bash_files

- name: shfmt check
if: steps.find-bash.outputs.files != ''
run: |
bash_files="${{ steps.find-bash.outputs.files }}"
echo "Running shfmt on:$bash_files"
# -d shows diff; indent settings sourced from .editorconfig
shfmt -d $bash_files

- name: EditorConfig check
uses: editorconfig-checker/action-editorconfig-checker@main

- name: Run editorconfig-checker
run: editorconfig-checker
11 changes: 11 additions & 0 deletions .shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# ShellCheck configuration for nsheaps/git-wt
# https://www.shellcheck.net/wiki/

# Default shell dialect — all scripts in this repo are bash.
shell=bash

# SC1091: Not following sourced files — sourced paths are dynamic
disable=SC1091

# SC2034: Variable appears unused — some variables are used in tests or exported
disable=SC2034
Loading
Loading