Bläddra i källkod

Merge pull request #995 from dalf/selenium

[fix] fix travis build
Adam Tauber 7 år sedan
förälder
incheckning
d4aa1dccee
5 ändrade filer med 63 tillägg och 34 borttagningar
  1. 4
    5
      .travis.yml
  2. 53
    28
      manage.sh
  3. 1
    1
      requirements-dev.txt
  4. 4
    0
      searx/static/themes/oscar/gruntfile.js
  5. 1
    0
      searx/static/themes/simple/gruntfile.js

+ 4
- 5
.travis.yml Visa fil

@@ -14,12 +14,11 @@ before_install:
14 14
   - "export DISPLAY=:99.0"
15 15
   - "sh -e /etc/init.d/xvfb start"
16 16
   - npm install less less-plugin-clean-css grunt-cli
17
-  - ( cd searx/static/themes/oscar;npm install; cd - )
18
-  - ( cd searx/static/themes/simple;npm install; cd - )
19
-  - mkdir -p ~/drivers; export PATH=~/drivers:$PATH;
20
-  - GECKODRIVER_URL="https://github.com/mozilla/geckodriver/releases/download/v0.14.0/geckodriver-v0.14.0-linux64.tar.gz";
21
-  - FILE=`mktemp`; wget "$GECKODRIVER_URL" -qO $FILE && tar xz -C ~/drivers -f $FILE geckodriver; rm $FILE; chmod 777 ~/drivers/geckodriver;
17
+  - export PATH=`pwd`/node_modules/.bin:$PATH
18
+  - ./manage.sh install_geckodriver ~/drivers
19
+  - export PATH=~/drivers:$PATH
22 20
 install:
21
+  - ./manage.sh npm_packages
23 22
   - ./manage.sh update_dev_packages
24 23
   - pip install coveralls
25 24
 script:

+ 53
- 28
manage.sh Visa fil

@@ -5,6 +5,8 @@ PYTHONPATH=$BASE_DIR
5 5
 SEARX_DIR="$BASE_DIR/searx"
6 6
 ACTION=$1
7 7
 
8
+cd "$BASE_DIR"
9
+
8 10
 update_packages() {
9 11
     pip install -r "$BASE_DIR/requirements.txt"
10 12
 }
@@ -14,16 +16,17 @@ update_dev_packages() {
14 16
     pip install -r "$BASE_DIR/requirements-dev.txt"
15 17
 }
16 18
 
17
-check_geckodriver() {
19
+install_geckodriver() {
18 20
     echo '[!] Checking geckodriver'
21
+    # TODO : check the current geckodriver version
19 22
     set -e
20 23
     geckodriver -V 2>1 > /dev/null || NOTFOUND=1
21 24
     set +e
22 25
     if [ -z $NOTFOUND ]; then
23 26
 	return
24 27
     fi
25
-    GECKODRIVER_VERSION="v0.14.0"
26
-    PLATFORM=`python -c "import platform; print platform.system().lower(), platform.architecture()[0]"`
28
+    GECKODRIVER_VERSION="v0.18.0"
29
+    PLATFORM=`python -c "import six; import platform; six.print_(platform.system().lower(), platform.architecture()[0])"`
27 30
     case $PLATFORM in
28 31
 	"linux 32bit" | "linux2 32bit") ARCH="linux32";;
29 32
 	"linux 64bit" | "linux2 64bit") ARCH="linux64";;
@@ -32,16 +35,25 @@ check_geckodriver() {
32 35
 	"mac 64bit") ARCH="macos";;
33 36
     esac
34 37
     GECKODRIVER_URL="https://github.com/mozilla/geckodriver/releases/download/$GECKODRIVER_VERSION/geckodriver-$GECKODRIVER_VERSION-$ARCH.tar.gz";
