Frux app server, for the asignature 'Taller de Programación II, FIUBA'
Frux is the newest crowdfunding app in town.
Before reading this repo, you should probably visit our homepage, with lots of info on the development, latest news, and lots (lots) of documentation.
If you are only interested in the source code, check out the different repos!
Frux is currently being developed by
This project was built with poetry in mind as the means to manage dependencies. You can follow their install guide to install it.
Having poetry installed, the following command will install the project into a new environment.
poetry install
Keep in mind that this will by default install the base requirements as well as the dev requirements.
To install the testing
extras, run:
poetry install -E testing
Remember to commit to the repo the poetry.lock
file generated by poetry install
.
We use pre-commit to run several code scans and hooks that make the development cycle easier.
pre-commit install
pre-commit install -t pre-push
Check the full poetry docs, but here goes a quick reminder,
poetry add <dependency> [--dev]
Always remember to commit changes to poetry.lock
!
In order to bootstrap dependencies and run several actions, we are using nox. This way, dependencies are isolated and you get environment replicability.
To run all sessions,
poetry run nox
To run tests session,
poetry run nox --sessions tests [-- pylint arguments]
To run linting session,
poetry run nox --sessions cop
To run bandit session,
poetry run nox --sessions bandit
To run pyreverse session,
poetry run nox --sessions pyreverse
poetry run python frux_app_server/manage.py db migrate -m "migration message"
Remember to review them after creating them.
frux-app-server follows PEP8.
If you installed the pre-commit hooks you shouldn't worry too much about style, since they will fix it for you or warn you about styling errors. We use the following hooks:
- black: An opinionated code formatting tool that ensures consistency across all projects using it
- flake8: a tool to enforce style guide
- mypy: a static type checker for Python
- pylint: a source code, bug and quality checker
We use either numpy style or google style docstring formatting. It's usually good to include the following docstrings:
- module level docstring giving a general overview of what it does.
- class dosctrings explaining what it is
- method/functions to explain what it does and what it's parameters are
We use the pytest framework to test frux-app-server. The easiest way to run tests it through nox
with nox --sessions tests
.
Get everything up and running.
cd docker-compose
docker-compose up --build
Create an .env
file with the following Firebase admin account credentials:
FIREBASE_PRIVATE_KEY="..."
FIREBASE_CLIENT_EMAIL="..."
FIREBASE_PROJECT_ID="..."
Make sure you have the db up to date, and then run locally.
poetry run python frux_app_server/manage.py db upgrade
FLASK_APP=$(pwd)/frux_app_server/app.py poetry run flask run
You will need to have the heroku cli installed and correctly configured for the following steps.
Prior to the actual deploy, make sure to commit your changes.
heroku create frux-app-server
heroku addons:create heroku-postgresql:hobby-dev
heroku stack:set container
git push heroku master
- The first step initializes a new heroku app
- The second step provisions a postgres addon
- The third step sets the app to use a docker image. Instead of using a Procfile, we will use a
heroku.yml
. Heroku does not yet support a poetry buildpack and exporting arequirements.txt
from poetry is pretty cumbersome. - Deploy 🚀
You can fetch logs from the app using heroku logs --tail
.
Go to the app on the Heroku Dashboard. On the deploy tab, select "Connect to github" under the "Deployment method" section. Select your repo and you're good to go. Pushes to master will deploy a new version.
The heroku Dockerfile includes the DataDog agent. Create a new DataDog API Key from here. Remember to set the following config vars:
heroku config:set DD_API_KEY=<your_api_key>
heroku config:set DD_DYNO_HOST=false
heroku config:set HEROKU_APP_NAME=frux-app-server
heroku config:set DD_TAGS=service:frux_app_server
A few pipelines have been set to run on github actions to ensure code quality.
This workflow runs linters and tests.
You can visit the swagger docs at 127.0.0.1:5000
.