Getting travisCI setup

This commit is contained in:
kevgliss 2015-07-20 16:13:42 -07:00
parent 14b62a145a
commit c89dff7994
9 changed files with 186 additions and 13 deletions

2
.gitignore vendored
View File

@ -26,3 +26,5 @@ pip-log.txt
docs/_build docs/_build
.editorconfig .editorconfig
.idea .idea
test.conf
lemur/tests/tmp

View File

@ -1,7 +1,27 @@
language: node_js sudo: false
node_js: language: python
- '0.8' services:
- '0.10' - postgresql
python:
- "2.7"
cache:
directories:
- node_modules
- .pip_download_cache
- "$HOME/virtualenv/python2.7.9"
env:
global:
- PIP_DOWNLOAD_CACHE=".pip_download_cache"
install:
- time make develop dev-postgres
before_script: before_script:
- 'npm install -g bower grunt-cli' - psql -c 'create database lemur;' -U postgres
- 'bower install' script:
- make lint
- make test-js
- py.test tests
- make test-cli
notifications:
email:
kglisson@netflix.com

83
Makefile Normal file
View File

@ -0,0 +1,83 @@
NPM_ROOT = ./node_modules
STATIC_DIR = src/lemur/static/app
develop: update-submodules setup-git
@echo "--> Installing dependencies"
npm install
pip install "setuptools>=0.9.8"
# order matters here, base package must install first
pip install -e .
pip install "file://`pwd`#egg=lemur[dev]"
pip install "file://`pwd`#egg=lemur[tests]"
@echo ""
dev-docs:
pip install -r docs/requirements.txt
reset-db:
@echo "--> Dropping existing 'lemur' database"
dropdb lemur || true
@echo "--> Creating 'lemur' database"
createdb -E utf-8 lemur
@echo "--> Applying migrations"
lemur db upgrade
setup-git:
@echo "--> Installing git hooks"
git config branch.autosetuprebase always
cd .git/hooks && ln -sf ../../hooks/* ./
@echo ""
clean:
@echo "--> Cleaning static cache"
${NPM_ROOT}/.bin/gulp clean
@echo "--> Cleaning pyc files"
find . -name "*.pyc" -delete
@echo ""
test: develop lint test-js test-python test-cli
testloop: develop
pip install pytest-xdist
py.test tests -f
test-cli:
@echo "--> Testing CLI"
rm -rf test_cli
mkdir test_cli
cd test_cli && lemur create_config -c ./test.conf > /dev/null
cd test_cli && lemur -c ./test.conf db upgrade > /dev/null
cd test_cli && lemur -c ./test.conf help 2>&1 | grep start > /dev/null
rm -r test_cli
@echo ""
test-js:
@echo "--> Running JavaScript tests"
npm test
@echo ""
test-python:
@echo "--> Running Python tests"
py.test lemur/tests || exit 1
@echo ""
lint: lint-python lint-js
lint-python:
@echo "--> Linting Python files"
PYFLAKES_NODOCTEST=1 flake8 lemur tests
@echo ""
lint-js:
@echo "--> Linting JavaScript files"
npm run lint
@echo ""
coverage: develop
coverage run --source=lemur -m py.test
coverage html
publish:
python setup.py sdist bdist_wheel upload
.PHONY: develop dev-postgres dev-docs setup-git build clean update-submodules test testloop test-cli test-js test-python lint lint-python lint-js coverage publish

5
docs/requirements.txt Normal file
View File

@ -0,0 +1,5 @@
Jinja2>=2.3
Pygments>=1.2
Sphinx>=1.3
docutils>=0.7
markupsafe

View File

@ -26,6 +26,7 @@ var gulp = require('gulp'),
imagemin = require('gulp-imagemin'), imagemin = require('gulp-imagemin'),
minifyHtml = require('gulp-minify-html'), minifyHtml = require('gulp-minify-html'),
bowerFiles = require('main-bower-files'), bowerFiles = require('main-bower-files'),
karma = require('karma'),
replace = require('gulp-replace-task'); replace = require('gulp-replace-task');
@ -37,6 +38,15 @@ gulp.task('clean', function (cb) {
del(['.tmp', 'lemur/static/dist'], cb); del(['.tmp', 'lemur/static/dist'], cb);
}); });
gulp.task('test', function (done) {
new karma.Server({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, function() {
done();
}).start();
});
gulp.task('dev:fonts', function () { gulp.task('dev:fonts', function () {
var fileList = [ var fileList = [
'lemur/static/app/vendor/bower_components/bootstrap/dist/fonts/*', 'lemur/static/app/vendor/bower_components/bootstrap/dist/fonts/*',

27
gulp/karma.conf.js Normal file
View File

@ -0,0 +1,27 @@
// Contents of: config/karma.conf.js
module.exports = function (config) {
config.set({
basePath : '../',
// Fix for "JASMINE is not supported anymore" warning
frameworks : ["jasmine"],
files : [
'app/lib/angular/angular.js',
'app/lib/angular/angular-*.js',
'test/lib/angular/angular-mocks.js',
'app/js/**/*.js',
'test/unit/**/*.js'
],
autoWatch : true,
browsers : ['Chrome'],
junitReporter : {
outputFile : 'test_out/unit.xml',
suite : 'unit'
//...
}
});
}

