From c640592e2468dcee6e72a95d8b54944a2cc1d885 Mon Sep 17 00:00:00 2001 From: Carlos Vieira Date: Thu, 9 Apr 2015 12:48:02 -0300 Subject: [PATCH] Modificando forma de compilar/teste --- .gitignore | 7 ++++++- README.md | 50 +++++++++++++------------------------------------- app/barrabrasil.py | 8 ++++---- app/profile.py | 4 +++- build.sh | 10 ++++++---- makefile | 27 +++++++++++++++++++++++++++ package.json | 25 +++++++++++++++++++++++++ recipes/default/assets.json | 2 +- recipes/default/compile.sh | 11 ++++++----- requirements.txt | 3 +++ 10 files changed, 94 insertions(+), 53 deletions(-) create mode 100644 makefile create mode 100644 package.json create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore index 6087281..c8856ac 100644 --- a/.gitignore +++ b/.gitignore @@ -20,5 +20,10 @@ test/resultado.txt test-reports.xml # Vagrant files # -################ +################# .vagrant + +# Enviroment files # +#################### +venv +node_modules diff --git a/README.md b/README.md index 50252c1..52169bd 100644 --- a/README.md +++ b/README.md @@ -27,15 +27,6 @@ Altere o arquivo 'app/profile' para apontar para o novo profile. Exemplo: Esses são comandos exemplos, por favor verifique no seu sistema como deve ser instalado. - * flask - pip install flask - * assetgen - pip install assetgen - * config - pip install config - * tavutil - pip install tavutil - * node.js apt-get install python-software-properties python g++ make add-apt-repository ppa:chris-lea/node.js @@ -43,44 +34,25 @@ Esses são comandos exemplos, por favor verifique no seu sistema como deve ser i apt-get install nodejs apt-get install npm - * coffeescript - npm install -g coffee-script - * sass apt-get install ruby-full build-essential apt-get install rubygems gem install sass sass -v - * uglifyjs - npm install -g uglify-js - (Debian ou Ubuntu: apt-get install node-uglify) * zlib +## Para criar o ambiente de desenvolvimento execute: -Para profiling é necessário além dos acima: - - * werkzeug - -Para testes headless é necessário também: - - * mocha - npm install mocha - - * chai - npm install chai +> make venv - * chai-jq - npm install chai-jq +## Para profiling é necessário além dos acima: - * ejs - npm install ejs + * werkzeug - * express - npm install express +E execute o - * zombie - npm install zombie +> make profile ## Usando vagrant: @@ -94,15 +66,19 @@ cd /vagrant/ Execute o comando: -> ./build.sh _profile_ +> make run -Se não for especificado nenhum _profile_ o profile _default_ será selecionado. +O profile selecionado será o contido em _app/profile_ ## Testes da barra Execute o comando: -> mocha +> make teste + +Para gerar um teste em XUNIT execute + +> make testReport # Requisitos da Barra ---- diff --git a/app/barrabrasil.py b/app/barrabrasil.py index 7c37c2c..69fb2ff 100644 --- a/app/barrabrasil.py +++ b/app/barrabrasil.py @@ -58,10 +58,10 @@ def barra(): resposta.headers['Last-Modified'] = data return resposta -#if __name__ == '__main__': -# import webbrowser -# webbrowser.open("http://127.0.0.1:5000/",new=1) -# app.run(host='0.0.0.0', debug=True) +if __name__ == '__main__': + import webbrowser + webbrowser.open("http://127.0.0.1:5000/",new=1) + app.run(host='0.0.0.0', debug=True) #webbrowser.open("https://127.0.0.1:5000/",new=2) #app.run(debug=False,ssl_context=ctx) diff --git a/app/profile.py b/app/profile.py index 82a13ee..d93d096 100644 --- a/app/profile.py +++ b/app/profile.py @@ -4,4 +4,6 @@ from barrabrasil import app app.config['PROFILE'] = True app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions = [30]) #30 que mais demoraram -app.run(debug = True) +import webbrowser +webbrowser.open("http://127.0.0.1:5000/",new=1) +app.run(host='0.0.0.0', debug=True) diff --git a/build.sh b/build.sh index 083e700..84bad1c 100755 --- a/build.sh +++ b/build.sh @@ -4,7 +4,7 @@ if [ -n "$1" ] then profile=$1 else - profile='default' + profile=$(cat app/profile | awk 'FNR == 1 {print $3}') fi if test -d "recipes/$profile" @@ -15,9 +15,11 @@ then touch profile echo 'profile :' $profile > profile echo 'date : "'$(date -R)'"'>> profile - mkdir templates/$profile + if test ! -d "templates/$profile" + then + mkdir templates/$profile + fi cp templates/$profile/* static/ #Copiando enquanto a barra é estática. - python barrabrasil.py else - echo "Error. Profile $1 does not exist." + echo "Erro. O profile '$profile' não existe." fi diff --git a/makefile b/makefile new file mode 100644 index 0000000..5f0ef0b --- /dev/null +++ b/makefile @@ -0,0 +1,27 @@ +# Makefile +run: build + venv/bin/python app/barrabrasil.py + + +profile: build + venv/bin/python app/profile.py + +build: venv + sh ./build.sh + +venv: venv/bin/activate +venv/bin/activate: requirements.txt package.json + test -d .env || virtualenv --no-site-packages venv + venv/bin/pip install -Ur requirements.txt + touch venv/bin/activate + npm install + +testReport: + npm run testReport + +teste: + npm test + + + + diff --git a/package.json b/package.json new file mode 100644 index 0000000..21c904d --- /dev/null +++ b/package.json @@ -0,0 +1,25 @@ +{ +"name": "BarraBrasil", +"description": "Barra oficial do governo federal brasileiro", +"version": "2.1.3", +"engines": { +"node": "~0.10" +}, +"dependencies": { +"jsdom": "3.1.2", +"uglifyjs": "*", +"coffee-script": "*", +"express": "*", +"chai": "*", +"chai-jq": "*", +"mocha": "*", +"zombie": "*", +"ejs": "*" +}, +"optionalDependencies": {}, +"scripts": { +"testReport": "./node_modules/.bin/mocha --timeout 30000 --recursive -R xunit test/ > test-reports.xml", +"test": "./node_modules/.bin/mocha --timeout 30000 --recursive test/" +} +} + diff --git a/recipes/default/assets.json b/recipes/default/assets.json index 8dd4809..b039e50 100644 --- a/recipes/default/assets.json +++ b/recipes/default/assets.json @@ -1 +1 @@ -{"barra-brasil.js": "barra-brasil.js"} \ No newline at end of file +{"footer-brasil-1.js": "footer-brasil-1.js", "estilo-footer.css": "estilo-footer.css", "footer-brasil-css.js": "footer-brasil-css.js"} \ No newline at end of file diff --git a/recipes/default/compile.sh b/recipes/default/compile.sh index e1e89a7..e2c3ea3 100644 --- a/recipes/default/compile.sh +++ b/recipes/default/compile.sh @@ -1,7 +1,8 @@ #!/bin/sh -assetgen ./barra-brasil-1.yaml -assetgen ./barra-brasil-2.yaml -assetgen ./footer-brasil-1.yaml -assetgen ./footer-brasil-2.yaml -assetgen ./barra-brasil-final.yaml +export PATH=$PATH:../../node_modules/.bin/ +../../venv/bin/assetgen ./barra-brasil-1.yaml +../../venv/bin/assetgen ./barra-brasil-2.yaml +../../venv/bin/assetgen ./footer-brasil-1.yaml +../../venv/bin/assetgen ./footer-brasil-2.yaml +../../venv/bin/assetgen ./barra-brasil-final.yaml diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..5ee5317 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +Flask +Assetgen +Config -- libgit2 0.21.2