feat: add shellcheck & shfmt github actions (#33)
* refactor: separate lint shfmt and shellcheck * feat: add simple github action task * fix: linting bash files according to shfmt * feat: move main method dedicated shell file * feat: update changelog entry
This commit is contained in:
parent
1b97d625e6
commit
23bbbfcaee
5 changed files with 63 additions and 31 deletions
22
.github/workflows/github-actions.yml
vendored
Normal file
22
.github/workflows/github-actions.yml
vendored
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
name: GitHub Actions
|
||||||
|
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
|
||||||
|
on: [push]
|
||||||
|
jobs:
|
||||||
|
lint-shellcheck:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: install shellcheck
|
||||||
|
run: sudo apt-get install -y shellcheck
|
||||||
|
- name: checkout repo
|
||||||
|
uses: actions/checkout@main
|
||||||
|
- name: lint files against shellcheck
|
||||||
|
run: make lint_shellcheck
|
||||||
|
lint-shfmt:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: install shfmt
|
||||||
|
run: sudo apt-get install -y shfmt
|
||||||
|
- name: checkout repo
|
||||||
|
uses: actions/checkout@main
|
||||||
|
- name: lint files against shfmt
|
||||||
|
run: make lint_shfmt
|
|
@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||||
|
|
||||||
- Added light and dark transparent themes [#18](https://github.com/egel/tmux-gruvbox/issues/18)
|
- Added light and dark transparent themes [#18](https://github.com/egel/tmux-gruvbox/issues/18)
|
||||||
- Added editorconfig
|
- Added editorconfig
|
||||||
|
- Added code linters for shellcheck & shfmt [#33](https://github.com/egel/tmux-gruvbox/issues/33)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|
17
Makefile
17
Makefile
|
@ -1,5 +1,12 @@
|
||||||
.PHONY: check-scripts
|
.PHONY: lint_shellcheck
|
||||||
check-scripts:
|
lint_shellcheck:
|
||||||
@# Fail if any of these files have warnings
|
find . -type f -not -path "./uncommited/*" -a \( -iname "*.sh" \) | \
|
||||||
find . -type f -not -path "./uncommited/*" -a \( -iname "*.sh" -o -iname "*.tmux" \) | xargs -I % sh -c 'shellcheck %'
|
xargs -I % sh -c 'shellcheck %'
|
||||||
find . -type f -not -path "./uncommited/*" -a \( -iname "*.sh" -o -iname "*.tmux" \) | xargs -I % sh -c 'shfmt -l -d %'
|
|
||||||
|
.PHONY: lint_shfmt
|
||||||
|
lint_shfmt:
|
||||||
|
find . -type f -not -path "./uncommited/*" -a \( -iname "*.sh" \) | \
|
||||||
|
xargs -I % sh -c 'shfmt -i=2 -l -d -ln=bash %'
|
||||||
|
|
||||||
|
.PHONY: check_scripts
|
||||||
|
check_scripts: lint_shellcheck lint_shfmt
|
||||||
|
|
|
@ -1,30 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
SCRIPT_SRC="$(dirname "${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}")"
|
source "./src/gruvbox-main.sh"
|
||||||
readonly SCRIPT_SRC
|
|
||||||
CURRENT_DIR=$(cd "${SCRIPT_SRC}" >/dev/null 2>&1 && pwd)
|
|
||||||
readonly CURRENT_DIR
|
|
||||||
readonly THEME_OPTION="@tmux-gruvbox"
|
|
||||||
readonly DEFAULT_THEME="dark"
|
|
||||||
|
|
||||||
get_theme() {
|
|
||||||
local option="$1"
|
|
||||||
local default_value="$2"
|
|
||||||
local option_value
|
|
||||||
option_value=$(tmux show-option -gqv "$option")
|
|
||||||
if [ -z "$option_value" ]; then
|
|
||||||
echo "$default_value"
|
|
||||||
else
|
|
||||||
echo "$option_value"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
main() {
|
|
||||||
local theme
|
|
||||||
theme=$(get_theme "$THEME_OPTION" "$DEFAULT_THEME")
|
|
||||||
tmux source-file "$CURRENT_DIR/tmux-gruvbox-${theme}.conf"
|
|
||||||
}
|
|
||||||
|
|
||||||
main "$@"
|
|
||||||
|
|
||||||
# vim: ai et ft=bash
|
# vim: ai et ft=bash
|
||||||
|
|
27
src/gruvbox-main.sh
Executable file
27
src/gruvbox-main.sh
Executable file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
SCRIPT_SRC="$(dirname "${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}")"
|
||||||
|
readonly SCRIPT_SRC
|
||||||
|
CURRENT_DIR=$(cd "${SCRIPT_SRC}" >/dev/null 2>&1 && pwd) readonly CURRENT_DIR
|
||||||
|
readonly THEME_OPTION="@tmux-gruvbox"
|
||||||
|
readonly DEFAULT_THEME="dark"
|
||||||
|
|
||||||
|
get_theme() {
|
||||||
|
local option="$1"
|
||||||
|
local default_value="$2"
|
||||||
|
local option_value
|
||||||
|
option_value=$(tmux show-option -gqv "$option")
|
||||||
|
if [ -z "$option_value" ]; then
|
||||||
|
echo "$default_value"
|
||||||
|
else
|
||||||
|
echo "$option_value"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
local theme
|
||||||
|
theme=$(get_theme "$THEME_OPTION" "$DEFAULT_THEME")
|
||||||
|
tmux source-file "$CURRENT_DIR/tmux-gruvbox-${theme}.conf"
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
Loading…
Add table
Add a link
Reference in a new issue