35
-    if [ -z "$VIRTUAL_ENV" ]; then
36
-	echo "geckodriver can't be installed because VIRTUAL_ENV is not set, you should download it from\n  $GECKODRIVER_URL"
37
-	exit
38
+
39
+    if [ -z "$1" ]; then
40
+	if [ -z "$VIRTUAL_ENV" ]; then
41
+	    echo "geckodriver can't be installed because VIRTUAL_ENV is not set, you should download it from\n  $GECKODRIVER_URL"
42
+	    exit    
43
+	else
44
+	    GECKODRIVER_DIR="$VIRTUAL_ENV/bin"
45
+	fi
38 46
     else
39
-	echo "Installing $VIRTUAL_ENV from\n  $GECKODRIVER_URL"
40
-	FILE=`mktemp`
41
-	wget "$GECKODRIVER_URL" -qO $FILE && tar xz -C $VIRTUAL_ENV/bin/ -f $FILE geckodriver
42
-	rm $FILE
43
-	chmod 777 $VIRTUAL_ENV/bin/geckodriver
47
+	GECKODRIVER_DIR="$1"
48
+	mkdir -p "$GECKODRIVER_DIR"
44 49
     fi
50
+
51
+    echo "Installing $GECKODRIVER_DIR/geckodriver from\n  $GECKODRIVER_URL"
52
+    
53
+    FILE=`mktemp`
54
+    wget "$GECKODRIVER_URL" -qO $FILE && tar xz -C "$GECKODRIVER_DIR" -f $FILE geckodriver
55
+    rm $FILE
56
+    chmod 777 "$GECKODRIVER_DIR/geckodriver"
45 57
 }
46 58
 
