Skip to content

Commit

Permalink
Add GitHub Actions with ShellCheck
Browse files Browse the repository at this point in the history
See mathiasbynens#951 for details
Okeanos committed Nov 28, 2021
1 parent 83a7a2f commit 03f8e4d
Showing 9 changed files with 54 additions and 23 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -6,3 +6,7 @@ indent_style = tab
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{yaml, yml}]
indent_style = space
tab_width = 2
9 changes: 9 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
time: "03:00"
timezone: Europe/Berlin
open-pull-requests-limit: 99
10 changes: 10 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Test

on: [push, pull_request]

jobs:
shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- uses: bewuethr/shellcheck-action@v2
7 changes: 4 additions & 3 deletions bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

cd "$(dirname "${BASH_SOURCE}")";
cd "$(dirname "${BASH_SOURCE[0]:-$0}")" || exit;

git pull --autostash --rebase;

@@ -15,13 +15,14 @@ function doIt() {
stow --dotfiles -d "stow" "ssh" -t "${HOME}";
stow --dotfiles -d "stow" "vim" -t "${HOME}";
# load new config
# shellcheck disable=SC1090
source ~/.bash_profile;
}

if [ "$1" == "--force" -o "$1" == "-f" ]; then
if [ "$1" == "--force" ] || [ "$1" == "-f" ]; then
doIt;
else
read -p "This may overwrite existing files in your home directory. Are you sure? (y/n) " -n 1;
read -rp "This may overwrite existing files in your home directory. Are you sure? (y/n) " -n 1;
echo "";
if [[ $REPLY =~ ^[Yy]$ ]]; then
doIt;
2 changes: 1 addition & 1 deletion brew.sh
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ echo 'Be sure to add `$(brew --prefix gnu-sed)/libexec/gnubin` to `$PATH`.'
echo 'If you would like to map vi so it opens the brew-installed vim: ln -s /usr/local/bin/vim /usr/local/bin/vi'

# Switch to using brew-installed bash as default shell
if ! fgrep -q "${BREW_PREFIX}/bin/bash" /etc/shells; then
if ! grep -Fq "${BREW_PREFIX}/bin/bash" /etc/shells; then
echo "${BREW_PREFIX}/bin/bash" | sudo tee -a /etc/shells;
chsh -s "${BREW_PREFIX}/bin/bash";
fi;
3 changes: 2 additions & 1 deletion stow/shell/dot-aliases
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
# shellcheck disable=SC2139

# Easier navigation: .., ..., ...., ....., ~ and -
alias ..="cd .."
@@ -123,7 +124,7 @@ alias map="xargs -n1"

# One of @janmoesen’s ProTip™s
for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do
alias "${method}"="lwp-request -m '${method}'"
alias "${method}=lwp-request -m '${method}'"
done

# Stuff I never really use but cannot delete either because of http://xkcd.com/530/
7 changes: 4 additions & 3 deletions stow/shell/dot-bash_prompt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
# shellcheck disable=SC2034

