-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from hackersandslackers/feature/python10-flask…
…3-migration Python v3.10 & Flask v3 Update
- Loading branch information
Showing
29 changed files
with
835 additions
and
773 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FLASK_ENV=development | ||
FLASK_APP=wsgi.py | ||
FLASK_DEBUG=True | ||
LESS_BIN=/usr/local/bin/lessc | ||
SECRET_KEY="HGuitfI&uf6i7r&ujHFc" | ||
FLASK_DEBUG=False | ||
LESS_BIN="/Users/myuser/.nvm/versions/node/v18.18.1/bin/lessc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a single version of Python | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | ||
|
||
name: Python application | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
pull_request: | ||
branches: [master] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
cache: "pip" # caching pip dependencies | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install flake8 pytest | ||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
- name: Lint with flake8 | ||
run: | | ||
# stop the build if there are Python syntax errors or undefined names | ||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | ||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,96 @@ | ||
SRCPATH := $(CURDIR) | ||
PROJECTNAME := $(shell basename $(CURDIR)) | ||
PROJECT_NAME := $(shell basename $CURDIR) | ||
VIRTUAL_ENV := $(CURDIR)/.venv | ||
LOCAL_PYTHON := $(VIRTUAL_ENV)/bin/python3 | ||
|
||
define HELP | ||
Manage $(PROJECTNAME). Usage: | ||
Manage $(PROJECT_NAME). Usage: | ||
|
||
make run - Run $(PROJECT_NAME) locally. | ||
make install - Create local virtualenv & install dependencies. | ||
make deploy - Set up project & run locally. | ||
make update - Update dependencies via Poetry and output resulting `requirements.txt`. | ||
make format - Run Python code formatter & sort dependencies. | ||
make lint - Check code formatting with flake8. | ||
make clean - Remove extraneous compiled files, caches, logs, etc. | ||
|
||
make run - Run $(PROJECTNAME). | ||
make deploy - Install requirements and run app for the first time. | ||
make update - Update pip dependencies via Python Poetry. | ||
make format - Format code with Python's `Black` library. | ||
make clean - Remove cached files and lock files. | ||
endef | ||
export HELP | ||
|
||
.PHONY: run deploy update format clean help | ||
|
||
|
||
requirements: .requirements.txt | ||
|
||
|
||
.requirements.txt: requirements.txt | ||
$(shell . .venv/bin/activate && pip install -r requirements.txt) | ||
|
||
.PHONY: run install deploy update format lint clean help | ||
|
||
all help: | ||
@echo "$$HELP" | ||
|
||
env: $(VIRTUAL_ENV) | ||
|
||
$(VIRTUAL_ENV): | ||
if [ ! -d $(VIRTUAL_ENV) ]; then \ | ||
echo "Creating Python virtual env in \`${VIRTUAL_ENV}\`"; \ | ||
python3 -m venv $(VIRTUAL_ENV); \ | ||
fi | ||
|
||
.PHONY: run | ||
run: | ||
$(shell . .venv/bin/activate && python3 wsgi.py) | ||
run: env | ||
$(LOCAL_PYTHON) -m gunicorn -w 4 wsgi:app | ||
|
||
.PHONY: install | ||
install: env | ||
$(LOCAL_PYTHON) -m pip install --upgrade pip setuptools wheel && \ | ||
$(LOCAL_PYTHON) -m pip install -r requirements.txt && \ | ||
npm i -g less && \ | ||
echo Installed dependencies in \`${VIRTUAL_ENV}\`; | ||
|
||
.PHONY: deploy | ||
deploy: | ||
$(shell . ./deploy.sh) | ||
make install && \ | ||
make run | ||
|
||
.PHONY: test | ||
test: env | ||
$(LOCAL_PYTHON) -m \ | ||
coverage run -m pytest -vv \ | ||
--disable-pytest-warnings && \ | ||
coverage html --title='Coverage Report' -d .reports && \ | ||
open .reports/index.html | ||
|
||
.PHONY: update | ||
update: | ||
poetry shell && poetry update | ||
pip freeze > requirements.txt | ||
exit | ||
|
||
update: env | ||
$(LOCAL_PYTHON) -m pip install --upgrade pip setuptools wheel && \ | ||
poetry update && \ | ||
poetry export -f requirements.txt --output requirements.txt --without-hashes && \ | ||
echo Installed dependencies in \`${VIRTUAL_ENV}\`; | ||
|
||
.PHONY: format | ||
format: requirements | ||
$(shell . .venv/bin/activate) | ||
$(shell isort -rc ./) | ||
$(shell black ./) | ||
format: env | ||
$(LOCAL_PYTHON) -m isort --multi-line=3 . && \ | ||
$(LOCAL_PYTHON) -m black . | ||
|
||
.PHONY: lint | ||
lint: env | ||
$(LOCAL_PYTHON) -m flake8 . --count \ | ||
--select=E9,F63,F7,F82 \ | ||
--exclude .git,.github,__pycache__,.pytest_cache,.venv,logs,creds,.venv,docs,logs,.reports \ | ||
--show-source \ | ||
--statistics | ||
|
||
|
||
.PHONY: clean | ||
clean: | ||
find . -name '*.pyc' -delete | ||
find . -name '__pycache__' -delete | ||
find . -name 'poetry.lock' -delete | ||
find . -name 'Pipefile.lock' -delete | ||
find . -name '.coverage' -delete && \ | ||
find . -name '*.pyc' -delete && \ | ||
find . -name '__pycache__' -delete && \ | ||
find . -name 'poetry.lock' -delete && \ | ||
find . -name '*.log' -delete && \ | ||
find . -name '.DS_Store' -delete && \ | ||
find . -name 'Pipfile' -delete && \ | ||
find . -name 'Pipfile.lock' -delete && \ | ||
find . -wholename '**/*.pyc' -delete && \ | ||
find . -wholename '**/*.html' -delete && \ | ||
find . -type d -wholename '__pycache__' -exec rm -rf {} + && \ | ||
find . -type d -wholename '.venv' -exec rm -rf {} + && \ | ||
find . -type d -wholename '.pytest_cache' -exec rm -rf {} + && \ | ||
find . -type d -wholename '**/.pytest_cache' -exec rm -rf {} + && \ | ||
find . -type d -wholename '**/*.log' -exec rm -rf {} + && \ | ||
find . -type d -wholename './.reports/*' -exec rm -rf {} + && \ | ||
find . -type d -wholename '**/.webassets-cache' -exec rm -rf {} + |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.