47 59
 pep8_check() {
@@ -73,37 +85,49 @@ tests() {
73 85
     set -e
74 86
     pep8_check
75 87
     unit_tests
76
-    check_geckodriver
88
+    install_geckodriver
77 89
     robot_tests
78 90
     set +e
79 91
 }
80 92
 
81 93
 build_style() {
82
-    # lessc -x "$BASE_DIR/searx/static/$1" "$BASE_DIR/searx/static/$2"
83 94
     lessc --clean-css="--s1 --advanced --compatibility=ie9" "$BASE_DIR/searx/static/$1" "$BASE_DIR/searx/static/$2"
84 95
 }
85 96
 
86 97
 styles() {
87 98
     echo '[!] Building styles'
88
-	build_style themes/legacy/less/style.less themes/legacy/css/style.css
89
-	build_style themes/legacy/less/style-rtl.less themes/legacy/css/style-rtl.css
90
-	build_style themes/courgette/less/style.less themes/courgette/css/style.css
91
-	build_style themes/courgette/less/style-rtl.less themes/courgette/css/style-rtl.css
92
-	build_style less/bootstrap/bootstrap.less css/bootstrap.min.css
93
-	build_style themes/oscar/less/pointhi/oscar.less themes/oscar/css/pointhi.min.css
94
-	build_style themes/oscar/less/logicodev/oscar.less themes/oscar/css/logicodev.min.css
95
-	build_style themes/pix-art/less/style.less themes/pix-art/css/style.css
96
-	build_style themes/simple/less/style.less themes/simple/css/searx.min.css
97
-	build_style themes/simple/less/style-rtl.less themes/simple/css/searx-rtl.min.css
99
+    build_style themes/legacy/less/style.less themes/legacy/css/style.css
100
+    build_style themes/legacy/less/style-rtl.less themes/legacy/css/style-rtl.css
101
+    build_style themes/courgette/less/style.less themes/courgette/css/style.css
102
+    build_style themes/courgette/less/style-rtl.less themes/courgette/css/style-rtl.css
103
+    build_style less/bootstrap/bootstrap.less css/bootstrap.min.css
104
+    build_style themes/pix-art/less/style.less themes/pix-art/css/style.css
105
+    # built using grunt
106
+    #build_style themes/oscar/less/pointhi/oscar.less themes/oscar/css/pointhi.min.css
107
+    #build_style themes/oscar/less/logicodev/oscar.less themes/oscar/css/logicodev.min.css
108
+    #build_style themes/simple/less/style.less themes/simple/css/searx.min.css
109
+    #build_style themes/simple/less/style-rtl.less themes/simple/css/searx-rtl.min.css
110
+}
111
+
112
+npm_packages() {
113
+    echo '[!] install NPM packages for oscar theme'
114
+    cd $BASE_DIR/searx/static/themes/oscar
115
+    npm install
116
+
117
+    echo '[!] install NPM packages for simple theme'    
118
+    cd $BASE_DIR/searx/static/themes/simple
119
+    npm install
98 120
 }
99 121
 
100 122
 grunt_build() {
101
-	grunt --gruntfile "$SEARX_DIR/static/themes/oscar/gruntfile.js"
102
-	grunt --gruntfile "$SEARX_DIR/static/themes/simple/gruntfile.js"
123
+    echo '[!] Grunt build : oscar theme'
124
+    grunt --gruntfile "$SEARX_DIR/static/themes/oscar/gruntfile.js"
125
+    echo '[!] Grunt build : simple theme'    
126
+    grunt --gruntfile "$SEARX_DIR/static/themes/simple/gruntfile.js"
103 127
 }
104 128
 
105 129
 locales() {
106
-	pybabel compile -d "$SEARX_DIR/translations"
130
+    pybabel compile -d "$SEARX_DIR/translations"
107 131
 }
108 132
 
109 133
 help() {
@@ -112,6 +136,7 @@ help() {
112 136
 
113 137
 Commands
114 138
 ========
139
+    npm_packages         - Download & install dependencies
115 140
     grunt_build          - Build js files
116 141
     help                 - This text
117 142
     locales              - Compile locales
@@ -123,10 +148,10 @@ Commands
123 148
     unit_tests           - Run unit tests
124 149
     update_dev_packages  - Check & update development and production dependency changes
125 150
     update_packages      - Check & update dependency changes
126
-    check_geckodriver    - Check & download geckodriver (required for robot_tests)
151
+    install_geckodriver  - Download & install geckodriver if not already installed (required for robot_tests)
127 152
 "
128 153
 }
129 154
 
130 155
 [ "$(command -V "$ACTION" | grep ' function$')" = "" ] \
131 156
     && help "action not found" \
132
-    || $ACTION
157
+    || $ACTION "$2"

+ 1
- 1
requirements-dev.txt Visa fil

@@ -7,4 +7,4 @@ splinter==0.7.5
7 7
 transifex-client==0.12.2
8 8
 unittest2==1.1.0
9 9
 zope.testrunner==4.5.1
10
-selenium==3.0.1
10
+selenium==3.5.0

+ 4
- 0
searx/static/themes/oscar/gruntfile.js Visa fil

@@ -24,6 +24,7 @@ module.exports = function(grunt) {
24 24
     jshint: {
25 25
       files: ['gruntfile.js', 'js/searx_src/*.js'],
26 26
       options: {
27
+        reporterOutput: "",	    
27 28
         // options here to override JSHint defaults
28 29
         globals: {
29 30
           jQuery: true,
@@ -51,6 +52,8 @@ module.exports = function(grunt) {
51 52
             files: {"css/pointhi.min.css": "less/pointhi/oscar.less",
52 53
                     "css/logicodev.min.css": "less/logicodev/oscar.less"}
53 54
         },
55
+        /*
56
+	// built with ./manage.sh styles
54 57
         bootstrap: {
55 58
             options: {
56 59
                 paths: ["less/bootstrap"],
@@ -58,6 +61,7 @@ module.exports = function(grunt) {
58 61
             },
59 62
             files: {"css/bootstrap.min.css": "less/bootstrap/bootstrap.less"}
60 63
         },
64
+        */
61 65
     },
62 66
     watch: {
63 67
         scripts: {

+ 1
- 0
searx/static/themes/simple/gruntfile.js Visa fil

@@ -34,6 +34,7 @@ module.exports = function(grunt) {
34 34
     jshint: {
35 35
       files: ['js/searx_src/*.js'],
36 36
       options: {
37
+        reporterOutput: "",
37 38
         proto: true,
38 39
         // options here to override JSHint defaults
39 40
         globals: {