Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: "Test"

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
name: Test
runs-on: ubuntu-latest
services:
db:
image: postgres:12.3-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: github_actions
ports:
- 5432:5432
options: --mount type=tmpfs,destination=/var/lib/postgresql/data --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
strategy:
matrix:
python-version: [3.8, 3.9]
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- 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
curl https://get.helm.sh/helm-v3.1.1-linux-amd64.tar.gz | tar xvz && sudo mv linux-amd64/helm /usr/local/bin/helm
- name: Test with django tests
working-directory: ./src
run: |
coverage run manage.py test
coverage report
env:
DATABASE_USER: postgres
DATABASE_PASSWORD: postgres
DATABASE_NAME: github_actions
DATABASE_HOST: 127.0.0.1
DJANGO_SETTINGS_MODULE: configuration.settings.test
KEYCLOAK_SCHEME: http
KEYCLOAK_HOST: 127.0.0.1
KEYCLOAK_PORT: 8091
KEYCLOAK_REALM_NAME: unikube
KEYCLOAK_CLIENT_ID: orgas
KEYCLOAK_CLIENT_SECRET: 79538492-73bf-47f9-8050-874326933260
- name: Upload coverage data to coveralls.io
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: ${{ matrix.python-version }}
COVERALLS_PARALLEL: true
working-directory: ./src
run: |
coveralls --service=github
coveralls:
name: Indicate completion to coveralls.io
needs: test
runs-on: ubuntu-latest
container: python:3-slim
steps:
- name: Finished
run: |
pip3 install --upgrade coveralls
coveralls --finish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -326,3 +326,5 @@ tags
.local-dev/

.docker/data/

.vscode/*
87 changes: 43 additions & 44 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,52 +1,51 @@
repos:
# black - format python code
- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
args: # arguments to configure black
- --line-length=120
# black - format python code
- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
args: # arguments to configure black
- --line-length=120

# these folders wont be formatted by black
- --exclude="""\.git |
\.__pycache__|
\.hg|
\.mypy_cache|
\.tox|
\.venv|
migrations|
_build|
buck-out|
build|
dist"""
# these folders wont be formatted by black
- --exclude="""\.git |
\.__pycache__|
\.hg|
\.mypy_cache|
\.tox|
\.venv|
migrations|
_build|
buck-out|
build|
dist"""

language_version: python3.8
language_version: python3.8

# flake8 - style guide enforcement
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
args: # arguments to configure flake8
# making line length compatible with black
- "--max-line-length=120"
- "--max-complexity=18"
- "--select=B,C,E,F,W,T4,B9"
# flake8 - style guide enforcement
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
args: # arguments to configure flake8
# making line length compatible with black
- "--max-line-length=120"
- "--max-complexity=18"
- "--select=B,C,E,F,W,T4,B9"

# these are errors that will be ignored by flake8
# check out their meaning here
# https://flake8.pycqa.org/en/latest/user/error-codes.html
- "--ignore=E203,E266,E501,W503,F403,F401,E402"
# these are errors that will be ignored by flake8
# check out their meaning here
# https://flake8.pycqa.org/en/latest/user/error-codes.html
- "--ignore=E203,E266,E501,W503,F403,F401,E402"

# isort - organize import correctly
- repo: https://github.com/PyCQA/isort
rev: 5.6.4
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]
# isort - organize import correctly
- repo: https://github.com/PyCQA/isort
rev: 5.6.4
hooks:
- id: isort

# gitlint - correct git commit format
- repo: https://github.com/jorisroovers/gitlint
rev: v0.15.0
# gitlint - correct git commit format
- repo: https://github.com/jorisroovers/gitlint
rev: v0.15.0
hooks:
- id: gitlint
- id: gitlint
8 changes: 6 additions & 2 deletions src/requirements.txt → requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@ graphene-django==2.9.1
graphene-federation~=0.1.0
psycopg2>=2.7,<3.0

# tests
factory_boy
# for tests
snapshottest~=0.6
factory_boy~=2.9.0
coverage~=5.3.1
docker~=4.1.0
coveralls==2.2.0
10 changes: 10 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[bdist_wheel]
universal=0

[isort]
multi_line_output = 3
include_trailing_comma = True
force_grid_wrap = 0
use_parentheses = True
ensure_newline_before_comments = True
line_length = 120
4 changes: 4 additions & 0 deletions src/.coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[run]
branch = True
source = .
omit = *migrations*, *tests*, *configuration*, *backoffice*, manage.py
71 changes: 71 additions & 0 deletions src/configuration/settings/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import os
import sys

from environs import Env

env = Env()

DEBUG = True
SECRET_KEY = "thisisnotneeded"


MIDDLEWARE = []

SITE_ID = 1

MEDIA_URL = "/media/"
STATIC_URL = "/static/"

BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

INSTALLED_APPS = [
"django.contrib.auth",
"django.contrib.contenttypes",
"organization",
"gql",
]

LOGGING = {
"version": 1,
"disable_existing_loggers": True,
"formatters": {"console": {"format": "%(asctime)s %(levelname)-8s %(name)-12s %(message)s"}},
"handlers": {
"console": {
"class": "logging.StreamHandler",
"formatter": "console",
"stream": sys.stdout,
}
},
"root": {"handlers": ["console"], "level": "INFO"},
"loggers": {
"hurricane": {
"handlers": ["console"],
"level": os.getenv("HURRICANE_LOG_LEVEL", "INFO"),
"propagate": False,
},
"pika": {
"handlers": ["console"],
"level": "ERROR",
"propagate": False,
},
},
}

DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"NAME": env.str("DATABASE_NAME"),
"USER": env.str("DATABASE_USER"),
"HOST": env.str("DATABASE_HOST"),
"PORT": env.int("DATABASE_PORT", 5432),
}
}

if env.str("DATABASE_PASSWORD", None):
DATABASES["default"]["PASSWORD"] = env.str("DATABASE_PASSWORD")

# AUTH_USER_MODEL = "backoffice.AdminUser"

GRAPHENE_PER_PAGE = 30

CELERY_TASK_ALWAYS_EAGER = True
1 change: 0 additions & 1 deletion src/gql/schema/mutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from commons.keycloak.abstract_models import KeycloakResource
from commons.keycloak.users import UserHandler
from django.core.exceptions import ValidationError
from django.core.validators import validate_email
from django.db import IntegrityError
from graphene_django.forms.mutation import DjangoModelFormMutation
from graphql import GraphQLError
Expand Down
1 change: 0 additions & 1 deletion src/gql/schema/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ class Meta:


class Query(graphene.ObjectType):

all_organizations = page_field_factory(OrganizationNode)
organization = graphene.Field(OrganizationNode, id=graphene.UUID(required=True))
user_invitations = page_field_factory(OrganizationInvitationNode)
Expand Down
4 changes: 0 additions & 4 deletions src/organization/models/organization.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import uuid
from typing import Optional

from commons.keycloak.abstract_models import KeycloakResource
Expand All @@ -15,11 +14,8 @@ def get_default_avatar_image():

class Organization(TitleSlugDescriptionModel, TimeStampedModel, KeycloakResource):
resource_handler = OrganizationResourceHandler

secret_token = models.CharField(max_length=300, blank=True)

on_trial = models.BooleanField()

avatar_image = models.FileField(blank=True, null=True, default=get_default_avatar_image)

def __str__(self):
Expand Down