Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI-WIP #67

Closed
wants to merge 6 commits into from
Closed
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
20 changes: 20 additions & 0 deletions .env_template
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
SECRET_KEY=
DEBUG=false
DATABASE_URL=postgres://postgres:postgres@localhost:5432/connect
CELERY_BROKER_URL=redis://localhost:6379/0
REDIS_URL=redis://localhost:6379/0
DJANGO_ALLOWED_HOSTS=
CSRF_TRUSTED_ORIGINS=

TWILIO_ACCOUNT_SID=
TWILIO_AUTH_TOKEN=
TWILIO_MESSAGING_SERVICE=

FCM_PROJECT_ID=
FCM_PRIVATE_KEY_ID=
FCM_CLIENT_EMAIL=
FCM_CLIENT_ID=
FCM_CLIENT_X509_CERT_URL=
FCM_PRIVATE_KEY=

OIDC_RSA_PRIVATE_KEY=
63 changes: 63 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: CI

# Enable Buildkit and let compose use it to speed up image building
env:
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1

on:
pull_request:
branches: ['main']

push:
branches: ['main']

concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
linter:
runs-on: ubuntu-latest
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Run pre-commit
uses: pre-commit/[email protected]

pytest:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:12
ports:
- 5432:5432
env:
POSTGRES_PASSWORD: postgres

env:
DATABASE_URL: 'postgres://postgres:postgres@localhost:5432/postgres'

steps:
- name: Checkout Code Repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: pip
cache-dependency-path: requirements-dev.txt

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Test with pytest
run: pytest
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@
/.idea
/.direnv
/.envrc
*.env
!*.env_example
57 changes: 57 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
default_stages: [pre-commit]

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-json
- id: check-toml
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: check-builtin-literals
- id: check-case-conflict
- id: check-docstring-first
- id: detect-private-key

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.9-for-vscode
hooks:
- id: prettier
args: ['--tab-width', '2', '--single-quote']
exclude: 'templates/'

- repo: https://github.com/adamchainz/django-upgrade
rev: '1.13.0'
hooks:
- id: django-upgrade
args: ['--target-version', '4.1']

- repo: https://github.com/asottile/pyupgrade
rev: v3.4.0
hooks:
- id: pyupgrade
args: [--py311-plus]

- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8

# sets up .pre-commit-ci.yaml to ensure pre-commit dependencies stay up to date
ci:
autoupdate_schedule: weekly
skip: []
submodules: false
12 changes: 6 additions & 6 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from oauth2_provider.models import Application
from rest_framework.test import APIClient

from users.factories import UserFactory, FCMDeviceFactory
from messaging.factories import ServerFactory
from users.factories import FCMDeviceFactory, UserFactory


@pytest.fixture
def user(db):
Expand All @@ -27,7 +27,7 @@ def auth_device(user, api_client):
"""
Create the Basic Authentication credentials for the test user.
"""
credentials = f"{user.username}:testpass".encode("utf-8")
credentials = f"{user.username}:testpass".encode()
base64_credentials = base64.b64encode(credentials).decode("utf-8")
cred = f"Basic {base64_credentials}"
api_client.credentials(HTTP_AUTHORIZATION=cred)
Expand All @@ -50,7 +50,7 @@ def oauth_app(user):

@pytest.fixture
def authed_client(api_client, oauth_app):
auth = f'{oauth_app.client_id}:{oauth_app.raw_client_secret}'.encode('utf-8')
credentials = base64.b64encode(auth).decode('utf-8')
api_client.defaults['HTTP_AUTHORIZATION'] = 'Basic ' + credentials
auth = f"{oauth_app.client_id}:{oauth_app.raw_client_secret}".encode()
credentials = base64.b64encode(auth).decode("utf-8")
api_client.defaults["HTTP_AUTHORIZATION"] = "Basic " + credentials
return api_client
2 changes: 1 addition & 1 deletion connectid/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'connectid.settings')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "connectid.settings")

application = get_asgi_application()
30 changes: 0 additions & 30 deletions connectid/localsettings.example.py

This file was deleted.

Loading
Loading