Skip to content

Commit

Permalink
Merge pull request #22 from GatorEducator/feature/automated-docker-bu…
Browse files Browse the repository at this point in the history
…ilds

Automated docker builds
  • Loading branch information
Michionlion authored Apr 27, 2019
2 parents 372c0fd + ae88365 commit d1e87e6
Show file tree
Hide file tree
Showing 15 changed files with 187 additions and 51 deletions.
110 changes: 110 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,115 @@ Dockerfile
.venv/
.git/
.gitignore
/tests
/scripts

# possibly need to ignore database if using remote
# database.db

# Ignore git's ignore

# 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/
*.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/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# 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/
9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ os: linux
# set env variables for different jobs
env:
global:
- PYENV_ROOT=$HOME/.travis-pyenv
- PIPENV_VENV_IN_PROJECT=1
- PIPENV_IGNOR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b+BriRuqE0ddc1l35n77vE7MHWMV264ysc2OlVIZWGFwJ82yk+yqS9RjJvwM1XwP74AiiHzxk1XQO3ylTK3P0pP+legfoDQ4AZrGJCyOZ39OtPdJXVz/5gPWPbGqzE+U43PzzdvvWqQfFBXXP2rIrOAamUdDeQlB6nLB1lUIPJ7VoxVVLfhSE0n3ku2SgW3QMkq4/ytr63mG2TD9sbGXMbz9R8Q+enothockujlx9z4nI0ew/97wDsBC9T7oqGpuZAnokDgLtsMo1y5ekP7bEELuBFsa2WchPbTw3M42beUj6MluVeI+i4G3UIvAKOA3E7EelkJ7pndnO+91KtMBda3ZvO870DZtbo+X8Sg6WZGbzdvGpB7+qQcsIm41Y8vAy3c3ryps6rRKaAiFQDK77GkvKpTrl6V7soKBA2/5O/PE9RIaqYFsjvv1vFhkp4Ib0hqoxBaGy3AMjAdPRVamW9Ocngnokmn7lDOvNkuvIarcIPMgiSSS6xMLtbKPlZ2SIyRk5cimq3PzF2yCaC8JZu6WQXkAjWPs3Vh7wNiBJf29vKkpOLdGPR0n8VN05fNJi7WnZNj+HvwnFHHPgQjWuGrO+GiTLWdHS5YlpVB9WxTFhbxpDY1b2ZAR1A="

# command to install dependencies
install:
Expand All @@ -27,9 +26,9 @@ install:
# cache pip installations
# cache pyenv installations
cache:
- pip
- directories:
directories:
- $HOME/.pyenv_cache
- $HOME/.cache/pip

# perform testing:
# --> run the test suite and generate coverage with Pipfile script
Expand Down
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
![logo](logo.jpg "Professor Spidey")

