Skip to content

Enable workflows: Ensure no leading/trailing whitespace is included in specified repo(s) #233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 24, 2025
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
46 changes: 42 additions & 4 deletions dev/tools.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,54 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Run Python code tools (isort, black, flake8)
#
#### SETUP ####################################################################

set -o errexit
set -o errtrace
set -o nounset

printf "\e[1m\e[7m %-80s\e[0m\n" 'isort'
# shellcheck disable=SC2154
trap '_es=${?};
printf "${0}: line ${LINENO}: \"${BASH_COMMAND}\"";
printf " exited with a status of ${_es}\n";
exit ${_es}' ERR

DIR_REPO="$(cd -P -- "${0%/*}/.." && pwd -P)"
# https://en.wikipedia.org/wiki/ANSI_escape_code
E0="$(printf "\e[0m")" # reset
E30="$(printf "\e[30m")" # black foreground
E31="$(printf "\e[31m")" # red foreground
E107="$(printf "\e[107m")" # bright white background

#### FUNCTIONS ################################################################

error_exit() {
# Echo error message and exit with error
echo -e "${E31}ERROR:${E0} ${*}" 1>&2
exit 1
}

print_header() {
# Print 80 character wide black on white heading with time
printf "${E30}${E107}# %-69s$(date '+%T') ${E0}\n" "${@}"
}

#### MAIN #####################################################################

cd "${DIR_REPO}"

print_header 'isort'
# shellcheck disable=SC2068
pipenv run isort ${@:-.}
echo

printf "\e[1m\e[7m %-80s\e[0m\n" 'black'
print_header 'black'
# shellcheck disable=SC2068
pipenv run black ${@:-.}
echo

printf "\e[1m\e[7m %-80s\e[0m\n" 'flake8'
print_header 'flake8'
# shellcheck disable=SC2068
pipenv run flake8 ${@:-.}
echo
2 changes: 2 additions & 0 deletions enable_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def setup():
args.dryrun = ""
if not args.repos:
raise ap.error("at least one (1) REPOSITORY must be specified")
for i, repo in enumerate(args.repos):
args.repos[i] = repo.strip()
return args


Expand Down