Merge branch '2-devop-env'
commit
5287fd818e
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# This hook checks if the commit message ends with an issue number, and if not,
|
||||
# tries to derive that number from the branch name
|
||||
|
||||
branch=`git rev-parse --abbrev-ref HEAD`
|
||||
|
||||
# This check doesn't need to run when commiting to develop/master
|
||||
[[ "$branch" =~ ^master|develop$ ]] && exit 0
|
||||
|
||||
issue_num=`echo "$branch" | grep -Po '^[0-9]+(?=-)'`
|
||||
|
||||
# Check if issue number is already present
|
||||
if ! grep -q '([0-9]\+)$' "$1"; then
|
||||
# Error out if we can't derive issue number
|
||||
[[ -z "$issue_num" ]] && {
|
||||
>&2 echo "Couldn't derive issue number from branch. Please add one manually.";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# Append issue number, and remove all comments
|
||||
echo "[#$issue_num]" "$(cat "$1")" > "$1"
|
||||
fi
|
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# This hook lints the code, and if we're on develop or master, also forces the tests to pass.
|
||||
|
||||
|
||||
branch=`git rev-parse --abbrev-ref HEAD`
|
||||
|
||||
# TODO should we add release branches here as well?
|
||||
if [[ "$branch" =~ ^master|develop$ ]]; then
|
||||
make test > /dev/null 2>&1 || {
|
||||
>&2 echo "Tests failed. check 'make test' for more info.";
|
||||
exit 1;
|
||||
}
|
||||
fi
|
|
@ -0,0 +1,41 @@
|
|||
# =====CONFIG=====
|
||||
PYTHON := python3.9
|
||||
# This can't contain spaces (I think)
|
||||
VENV := venv
|
||||
|
||||
|
||||
# By default, just create the venv when needed
|
||||
all: venv
|
||||
|
||||
|
||||
# Create the venv
|
||||
$(VENV)/bin/activate: requirements.txt requirements-dev.txt
|
||||
@ '$(PYTHON)' -m venv '$(VENV)'
|
||||
@ '$(VENV)'/bin/pip install -r requirements.txt -r requirements-dev.txt
|
||||
|
||||
# Convenient alias for the venv
|
||||
venv: $(VENV)/bin/activate
|
||||
.PHONY: venv
|
||||
|
||||
|
||||
# Remove the venv
|
||||
clean:
|
||||
@ rm -rf '$(VENV)'
|
||||
|
||||
|
||||
# Run the Flask server
|
||||
# TODO
|
||||
run: venv
|
||||
|
||||
|
||||
# Format the codebase using black
|
||||
format: venv
|
||||
@ '$(VENV)/bin/python' -m black src
|
||||
|
||||
# Lint the codebase using flake8
|
||||
lint: venv
|
||||
@ '$(VENV)/bin/python' -m flake8 src
|
||||
|
||||
# Run rests using pytest
|
||||
# TODO
|
||||
test: venv
|
|
@ -0,0 +1,11 @@
|
|||
# Formatter
|
||||
black~=20.8b1
|
||||
|
||||
# Linter
|
||||
flake8~=3.9.0
|
||||
|
||||
# Testing suite
|
||||
pytest~=6.2.2
|
||||
|
||||
# Language server
|
||||
jedi~=0.18.0
|
|
@ -0,0 +1,2 @@
|
|||
# Web framework
|
||||
Flask~=1.1.2
|
Reference in New Issue