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

Travis Build Stages + Docker Repository #573

Merged
merged 13 commits into from Aug 5, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 10 additions & 13 deletions .travis.yml
@@ -1,22 +1,21 @@
sudo: required
services:
- docker
- docker
env:
- DOCKER_COMPOSE_VERSION=1.11.2
- DOCKER_COMPOSE_VERSION=1.11.2
language: python
python:
- '3.6'
- '3.6'
install:
- sudo docker --version
- sudo docker-compose --version
- sudo docker --version
- sudo docker-compose --version
before_script:
- "./csu start"
- ./csu start
script:
- "./csu dev test"
- "./csu dev test_backwards"
- "./csu dev test_coverage"
- "./csu dev style"
- "./csu dev docs"
- ./csu ci test_with_coverage
- ./csu ci test_backwards
- ./csu ci style
- ./csu ci docs
deploy:
- provider: script
script: bash ./infrastructure/dev-deploy/dev-deploy.sh
Expand All @@ -28,8 +27,6 @@ deploy:
skip_cleanup: true
on:
branch: master
after_script:
- bash <(curl -s https://codecov.io/bash)
notifications:
email: false
slack:
Expand Down
11 changes: 1 addition & 10 deletions Dockerfile
@@ -1,28 +1,19 @@
# This Dockerfile is based off the Google App Engine Python runtime image
# https://github.com/GoogleCloudPlatform/python-runtime
FROM gcr.io/google-appengine/python
FROM uccser/django:1.11.4

# Add metadata to Docker image
LABEL maintainer="csse-education-research@canterbury.ac.nz"

# Set terminal to be noninteractive
ARG DEBIAN_FRONTEND=noninteractive

ENV DJANGO_PRODUCTION=True

# Install packages, running of Python 3.4.2
RUN apt-get update && apt-get install -y \
python3 \
python3-dev \
python3-pip
RUN apt-get clean && rm /var/lib/apt/lists/*_*

EXPOSE 8080
RUN mkdir /csunplugged
WORKDIR /csunplugged

# Copy and install Python dependencies
RUN python -m virtualenv --python=python3.4 /docker_venv
COPY requirements /requirements
RUN /docker_venv/bin/pip3 install -r /requirements/production.txt

Expand Down
46 changes: 1 addition & 45 deletions Dockerfile-local
@@ -1,6 +1,6 @@
# This Dockerfile is based off the Google App Engine Python runtime image
# https://github.com/GoogleCloudPlatform/python-runtime
FROM gcr.io/google-appengine/python
FROM uccser/django:1.11.4-with-weasyprint

# Add metadata to Docker image
LABEL maintainer="csse-education-research@canterbury.ac.nz"
Expand All @@ -9,54 +9,10 @@ LABEL maintainer="csse-education-research@canterbury.ac.nz"
ARG DEBIAN_FRONTEND=noninteractive

ENV DJANGO_PRODUCTION=False

# Install custom Pango version

# Install FreeType2 then HarfBuzz then reinstall FreeType2
RUN apt-get update && apt-get install -y \
bzip2 \
gperf \
libbz2-dev \
libffi-dev \
libtinfo-dev \
libmount-dev \
libicu52 \
libpcre3 \
libglib2.0-dev \
libgdk-pixbuf2.0-dev \
libcairo2-dev

RUN mkdir /pango-install/
COPY ./csunplugged/pango-install.sh /pango-install/
RUN chmod +x /pango-install/pango-install.sh
RUN /pango-install/pango-install.sh

# Install packages (including Weasyprint dependencies), running of Python 3.4.2
RUN apt-get update && apt-get install -y \
python3 \
python3-dev \
python3-pip \
python-dev \
python-pip \
python-lxml \
python-cffi \
fontconfig \
shared-mime-info
RUN apt-get clean && rm /var/lib/apt/lists/*_*

EXPOSE 8080

# Copy and create virtual environment
COPY requirements /requirements
RUN python -m virtualenv --python=python3.4 /docker_venv

# Install Weasyprint dependencies
RUN /docker_venv/bin/pip3 install -U pip setuptools
RUN /docker_venv/bin/pip3 install packaging==16.8
RUN /docker_venv/bin/pip3 install appdirs==1.4.3
RUN /docker_venv/bin/pip3 install html5lib==1.0b9
RUN /docker_venv/bin/pip3 install six==1.10.0
RUN /docker_venv/bin/pip3 install weasyprint==0.36

# Install dependencies
RUN /docker_venv/bin/pip3 install -r /requirements/local.txt
Expand Down
48 changes: 46 additions & 2 deletions csu
Expand Up @@ -240,10 +240,12 @@ function test_coverage_help {
# Run test suite backwards for CI testing
function test_suite_backwards {
printf "Running test suite backwards...\n"
if [ "$TRAVIS_PULL_REQUEST" != "false" ]
then
status=0
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
docker-compose exec django /docker_venv/bin/python3 ./manage.py test --settings=config.settings.testing --pattern "test_*.py" --reverse -v 0
status=$?
fi
! (( ${status} ))
}
function test_suite_backwards_help {
printf " test_backwards Run test suite backwards.\n"
Expand Down Expand Up @@ -294,6 +296,45 @@ function logs_help {
printf " logs View logs.\n"
}

function test_with_coverage() {
test_suite
# Swap these two lines if testing is too slow
#docker-compose exec django /docker_venv/bin/coverage run --rcfile=/cs-unplugged/.coveragerc ./manage.py test --settings=config.settings.testing --pattern "test_*.py" -v 3 --exclude-tag=resource_generation
test_status=$?
test_coverage
coverage_status=$?
bash <(curl -s https://codecov.io/bash)
! (( $test_status || $coverage_status ))
}

function process_ci_command() {
if [ $# -lt 1 ]
then
printf "${RED}ERROR: ci command requires one parameter!${NC}\n"
helpmenu
exit 1
else
case "$1" in
docs)
documentation
exit
;;
style)
style
exit
;;
test_with_coverage)
test_with_coverage
exit
;;
test_backwards)
test_suite_backwards
exit
;;
esac
fi
}

function process_dev_command() {
if [ $# -lt 1 ]
then
Expand Down Expand Up @@ -387,6 +428,9 @@ case "$1" in
clean
exit
;;
ci)
process_ci_command $2
;;
dev)
process_dev_command $2 $3
;;
Expand Down
109 changes: 0 additions & 109 deletions csunplugged/pango-install.sh

This file was deleted.

2 changes: 2 additions & 0 deletions csunplugged/tests/resources/views/test_arrows.py
@@ -1,3 +1,4 @@
from django.test import tag
from django.urls import reverse

from tests.BaseTestWithDB import BaseTestWithDB
Expand All @@ -6,6 +7,7 @@
from utils.create_query_string import query_string


@tag('resource_generation')
class ArrowsResourceViewTest(BaseTestWithDB):

def __init__(self, *args, **kwargs):
Expand Down
@@ -1,3 +1,4 @@
from django.test import tag
from django.urls import reverse
from tests.BaseTestWithDB import BaseTestWithDB
from tests.resources.ResourcesTestDataGenerator import ResourcesTestDataGenerator
Expand All @@ -6,6 +7,7 @@
from utils.resource_valid_test_configurations import resource_valid_test_configurations


@tag('resource_generation')
class BarcodeChecksumPosterResourceViewTest(BaseTestWithDB):

def __init__(self, *args, **kwargs):
Expand Down
2 changes: 2 additions & 0 deletions csunplugged/tests/resources/views/test_binary_cards.py
@@ -1,9 +1,11 @@
from django.test import tag
from django.urls import reverse
from tests.BaseTestWithDB import BaseTestWithDB
from tests.resources.ResourcesTestDataGenerator import ResourcesTestDataGenerator
from utils.create_query_string import query_string


@tag('resource_generation')
class BinaryCardsResourceViewTest(BaseTestWithDB):

def __init__(self, *args, **kwargs):
Expand Down
2 changes: 2 additions & 0 deletions csunplugged/tests/resources/views/test_binary_cards_small.py
@@ -1,11 +1,13 @@
import itertools
from django.test import tag
from django.urls import reverse
from tests.BaseTestWithDB import BaseTestWithDB
from tests.resources.ResourcesTestDataGenerator import ResourcesTestDataGenerator
from utils.import_resource_module import import_resource_module
from utils.create_query_string import query_string


@tag('resource_generation')
class BinaryCardsSmallResourceViewTest(BaseTestWithDB):

def __init__(self, *args, **kwargs):
Expand Down
2 changes: 2 additions & 0 deletions csunplugged/tests/resources/views/test_binary_to_alphabet.py
@@ -1,9 +1,11 @@
from django.test import tag
from django.urls import reverse
from tests.BaseTestWithDB import BaseTestWithDB
from tests.resources.ResourcesTestDataGenerator import ResourcesTestDataGenerator
from utils.create_query_string import query_string


@tag('resource_generation')
class BinaryToAlphabetResourceViewTest(BaseTestWithDB):

def __init__(self, *args, **kwargs):
Expand Down
2 changes: 2 additions & 0 deletions csunplugged/tests/resources/views/test_binary_windows.py
@@ -1,10 +1,12 @@
import itertools
from django.test import tag
from django.urls import reverse
from tests.BaseTestWithDB import BaseTestWithDB
from tests.resources.ResourcesTestDataGenerator import ResourcesTestDataGenerator
from utils.create_query_string import query_string


@tag('resource_generation')
class BinaryWindowsResourceViewTest(BaseTestWithDB):

def __init__(self, *args, **kwargs):
Expand Down