Skip to content

Commit

Permalink
post gen project sh done
Browse files Browse the repository at this point in the history
  • Loading branch information
hnthh committed Nov 27, 2023
1 parent 1eb929a commit 3693f35
Show file tree
Hide file tree
Showing 140 changed files with 1,066 additions and 706 deletions.
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
VENV=cd testproject/django/src && ../venv/bin/python
VENV=cd testproject/django && poetry run python src/manage.py

test: bootstrap
$(VENV) ./manage.py makemigrations --check
$(VENV) ./manage.py startapp test_app
$(VENV) makemigrations --check
$(VENV) startapp test_app

bootstrap:
rm -Rf testproject
mkdir -p testproject

cd testproject && cookiecutter --no-input ../

coverage:
$(VENV) -m pip install pytest-cov
$(VENV) -m pytest --cov-report=xml --cov=app --cov=users --cov=a12n --cov=sepulkas
$(VENV) -m pytest --cov-report=xml --cov=core --cov=users --cov=a12n --cov=sepulkas
33 changes: 5 additions & 28 deletions hooks/post_gen_project.sh
Original file line number Diff line number Diff line change
@@ -1,33 +1,10 @@
#!/bin/bash -e

echo -ne "Running with "
cp src/core/.env.ci src/core/.env

python --version
poetry install

echo Creating and populating virtualenv..
poetry run python src/manage.py collectstatic
poetry run python src/manage.py migrate

python -m venv venv
. venv/bin/activate

pip install --upgrade pip pip-tools wheel
make

cd src

echo Collecting static assets...
./manage.py collectstatic

echo Running initial migrations...
./manage.py migrate

cd ../
echo Apply formatting..
make fmt

echo Running flake8..
make lint

echo Running pytest...
make test

echo Done
make fmt lint test
4 changes: 2 additions & 2 deletions {{cookiecutter.project_slug}}/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Run the linter
run: |
. venv/bin/activate
cp src/app/.env.ci src/app/.env
cp src/core/.env.ci src/core/.env
make lint
test:
Expand Down Expand Up @@ -73,5 +73,5 @@ jobs:

run: |
. venv/bin/activate
cp src/app/.env.ci src/app/.env
cp src/core/.env.ci src/core/.env
make test
1 change: 0 additions & 1 deletion {{cookiecutter.project_slug}}/.python-version

This file was deleted.

2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ ENV DD_VERSION ${RELEASE}

USER nobody

CMD uwsgi --master --http :8000 --module app.wsgi --workers 2 --threads 2 --harakiri 25 --max-requests 1000 --log-x-forwarded-for --buffer-size 32000
CMD uwsgi --master --http :8000 --module core.wsgi --workers 2 --threads 2 --harakiri 25 --max-requests 1000 --log-x-forwarded-for --buffer-size 32000
34 changes: 12 additions & 22 deletions {{cookiecutter.project_slug}}/Makefile
Original file line number Diff line number Diff line change
@@ -1,31 +1,21 @@
install-dev-deps: dev-deps
pip-sync requirements.txt dev-requirements.txt

install-deps: deps
pip-sync requirements.txt

deps:
pip-compile --resolver=backtracking --output-file=requirements.txt pyproject.toml

dev-deps: deps
pip-compile --resolver=backtracking --extra=dev --output-file=dev-requirements.txt pyproject.toml
manage = poetry run src/manage.py

fmt:
cd src && autoflake --in-place --remove-all-unused-imports --recursive .
cd src && isort .
cd src && black .
poetry run autoflake --in-place --remove-all-unused-imports --recursive src tests
poetry run black src tests

lint:
dotenv-linter src/app/.env.ci
cd src && ./manage.py check
flake8 src
cd src && mypy
$(manage) check
poetry run flake8 src tests
poetry run mypy src tests
poetry run dotenv-linter src/core/.env.ci

test:
mkdir -p src/static
cd src && ./manage.py makemigrations --dry-run --no-input --check
cd src && ./manage.py compilemessages
cd src && pytest --dead-fixtures
cd src && pytest -x

$(manage) makemigrations --dry-run --no-input --check
$(manage) compilemessages
poetry run pytest --dead-fixtures
poetry run pytest -x

pr: fmt lint test
6 changes: 3 additions & 3 deletions {{cookiecutter.project_slug}}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ This project is bootstrapped using [fandsdev/django](http://github.com/fandsdev/

## Project structure

The main django app is called `app`. It contains `.env` file for django-environ. For examples see `src/app/.env.ci`. Here are some usefull app-wide tools:
The main django app is called `app`. It contains `.env` file for django-environ. For examples see `src/core/.env.ci`. Here are some usefull app-wide tools:
* `app.admin` — app-wide django-admin customizations (empty yet), check out usage [examples](https://github.com/f213/django/tree/master/%7B%7Bcookiecutter.project_slug%7D%7D/src/app/admin)
* `app.test.api_client` (available as `api` and `anon` fixtures within pytest) — a [convinient DRF test client](https://github.com/f213/django/blob/master/%7B%7Bcookiecutter.project_slug%7D%7D/src/users/tests/tests_whoami.py#L6-L16).
* `core.test.api_client` (available as `api` and `anon` fixtures within pytest) — a [convinient DRF test client](https://github.com/f213/django/blob/master/%7B%7Bcookiecutter.project_slug%7D%7D/src/users/tests/tests_whoami.py#L6-L16).

Django user model is located in the separate `users` app.

Expand All @@ -25,7 +25,7 @@ $ make
Run the server:

```bash
$ cd src && cp app/.env.ci app/.env # default environment variables
$ cd src && cp core/.env.ci core/.env # default environment variables
$ ./manage.py migrate
$ ./manage.py createsuperuser
$ ./manage.py runserver
Expand Down
Loading

0 comments on commit 3693f35

Please sign in to comment.