-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
24be29b
commit 6f69694
Showing
69 changed files
with
3,318 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
version: 2 | ||
updates: | ||
# Enable version updates for pip | ||
- package-ecosystem: "pip" | ||
directory: "/" | ||
schedule: | ||
interval: "monthly" | ||
|
||
# Enable version updates for Docker | ||
- package-ecosystem: "docker" | ||
directory: "/" | ||
schedule: | ||
interval: "monthly" |
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,53 @@ | ||
name: Publish to TestPyPI | ||
|
||
on: | ||
release: | ||
types: [ prereleased ] | ||
|
||
jobs: | ||
build-n-publish: | ||
if: ${{ github.event.release.prerelease }} | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [3.9] | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v1 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install pypa/build | ||
run: >- | ||
python -m | ||
pip install | ||
build | ||
--user | ||
- name: Build a binary wheel and a source tarball | ||
run: >- | ||
python -m | ||
build | ||
--sdist | ||
--wheel | ||
--outdir dist/ | ||
. | ||
- name: Publish distribution 📦 to Test PyPI | ||
uses: pypa/gh-action-pypi-publish@v1.4.2 | ||
with: | ||
password: ${{ secrets.TEST_PYPI_API_TOKEN }} | ||
repository_url: https://test.pypi.org/legacy/ | ||
|
||
# - name: Slack alert if the publish fails | ||
# uses: 8398a7/action-slack@v2 | ||
# with: | ||
# status: ${{ job.status }} | ||
# author_name: Publish to Test PyPI | ||
# env: | ||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_PUBLISH_ALERTS_WEBHOOK }} | ||
# if: failure() |
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,70 @@ | ||
name: Publish to PyPI | ||
|
||
on: | ||
release: | ||
types: [ published ] | ||
|
||
jobs: | ||
build-n-publish: | ||
if: ${{ !github.event.release.prerelease }} | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [3.9] | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install pypa/build | ||
run: >- | ||
python -m | ||
pip install | ||
build | ||
--user | ||
- name: Build a binary wheel and a source tarball | ||
run: >- | ||
python -m | ||
build | ||
--sdist | ||
--wheel | ||
--outdir dist/ | ||
. | ||
- name: Publish distribution 📦 to PyPI | ||
if: startsWith(github.ref, 'refs/tags') | ||
uses: pypa/gh-action-pypi-publish@v1.4.2 | ||
with: | ||
password: ${{ secrets.PYPI_API_TOKEN }} | ||
|
||
# - name: Slack alert if the publish fails | ||
# uses: 8398a7/action-slack@v2 | ||
# with: | ||
# status: ${{ job.status }} | ||
# author_name: Publish to PyPI | ||
# env: | ||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_RELEASE_ALERTS_WEBHOOK }} | ||
# if: failure() | ||
|
||
slack-notifications: | ||
needs: build-n-publish | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Slackify the release body | ||
id: release_body | ||
uses: LoveToKnow/slackify-markdown-action@v1.0.0 | ||
with: | ||
text: ${{ github.event.release.body }} | ||
- uses: homeday-de/slack-release-bot-action@main | ||
with: | ||
webhook_url: ${{ secrets.SLACK_RELEASE_ALERTS_WEBHOOK }} | ||
title: ${{ github.event.release.name }} | ||
body: ${{ steps.release_body.outputs.text }} | ||
context: https://pypi.org/project/ob-dj-otp/ |
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,40 @@ | ||
name: Build & Test | ||
|
||
on: push | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [3.8, 3.9] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pipenv | ||
pipenv install --system --deploy --dev --verbose | ||
- name: Code linter | ||
run: pre-commit run --all-files | ||
|
||
- name: Test with pytest & generate coverage report | ||
run: | | ||
pytest --cov=./ --cov-report=xml | ||
# - name: Upload coverage to Codecov | ||
# uses: codecov/codecov-action@v2 | ||
# with: | ||
# token: ${{ secrets.CODECOV_TOKEN }} | ||
# file: ./coverage.xml | ||
# flags: unittests | ||
# name: codecov-dj-otp | ||
# fail_ci_if_error: true |
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,11 @@ | ||
docker-compose.local.env | ||
*egg-info/* | ||
build/* | ||
dist/* | ||
.idea/* | ||
coverage.xml | ||
.coverage | ||
version.py | ||
__pycache__/ | ||
venv/ | ||
.eggs/ |
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,2 @@ | ||
[settings] | ||
known_third_party =dj_database_url,django,drf_yasg,factory,pytest,rest_framework,setuptools |
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,49 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.3.0 | ||
hooks: | ||
- id: check-merge-conflict | ||
- id: check-added-large-files | ||
- id: check-ast | ||
- id: check-symlinks | ||
- id: check-yaml | ||
args: ['--unsafe'] | ||
- id: trailing-whitespace | ||
- id: check-json | ||
- id: debug-statements | ||
- id: detect-aws-credentials | ||
args: | ||
- --allow-missing-credentials | ||
- id: pretty-format-json | ||
args: | ||
- --autofix | ||
exclude: Pipfile.lock | ||
- repo: https://github.com/asottile/seed-isort-config | ||
rev: v2.2.0 | ||
hooks: | ||
- id: seed-isort-config | ||
- repo: https://github.com/PyCQA/isort | ||
rev: 5.12.0 | ||
hooks: | ||
- id: isort | ||
args: ["--profile", "black"] | ||
- repo: https://github.com/PyCQA/flake8 | ||
rev: 3.9.2 | ||
hooks: | ||
- id: flake8 | ||
additional_dependencies: [ flake8-print ] | ||
files: '\.py$' | ||
args: | ||
- --select=F401,F403,F406,F821,T001,T003 | ||
- repo: https://github.com/humitos/mirrors-autoflake | ||
rev: v1.1 | ||
hooks: | ||
- id: autoflake | ||
files: '\.py$' | ||
exclude: '^\..*' | ||
args: ["--in-place", "--remove-all-unused-imports"] | ||
- repo: https://github.com/psf/black | ||
rev: 22.8.0 | ||
hooks: | ||
- id: black | ||
args: ["--target-version", "py39"] |
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,45 @@ | ||
FROM python:3.9.7-slim-buster | ||
|
||
# prevent __pycache__ folder and files | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
ENV CRYPTOGRAPHY_DONT_BUILD_RUST=1 | ||
|
||
RUN set -ex \ | ||
&& apt-get update \ | ||
&& apt-get install -qq -y --no-install-recommends \ | ||
make \ | ||
curl \ | ||
gcc \ | ||
git \ | ||
jq \ | ||
gettext \ | ||
procps \ | ||
python3-dev \ | ||
sudo \ | ||
postgresql-client \ | ||
graphviz \ | ||
vim \ | ||
&& pip install pipenv \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /app | ||
|
||
# Create appuser user for the application | ||
RUN groupadd -g 9898 appuser && useradd -r -u 9898 -g appuser appuser -s /bin/bash | ||
RUN usermod -aG sudo appuser | ||
RUN mkdir /home/appuser && chown -R appuser /home/appuser | ||
RUN mkdir /public_assets | ||
|
||
COPY Pipfile Pipfile.lock ./ | ||
RUN pipenv install --system --deploy --dev --verbose | ||
|
||
ADD . ./ | ||
|
||
RUN rm /bin/sh && ln -s /bin/bash /bin/sh | ||
|
||
RUN chown -R appuser:appuser /public_assets | ||
RUN chown -R appuser:appuser /app | ||
RUN chown -R appuser:appuser /etc/environment | ||
RUN echo "appuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers | ||
USER appuser |
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,2 @@ | ||
include README.md | ||
prune tests |
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,81 @@ | ||
help: | ||
@echo "clean: remove all build, test, coverage and Python artifacts" | ||
@echo "clean-build: remove build artifacts" | ||
@echo "clean-pyc: remove Python file artifacts" | ||
@echo "clean-test: remove test and coverage artifacts" | ||
@echo "lint: check style with flake8" | ||
@echo "test: run tests quickly with the default Python" | ||
@echo "test-all: run tests on every Python version with tox" | ||
@echo "coverage: check code coverage quickly with the default Python" | ||
@echo "release: package and upload a release" | ||
@echo "dist: package" | ||
@echo "install: install the package to the active Python's site-packages" | ||
@echo "build: Build (usually, requires to build when changes happen to the Dockerfile or docker-compose.yml)" | ||
|
||
clean: clean-build clean-pyc clean-test | ||
|
||
clean-build: | ||
rm -fr build/ | ||
rm -fr dist/ | ||
rm -fr .eggs/ | ||
find . -name '*.egg-info' -exec rm -fr {} + | ||
find . -name '*.egg' -exec rm -f {} + | ||
|
||
clean-pyc: | ||
find . -name '*.pyc' -exec rm -f {} + | ||
find . -name '*.pyo' -exec rm -f {} + | ||
find . -name '*~' -exec rm -f {} + | ||
find . -name '__pycache__' -exec rm -fr {} + | ||
|
||
clean-test: | ||
rm -fr .tox/ | ||
rm -f .coverage | ||
rm -fr htmlcov/ | ||
|
||
lint_tests: | ||
flake8 leviathan_serving tests | ||
|
||
test: | ||
docker-compose run --rm app pytest | ||
|
||
test-all: | ||
tox | ||
|
||
coverage: | ||
coverage run --source leviathan_serving setup.py test | ||
coverage report -m | ||
coverage html | ||
$(BROWSER) htmlcov/index.html | ||
|
||
release: clean | ||
python setup.py sdist | ||
twine upload dist/* | ||
|
||
dist: clean | ||
python setup.py sdist | ||
python setup.py bdist_wheel | ||
ls -l dist | ||
|
||
install: clean | ||
python setup.py install | ||
|
||
lint: | ||
pre-commit run --all-files | ||
|
||
bash: | ||
docker-compose run --rm app bash | ||
|
||
migrations: | ||
docker-compose run --rm app python manage.py makemigrations | ||
|
||
migrate: | ||
docker-compose run --rm app python manage.py migrate | ||
|
||
rm: | ||
docker-compose down && docker-compose rm -f | ||
|
||
up: | ||
docker-compose up -d | ||
|
||
build: | ||
docker-compose build |
Oops, something went wrong.