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

use our notes container for tests #130

Closed
wants to merge 8 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
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[run]
data_file = /tmp/.coverage
branch = True
omit = notesserver/settings*
*wsgi.py
2 changes: 1 addition & 1 deletion .pii_annotations.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
source_path: ./
report_path: pii_report
report_path: /tmp/pii_report
safelist_path: .annotation_safe_list.yml
coverage_target: 100.0
annotations:
Expand Down
6 changes: 3 additions & 3 deletions .travis/docker-compose-travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ services:
image: elasticsearch:1.5.2
container_name: es
notes:
# Uncomment this line to use the official course-discovery base image
image: edxops/notes:latest
image: openedx/edx-notes-api:latest

# Uncomment the next two lines to build from a local configuration repo
# build: ../configuration/docker/build/discovery/

container_name: edx_notes_api
volumes:
- ..:/edx/app/edx_notes_api/edx_notes_api
- ..:/edx/app/notes
- ./edx_notes_api.yml:/edx/etc/edx_notes_api.yml
command: tail -f /dev/null
depends_on:
- "db"
Expand Down
6 changes: 4 additions & 2 deletions .travis/docker.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ travis_start: ## Start containers stopped by `travis_stop`
docker-compose -f .travis/docker-compose-travis.yml start

travis_test: ## Run tests on Docker containers, as on Travis CI
docker exec -e TERM=$(TERM) -e TOXENV=$(TOXENV) -it edx_notes_api /edx/app/edx_notes_api/edx_notes_api/.travis/run_tests.sh
docker exec -e TERM=$(TERM) -e TOXENV=$(TOXENV) -it edx_notes_api /edx/app/notes/.travis/run_tests.sh
docker exec -it edx_notes_api env TERM=$(TERM) /edx/app/notes/.travis/run_tests.sh

travis_pii_check: ## Run pii annotations checker on Docker containers, as on Travis CI
docker exec -e TERM=$(TERM) -e TOXENV=$(TOXENV) -it edx_notes_api /edx/app/edx_notes_api/edx_notes_api/.travis/run_pii_checker.sh
docker exec -e TERM=$(TERM) -e TOXENV=$(TOXENV) -it edx_notes_api /edx/app/notes/.travis/run_pii_checker.sh
docker exec -it edx_notes_api env TERM=$(TERM) /edx/app/notes/.travis/run_pii_checker.sh

travis_stop: ## Stop running containers created by `travis_up` without removing them
docker-compose -f .travis/docker-compose-travis.yml stop
Expand Down
9 changes: 9 additions & 0 deletions .travis/edx_notes_api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
DATABASES:
default:
ENGINE: "django.db.backends.mysql"
HOST: "db"
NAME: "edx_notes_api"
PASSWORD: "secret"
PORT: "3306"
USER: "notes001"
ELASTICSEARCH_URL: "http://es:9200"
5 changes: 2 additions & 3 deletions .travis/run_pii_checker.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!/bin/bash -xe
. /edx/app/edx_notes_api/venvs/edx_notes_api/bin/activate

export DJANGO_SETTINGS_MODULE=notesserver.settings.test

cd /edx/app/edx_notes_api/edx_notes_api
cd /edx/app/notes

make pii_check
PATH=/home/app/.local/bin:$PATH make pii_check

5 changes: 2 additions & 3 deletions .travis/run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/bin/bash -xe
. /edx/app/edx_notes_api/venvs/edx_notes_api/bin/activate

cd /edx/app/edx_notes_api/edx_notes_api
cd /edx/app/notes

make validate
PATH=/home/app/.local/bin:$PATH make validate

16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ include .travis/docker.mk
validate: test.requirements test

test: clean
$(TOX)python -Wd -m pytest
$(TOX)python3 -Wd -m pytest

pii_check: test.requirements pii_clean
code_annotations django_find_annotations --config_file .pii_annotations.yml \
Expand All @@ -26,8 +26,8 @@ clean:
coverage erase

pii_clean:
rm -rf pii_report
mkdir -p pii_report
rm -rf /tmp/pii_report
mkdir -p /tmp/pii_report

quality:
pep8 --config=.pep8 $(PACKAGES)
Expand All @@ -43,24 +43,24 @@ diff-quality:
coverage: diff-coverage diff-quality

create-index:
python manage.py rebuild_index
python3 manage.py rebuild_index

migrate:
python manage.py migrate --noinput
python3 manage.py migrate --noinput

static: # provide the static target for devstack's tooling.
@echo "The notes service does not need staticfiles to be compiled. Skipping."

requirements:
pip install -q -r requirements/base.txt --exists-action=w
pip install --user -q -r requirements/base.txt --exists-action=w

test.requirements: requirements
pip install -q -r requirements/test.txt --exists-action=w
pip install --user -q -r requirements/test.txt --exists-action=w

develop: test.requirements

piptools: ## install pinned version of pip-compile and pip-sync
pip install -r requirements/pip-tools.txt
pip install --user -r requirements/pip-tools.txt

upgrade: export CUSTOM_COMPILE_COMMAND=make upgrade
upgrade: piptools ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in
Expand Down
2 changes: 1 addition & 1 deletion manage.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import os
import sys

Expand Down