Browse Source

Merge pull request #995 from dalf/selenium

[fix] fix travis build
Adam Tauber 7 years ago
parent
commit
d4aa1dccee
5 changed files with 63 additions and 34 deletions
  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 View File

14
   - "export DISPLAY=:99.0"
14
   - "export DISPLAY=:99.0"
15
   - "sh -e /etc/init.d/xvfb start"
15
   - "sh -e /etc/init.d/xvfb start"
16
   - npm install less less-plugin-clean-css grunt-cli
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
 install:
20
 install:
21
+  - ./manage.sh npm_packages
23
   - ./manage.sh update_dev_packages
22
   - ./manage.sh update_dev_packages
24
   - pip install coveralls
23
   - pip install coveralls
25
 script:
24
 script:

+ 53
- 28
manage.sh View File

5
 SEARX_DIR="$BASE_DIR/searx"
5
 SEARX_DIR="$BASE_DIR/searx"
6
 ACTION=$1
6
 ACTION=$1
7
 
7
 
8
+cd "$BASE_DIR"
9
+
8
 update_packages() {
10
 update_packages() {
9
     pip install -r "$BASE_DIR/requirements.txt"
11
     pip install -r "$BASE_DIR/requirements.txt"
10
 }
12
 }
14
     pip install -r "$BASE_DIR/requirements-dev.txt"
16
     pip install -r "$BASE_DIR/requirements-dev.txt"
15
 }
17
 }
16
 
18
 
17
-check_geckodriver() {
19
+install_geckodriver() {
18
     echo '[!] Checking geckodriver'
20
     echo '[!] Checking geckodriver'
21
+    # TODO : check the current geckodriver version
19
     set -e
22
     set -e
20
     geckodriver -V 2>1 > /dev/null || NOTFOUND=1
23
     geckodriver -V 2>1 > /dev/null || NOTFOUND=1
21
     set +e
24
     set +e
22
     if [ -z $NOTFOUND ]; then
25
     if [ -z $NOTFOUND ]; then
23
 	return
26
 	return
24
     fi
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
     case $PLATFORM in
30
     case $PLATFORM in
28
 	"linux 32bit" | "linux2 32bit") ARCH="linux32";;
31
 	"linux 32bit" | "linux2 32bit") ARCH="linux32";;
29
 	"linux 64bit" | "linux2 64bit") ARCH="linux64";;
32
 	"linux 64bit" | "linux2 64bit") ARCH="linux64";;
32
 	"mac 64bit") ARCH="macos";;
35
 	"mac 64bit") ARCH="macos";;
33
     esac
36
     esac
34
     GECKODRIVER_URL="https://github.com/mozilla/geckodriver/releases/download/$GECKODRIVER_VERSION/geckodriver-$GECKODRIVER_VERSION-$ARCH.tar.gz";
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
     else
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
     fi
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
 pep8_check() {
59
 pep8_check() {
73
     set -e
85
     set -e
74
     pep8_check
86
     pep8_check
75
     unit_tests
87
     unit_tests
76
-    check_geckodriver
88
+    install_geckodriver
77
     robot_tests
89
     robot_tests
78
     set +e
90
     set +e
79
 }
91
 }
80
 
92
 
81
 build_style() {
93
 build_style() {
82
-    # lessc -x "$BASE_DIR/searx/static/$1" "$BASE_DIR/searx/static/$2"
83
     lessc --clean-css="--s1 --advanced --compatibility=ie9" "$BASE_DIR/searx/static/$1" "$BASE_DIR/searx/static/$2"
94
     lessc --clean-css="--s1 --advanced --compatibility=ie9" "$BASE_DIR/searx/static/$1" "$BASE_DIR/searx/static/$2"
84
 }
95
 }
85
 
96
 
86
 styles() {
97
 styles() {
87
     echo '[!] Building styles'
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
 grunt_build() {
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
 locales() {
129
 locales() {
106
-	pybabel compile -d "$SEARX_DIR/translations"
130
+    pybabel compile -d "$SEARX_DIR/translations"
107
 }
131
 }
108
 
132
 
109
 help() {
133
 help() {
112
 
136
 
113
 Commands
137
 Commands
114
 ========
138
 ========
139
+    npm_packages         - Download & install dependencies
115
     grunt_build          - Build js files
140
     grunt_build          - Build js files
116
     help                 - This text
141
     help                 - This text
117
     locales              - Compile locales
142
     locales              - Compile locales
123
     unit_tests           - Run unit tests
148
     unit_tests           - Run unit tests
124
     update_dev_packages  - Check & update development and production dependency changes
149
     update_dev_packages  - Check & update development and production dependency changes
125
     update_packages      - Check & update dependency changes
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
 [ "$(command -V "$ACTION" | grep ' function$')" = "" ] \
155
 [ "$(command -V "$ACTION" | grep ' function$')" = "" ] \
131
     && help "action not found" \
156
     && help "action not found" \
132
-    || $ACTION
157
+    || $ACTION "$2"

+ 1
- 1
requirements-dev.txt View File

7
 transifex-client==0.12.2
7
 transifex-client==0.12.2
8
 unittest2==1.1.0
8
 unittest2==1.1.0
9
 zope.testrunner==4.5.1
9
 zope.testrunner==4.5.1
10
-selenium==3.0.1
10
+selenium==3.5.0

+ 4
- 0
searx/static/themes/oscar/gruntfile.js View File

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

+ 1
- 0
searx/static/themes/simple/gruntfile.js View File

34
     jshint: {
34
     jshint: {
35
       files: ['js/searx_src/*.js'],
35
       files: ['js/searx_src/*.js'],
36
       options: {
36
       options: {
37
+        reporterOutput: "",
37
         proto: true,
38
         proto: true,
38
         // options here to override JSHint defaults
39
         // options here to override JSHint defaults
39
         globals: {
40
         globals: {