diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..98d77aa6 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,149 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +### AlphaKit Specific ### +.dockerignore +.editorconfig +.env +.git +.github +.gitignore +deployed_static +Makefile +README.md diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..f14f8127 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,30 @@ +# http://editorconfig.org +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.{py,rst,ini}] +indent_size = 4 +indent_style = space + +[*.py] +default_section=THIRDPARTY +known_first_party=app +line_length=120 +multi_line_output=3 + +[*.{css,html,js,json,sass,scss,yml,yaml}] +indent_size = 2 +indent_style = space + +[*.md] +indent_size = 4 +indent_style = space +trim_trailing_whitespace = false + +[{Makefile,modd.conf}] +indent_style = tab diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml new file mode 100644 index 00000000..8cb14ddb --- /dev/null +++ b/.github/workflows/actions.yml @@ -0,0 +1,129 @@ +name: CI + +on: + pull_request: + push: + branches: + main + +env: + DOCKER_BUILDKIT: "1" + DOCKER_IMAGE: "docker.pkg.github.com/revsys/alphakit" + +jobs: + + test: + runs-on: ubuntu-latest + + services: + postgres: + image: postgres:11 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: postgres + ports: ['5432:5432'] + # options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + + steps: + - name: Git - Get Sources + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up Python 3.9 + uses: actions/setup-python@v1 + with: + python-version: 3.9 + + - uses: actions/cache@v1 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/base.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + ${{ runner.os }}- + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -r requirements/base.txt + if: steps.cache.outputs.cache-hit != 'true' + + - name: Test with pytest + env: + DATABASE_URL: 'postgres://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres' + SECRET_KEY: 'for-testing-only' + run: | + python -m pytest + + - name: Lints with Black + run: | + python -m black --check . + + - name: Test our doc test coverage + run: | + interrogate -vv --fail-under 70 --whitelist-regex "test_.*" . + + build: + needs: [test] + name: Build and Publish Docker image + runs-on: ubuntu-latest + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + + steps: + - name: Git - Get Sources + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Fetch Git Tags + run: | + git fetch --depth=1 origin +refs/tags/*:refs/tags/* || true + + - name: Set up Python 3.9 + uses: actions/setup-python@v1 + with: + python-version: 3.9 + + - name: Install Python dependencies + run: | + python -m pip install --upgrade pip + python -m pip install vinnie + + - name: Bump and Tag our version + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + vinnie patch + git push --tags + + - name: Docker - Login + run: | + echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com \ + --username ${{ github.actor }} --password-stdin + + - name: Build Docker image + run: | + TAG=`vinnie version` + + docker build --file ./docker/Dockerfile \ + --build-arg TAG=${TAG} \ + --cache-from=${DOCKER_IMAGE}:latest \ + --tag ${DOCKER_IMAGE} . + + - name: Docker - Tag + run: | + TAG=`vinnie version` + + docker tag ${DOCKER_IMAGE} ${DOCKER_IMAGE}:latest + docker tag ${DOCKER_IMAGE} ${DOCKER_IMAGE}:${TAG} + + - name: Docker list images + run: | + docker images + + # - name: Docker - Push + # run: | + # docker push ${DOCKER_IMAGE}:latest + # docker push ${DOCKER_IMAGE}:${TAG} diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..309b0682 --- /dev/null +++ b/.gitignore @@ -0,0 +1,142 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +### AlphaKit Specific ### +.env +deployed_static diff --git a/env.template b/env.template new file mode 100644 index 00000000..d4352b17 --- /dev/null +++ b/env.template @@ -0,0 +1,15 @@ +# Database settings +PGDATABASE=postgres +PGHOST=db +PGPASSWORD="" +PGPORT=5432 +PGUSER=postgres + +# ALLOWED_HOSTS can be a comma-delimited string/list of host names +ALLOWED_HOSTS=localhost + +# Set DJANGO_DEBUG = 0 to turn off Debug +DJANGO_DEBUG=1 + +# Don't use this secret key in production obviously +SECRET_KEY="top-secret" \ No newline at end of file