[![Build Status](https://travis-ci.com/GatorEducator/quizagator.svg?branch=master)](https://travis-ci.com/GatorEducator/quizagator)
[![codecov.io](http://codecov.io/github/GatorEducator/quizagator/coverage.svg?branch=master)](
http://codecov.io/github/GatorEducator/quizagator?branch=master)
[![codecov.io](http://codecov.io/github/GatorEducator/quizagator/coverage.svg?branch=master)](http://codecov.io/github/GatorEducator/quizagator?branch=master)
[![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat)](#contributors)
[![made-with-python](
https://img.shields.io/badge/Made%20with-Python-blue.svg)](
https://www.python.org/)
[![made-with-python](https://img.shields.io/badge/Made%20with-Python-blue.svg)](https://www.python.org/)

## A Quiz Creation Tool for File Upload and Custom Grading

Expand Down
11 changes: 0 additions & 11 deletions application/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1 @@
""" Application package initializer """
import flask

# main flask instance
app = flask.Flask(__name__)

# pylint: disable=wrong-import-position
from . import index # noqa: E402, F401
from . import db_connect # noqa: E402, F401
from . import students # noqa: E402, F401
from . import teachers # noqa: E402, F401
from . import login # noqa: E402, F401
15 changes: 15 additions & 0 deletions application/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""AppFactory"""
import flask


def create_app():
"""Create an app"""
app = flask.Flask(__name__)

with app.app_context():
# pylint: disable=unused-import
from . import index # noqa: E402, F401
from . import students # noqa: E402, F401
from . import teachers # noqa: E402, F401
from . import login # noqa: E402, F401
return app
3 changes: 1 addition & 2 deletions application/db_connect.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
""" Describes the database connection """

import functools
import sqlite3
import flask

# from flask import g, session, escape
from application import app
from flask import current_app as app


DATABASE = "database.db"
Expand Down
3 changes: 1 addition & 2 deletions application/index.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
""" undocumented """

import flask

from application import app
from flask import current_app as app


@app.route("/")
Expand Down
3 changes: 1 addition & 2 deletions application/login.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
""" undocumented """

import flask

from application import app
from flask import current_app as app
from . import db_connect

# LOGIN THE USER
Expand Down
2 changes: 1 addition & 1 deletion application/students.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
""" Student endpoints """
import flask

from application import app
from flask import current_app as app
from . import db_connect as db


Expand Down
3 changes: 1 addition & 2 deletions application/teachers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
""" teacher endpoints """

import flask

from application import app
from flask import current_app as app
from . import db_connect as db


Expand Down
4 changes: 3 additions & 1 deletion run.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import argparse

from application import app
from application import app as appfactory

app = appfactory.create_app()

app.secret_key = "$JLmL!eCQXyajbdu2LCJ&Vwqs2JGagg3B&FRfexCmKBV"

Expand Down
4 changes: 3 additions & 1 deletion scripts/create-docker-image.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/bash

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

IMAGE_NAME="gatoreducator/quizagator"
TAG="latest"
TAG="$(source $SCRIPT_DIR/version.sh)-dev"

NAME="$IMAGE_NAME"
if ! test -z "$TAG"; then
Expand Down
6 changes: 5 additions & 1 deletion scripts/run-docker-image.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#!/bin/bash

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

NAME="quizagator"
IMAGE="gatoreducator/quizagator:latest"
IMAGE_NAME="gatoreducator/quizagator"
TAG="$(source $SCRIPT_DIR/version.sh)-dev"
IMAGE="$IMAGE_NAME:$TAG"
INNER_PORT="5000"
OUTER_PORT="4201"

Expand Down
16 changes: 16 additions & 0 deletions scripts/version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

function get_latest_version() {
local tag
tag="$(curl -s -X "GET" "https://api.github.com/repos/gatoreducator/quizagator/tags" | jq -r '.[0].name')"

if [[ -z "$tag" ]] || [[ "$tag" = "null" ]]; then
tag="v0.0.0"
fi

tag=${tag##v}
echo "$tag"
return 0
}

get_latest_version
42 changes: 24 additions & 18 deletions tests/test_app.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
""" basic tests """
"""Basic Tests"""
import pytest

from application import app
from application import login
from application import app as appfactory


@pytest.fixture()
def factory():
"""Create an app and its test client"""
actual_app = appfactory.create_app()

def test_app_created():
"""Start with a blank database."""
assert app is not None
# pylint: disable=too-few-public-methods
class Group:
"""Group of created objects"""

class FlaskrTestCase(unittest.TestCase):
app = actual_app
client = actual_app.test_client()

def setUp(self):
self.db_fd, flaskr.app.config['DATABASE'] = tempfile.mkstemp()
flaskr.app.testing = True
self.app = flaskr.app.test_client()
with flaskr.app.app_context():
flaskr.init_db()
return Group


# def test_index(app):
# res = app.get("/")
# # print(dir(res), res.status_code)
# assert res.status_code == 200
# assert b"" in res.data
# pylint: disable=redefined-outer-name
def test_app_created(factory):
"""Start with a blank database"""
assert factory.app is not None


# pylint: disable=redefined-outer-name
def test_index(factory):
"""Test index page works -- NOT CORRECT"""
res = factory.client.get("/")
assert res.status_code == 404
assert b"" in res.data

0 comments on commit d1e87e6

Please sign in to comment.