# Shell prompt based on the Solarized Dark theme.
# Screenshot: http://i.imgur.com/EkEtphC.png
@@ -35,19 +36,19 @@ prompt_git() {
s+='*';
else
# Check for uncommitted changes in the index.
if ! $(git diff --quiet --ignore-submodules --cached); then
if ! git diff --quiet --ignore-submodules --cached; then
s+='+';
fi;
# Check for unstaged changes.
if ! $(git diff-files --quiet --ignore-submodules --); then
if ! git diff-files --quiet --ignore-submodules --; then
s+='!';
fi;
# Check for untracked files.
if [ -n "$(git ls-files --others --exclude-standard)" ]; then
s+='?';
fi;
# Check for stashed files.
if $(git rev-parse --verify refs/stash &>/dev/null); then
if git rev-parse --verify refs/stash &>/dev/null; then
s+='$';
fi;
fi;
4 changes: 3 additions & 1 deletion stow/shell/dot-exports
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
# shellcheck disable=SC2154

# Make vim the default editor.
export EDITOR='vim';
@@ -31,7 +32,8 @@ export LESS_TERMCAP_md="${yellow}";

# Avoid issues with `gpg` as installed via Homebrew.
# https://stackoverflow.com/a/42265848/96656
export GPG_TTY=$(tty);
GPG_TTY=$(tty);
export GPG_TTY

# Hide the “default interactive shell is now zsh” warning on macOS.
export BASH_SILENCE_DEPRECATION_WARNING=1;
31 changes: 17 additions & 14 deletions stow/shell/dot-functions
Original file line number Diff line number Diff line change
@@ -2,17 +2,17 @@

# Create a new directory and enter it
function mkd() {
mkdir -p "$@" && cd "$_";
mkdir -p "$@" && cd "$_" || return;
}

# Change working directory to the top-most Finder window location
function cdf() { # short for `cdfinder`
cd "$(osascript -e 'tell app "Finder" to POSIX path of (insertion location as alias)')";
cd "$(osascript -e 'tell app "Finder" to POSIX path of (insertion location as alias)')" || return;
}

# Create a .tar.gz archive, using `zopfli`, `pigz` or `gzip` for compression
function targz() {
local tmpFile="${@%/}.tar";
local tmpFile="${*%/}.tar";
tar -cvf "${tmpFile}" --exclude=".DS_Store" "${@}" || return 1;

size=$(
@@ -51,24 +51,24 @@ function fs() {
else
local arg=-sh;
fi
if [[ -n "$@" ]]; then
if [[ -n "$*" ]]; then
du $arg -- "$@";
else
du $arg .[^.]* ./*;
fi;
}

# Use Git’s colored diff when available
hash git &>/dev/null;
if [ $? -eq 0 ]; then
if hash git &>/dev/null; then
function diff() {
git diff --no-index --color-words "$@";
}
fi;

# Create a data URL from a file
function dataurl() {
local mimeType=$(file -b --mime-type "$1");
local mimeType;
mimeType=$(file -b --mime-type "$1");
if [[ $mimeType == text/* ]]; then
mimeType="${mimeType};charset=utf-8";
fi
@@ -86,9 +86,10 @@ function server() {

# Compare original and gzipped file size
function gz() {
local origsize=$(wc -c < "$1");
local gzipsize=$(gzip -c "$1" | wc -c);
local ratio=$(echo "$gzipsize * 100 / $origsize" | bc -l);
local origsize, gzipsize, ratio;
origsize=$(wc -c < "$1");
gzipsize=$(gzip -c "$1" | wc -c);
ratio=$(echo "$gzipsize * 100 / $origsize" | bc -l);
printf "orig: %d bytes\n" "$origsize";
printf "gzip: %d bytes (%2.2f%%)\n" "$gzipsize" "$ratio";
}
@@ -106,15 +107,17 @@ function getcertnames() {
return 1;
fi;

local domain="${1}";
local domain, tmp, certText;

domain="${1}";
echo "Testing ${domain}";
echo ""; # newline

local tmp=$(echo -e "GET / HTTP/1.0\nEOT" \
tmp=$(echo -e "GET / HTTP/1.0\nEOT" \
| openssl s_client -connect "${domain}:443" -servername "${domain}" 2>&1);

if [[ "${tmp}" = *"-----BEGIN CERTIFICATE-----"* ]]; then
local certText=$(echo "${tmp}" \
certText=$(echo "${tmp}" \
| openssl x509 -text -certopt "no_aux, no_header, no_issuer, no_pubkey, \
no_serial, no_sigdump, no_signame, no_validity, no_version");
echo "Common Name:";
@@ -134,7 +137,7 @@ function getcertnames() {

# Normalize `open` across Linux, macOS, and Windows.
# This is needed to make the `o` function (see below) cross-platform.
if [ ! $(uname -s) = 'Darwin' ]; then
if [ ! "$(uname -s)" = 'Darwin' ]; then
if grep -q Microsoft /proc/version; then
# Ubuntu on Windows using the Linux subsystem
alias open='explorer.exe';

0 comments on commit 03f8e4d

Please sign in to comment.