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

Add CI/CD for running tests #97

Merged
merged 8 commits into from
Dec 29, 2021
Merged
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
27 changes: 27 additions & 0 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: DRF Social Oauth2

on:
pull_request:
types: [opened, edited]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.9

- name: Build docker image for tests
run: |
docker-compose -f docker-compose.tests.yml build --no-cache

- name: Run dockerised tests
run: |
docker-compose -f docker-compose.tests.yml up --exit-code-from app

- name: Take down containers
run: |
docker-compose -f docker-compose.tests.yml down
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM python:3.9.4-slim-buster
ENV PYTHONUNBUFFERED 1

RUN mkdir /code
WORKDIR /code

ADD . /code/

RUN apt-get update && apt-get install -y --no-install-recommends wget && rm -rf /var/lib/apt/lists/* && pip install --no-cache-dir -r requirements.test.txt
6 changes: 6 additions & 0 deletions components.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
DOCKERIZE_VERSION="v0.6.1"
wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz
dockerize -wait tcp://db:5432 -timeout 60s
16 changes: 16 additions & 0 deletions docker-compose.tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: "3.7"

services:
app:
build: .
command: >
bash -c "sh components.sh && pytest"
depends_on:
- db
db:
image: postgres:13.2
restart: always
environment:
- POSTGRES_PASSWORD=password
- POSTGRES_USER=user
- POSTGRES_DB=database
5 changes: 4 additions & 1 deletion requirements.test.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
requests==2.26.0
pytest==6.2.5
djangorestframework==3.13.1
djangorestframework>=3.10.3
django-oauth-toolkit==1.6.1
social-auth-app-django>=3.1.0
pytest-mock==3.6.1
coverage==6.2
2 changes: 0 additions & 2 deletions tests/drf_social_oauth2/test_authentication.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import os

from requests.exceptions import HTTPError
from requests.models import Response
from rest_framework.exceptions import AuthenticationFailed
from pytest import raises

Expand Down