View File

@ -480,8 +480,8 @@ def main():
manager.add_command("show_urls", ShowUrls()) manager.add_command("show_urls", ShowUrls())
manager.add_command("db", MigrateCommand) manager.add_command("db", MigrateCommand)
manager.add_command("init", InitializeApp()) manager.add_command("init", InitializeApp())
manager.add_command('create_user', CreateUser()) manager.add_command("create_user", CreateUser())
manager.add_command('create_role', CreateRole()) manager.add_command("create_role", CreateRole())
manager.add_command("sync", Sync()) manager.add_command("sync", Sync())
manager.run() manager.run()

View File

@ -51,7 +51,8 @@
"main-bower-files": "^1.0.2", "main-bower-files": "^1.0.2",
"require-dir": "~0.3.0", "require-dir": "~0.3.0",
"streamqueue": "^0.1.1", "streamqueue": "^0.1.1",
"uglify-save-license": "^0.4.1" "uglify-save-license": "^0.4.1",
"karma": "~0.13.2"
}, },
"engines": { "engines": {
"node": ">=0.10.0" "node": ">=0.10.0"
@ -59,9 +60,12 @@
"scripts": { "scripts": {
"postinstall": "bower install --allow-root", "postinstall": "bower install --allow-root",
"pretest": "npm install && npm run build_static", "pretest": "npm install && npm run build_static",
"build_static": "gulp dist", "build_static": "gulp build",
"prelint": "npm install", "prelint": "npm install",
"lint": "jshint app/", "lint": "jshint app/",
"test": "gulp test" "test": "gulp test"
},
"devDependencies": {
"karma-chrome-launcher": "^0.2.0"
} }
} }

View File

@ -14,6 +14,7 @@ import os.path
from distutils import log from distutils import log
from distutils.core import Command from distutils.core import Command
from setuptools.command.develop import develop from setuptools.command.develop import develop
from setuptools.command.install import install
from setuptools.command.sdist import sdist from setuptools.command.sdist import sdist
from setuptools import setup from setuptools import setup
from subprocess import check_output from subprocess import check_output
@ -56,6 +57,24 @@ docs_require = [
'sphinxcontrib-httpdomain' 'sphinxcontrib-httpdomain'
] ]
dev_requires = [
'flake8>=2.0,<2.1',
]
class SmartInstall(install):
"""
Installs Lemur into the Python environment.
If the package indicator is missing, this will also force a run of
`build_static` which is required for JavaScript assets and other things.
"""
def _needs_static(self):
return not os.path.exists(os.path.join(ROOT, 'lemur-package.json'))
def run(self):
if self._needs_static():
self.run_command('build_static')
install.run(self)
class DevelopWithBuildStatic(develop): class DevelopWithBuildStatic(develop):
def install_for_development(self): def install_for_development(self):
self.run_command('build_static') self.run_command('build_static')
@ -79,7 +98,7 @@ class BuildStatic(Command):
log.info("running [npm install --quiet]") log.info("running [npm install --quiet]")
check_output(['npm', 'install', '--quiet'], cwd=ROOT) check_output(['npm', 'install', '--quiet'], cwd=ROOT)
log.info("running [gulp buld]") log.info("running [gulp build]")
check_output([os.path.join(ROOT, 'node_modules', '.bin', 'gulp'), 'build'], cwd=ROOT) check_output([os.path.join(ROOT, 'node_modules', '.bin', 'gulp'), 'build'], cwd=ROOT)
setup( setup(
@ -94,12 +113,15 @@ setup(
install_requires=install_requires, install_requires=install_requires,
extras_require={ extras_require={
'tests': tests_require, 'tests': tests_require,
'docs': docs_require 'docs': docs_require,
'dev': dev_requires,
}, },
cmdclass={ cmdclass={
'build_static': BuildStatic, 'build_static': BuildStatic,
'develop': DevelopWithBuildStatic, 'develop': DevelopWithBuildStatic,
'sdist': SdistWithBuildStatic 'sdist': SdistWithBuildStatic,
'install': SmartInstall
}, },
entry_points={ entry_points={
'console_scripts': [ 'console_scripts': [