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
20 changes: 20 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Description

Jira Ticket: https://yexttest.atlassian.net/browse/[ TICKET_NUMBER ]

<!--Please include a summary of the changes and the related issue. Please also include relevant motivation and context. If fixing a bug, be explicit about why these changes address the issue at hand and detail the root cause if possible. If you have modified any configuration files, explain the context. List any dependencies that are required for this change. -->

# Screenshots/GIFS

<!-- If the change is a bugfix or modification of existing behavior, include before and after screenshots/gifs/videos. If it is net new functionality, include a screenshot/gif/video of the new UI. -->

# Checklist

<!-- Remove any that don't apply -->

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have made corresponding changes to any relevant documentation
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ nosetests.xml

# Virtualenv
.venv

# Other
.pypirc
.git
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Contributors
| `Akshay Shah <http://github.com/akshayjshah>`_
| `Dale Hui <http://github.com/dhui>`_
| `Istvan Nemeth <http://github.com/archiezgg>`_
| `Lachlan Imel <http://github.com/limelator>`_
| `Robert MacCloy <http://github.com/rbm>`_
| `Sam Vilain <http://github.com/samv>`_
| `Wyatt Paul <http://github.com/wyguy444>`_
35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
REPO = $(shell git rev-parse --show-toplevel)
POETRY = poetry

hooks:
${REPO}/githooks/update_githooks.sh

install-build:
${POETRY} install --only=main

install-dev:
${POETRY} install

poetry:
curl -sSL https://install.python-poetry.org | POETRY_VERSION=2.1.3 python3 -
poetry cache clear pypi --all
poetry config virtualenvs.in-project true

quickstart: poetry install-dev hooks

quickstart-build: poetry install-build hooks

clean:
# Delete all .pyc and .pyo files.
find ${REPO} \( -name "*~" -o -name "*.py[co]" -o -name ".#*" -o -name "#*#" \) -exec rm '{}' +
rm -rf .pytest_cache

lint: clean
${POETRY} run flake8 --config=${REPO}/.flake8 ${REPO}/src/richenum
${POETRY} run pylint --rcfile=${REPO}/pylint.rc ${REPO}/src/richenum

test: clean
${POETRY} run pytest

build:
${POETRY} build
77 changes: 77 additions & 0 deletions githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/env bash

# Pre-commit linting.
#
# To skip any of these checks touch any of these bypass_* files in the
# project root.
# bypass_flake8
# bypass_tabs
#
# To bypass Flake8 checking for a particular line, add '# noqa' as an
# inline comment.

REPO_ROOT=$(git rev-parse --show-toplevel)

function get_temp_file {
export TMPDIR=/tmp # OSX compat
echo `mktemp tmp.pre-commit.XXXXXXXXXX`
}

function flake8_check {
local temp_file
temp_file=$1
poetry run flake8 --config="${REPO_ROOT}/.flake8" "$temp_file"
return $?
}

function tab_check {
local temp_file
temp_file=$1
if grep -q $'\t' $temp_file; then
return 1
else
return 0
fi
}

function run_check {
local run_type
local display_name
local file_ext
local callback
run_type=$1
display_name=$2
file_ext=$3 # the file extension to check against
callback=$4 # callback should take the (temporary) file to check

if [ -e $REPO_ROOT/bypass_$run_type ]; then
echo "Bypassed $display_name check."
rm $REPO_ROOT/bypass_$run_type 2> /dev/null # don't bypass the check next time.
else
# Only check staged files that match the extension.
# The --diff-filter option matches everything except for (D)eleted files.
echo "Running $display_name checker..."
local files
files=`git diff --staged --name-only --diff-filter=ACMRTUXB | grep "\.${file_ext}\$"`
for file in $files; do
local temp_file
temp_file=$(get_temp_file)
git show :0:$file > $temp_file # check the staged version of the file

local ret
$callback $temp_file
ret=$?

rm $temp_file # clean up the temp file, the callback should never exit
if [ $ret -ne 0 ]
then
echo "Not committing since there are ${display_name} errors in $file."
exit 1
fi
done
fi
}

# Flake8 checks for tab indentation in Python.
run_check flake8 Flake8 py flake8_check
run_check tabs TabCharacter sh tab_check
8 changes: 8 additions & 0 deletions githooks/update_githooks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
# Update our githooks.

REPO_ROOT=$(git rev-parse --show-toplevel)
src_dir="${REPO_ROOT}/githooks/"
dest_dir="${REPO_ROOT}/.git/hooks"

cp $src_dir/* $dest_dir
Loading