summaryrefslogtreecommitdiff
path: root/docs/dev/quickstart.rst
blob: e40772b3b1f08df713f689a07195075bc6438fea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
.. _devquickstart:

======================
Development Quickstart
======================

.. sidebar:: :ref:`makefile`

   For additional developer purpose there are :ref:`makefile`.

This quickstart guide gets your environment set up with searx.  Furthermore, it
gives a short introduction to the ``manage.sh`` script.

How to setup your development environment
=========================================

.. sidebar:: :ref:`make pyenv <make pyenv>`

   Alternatively use the :ref:`make pyenv`.

First, clone the source code of searx to the desired folder.  In this case the
source is cloned to ``~/myprojects/searx``.  Then create and activate the
searx-ve virtualenv and install the required packages using ``manage.sh``.

.. code:: sh

    cd ~/myprojects
    git clone https://github.com/asciimoo/searx.git
    cd searx
    virtualenv searx-ve
    . ./searx-ve/bin/activate
    ./manage.sh update_dev_packages


How to run tests
================

.. sidebar:: :ref:`make test.unit <make test>`

   Alternatively use the ``test.pep8``, ``test.unit``, ``test.robot`` targets.

Tests can be run using the ``manage.sh`` script.  Following tests and checks are
available:

- Unit tests
- Selenium tests
- PEP8 validation
- Unit test coverage check

For example unit tests are run with the command below:

.. code:: sh

   ./manage.sh unit_tests

For further test options, please consult the help of the ``manage.sh`` script or
read :ref:`make test`.


How to compile styles and javascript
====================================

.. _less: http://lesscss.org/
.. _NodeJS: https://nodejs.org

How to build styles
-------------------

Less_ is required to build the styles of searx.  Less_ can be installed using
either NodeJS_ or Apt.

.. code:: sh

   sudo -H apt-get install nodejs
   sudo -H npm install -g less

OR

.. code:: sh

   sudo -H apt-get install node-less

After satisfying the requirements styles can be build using ``manage.sh``

.. code:: sh

   ./manage.sh styles


How to build the source of the oscar theme
==========================================

.. _grunt: https://gruntjs.com/

Grunt_ must be installed in order to build the javascript sources. It depends on
NodeJS, so first Node has to be installed.

.. code:: sh

   sudo -H apt-get install nodejs
   sudo -H npm install -g grunt-cli

After installing grunt, the files can be built using the following command:

.. code:: sh

   ./manage.sh grunt_build


Tips for debugging/development
==============================

.. sidebar:: :ref:`make run`

   Makefile target ``run`` already enables debug option for your developer
   session / see :ref:`make run`.

Turn on debug logging
  Whether you are working on a new engine or trying to eliminate a bug, it is
  always a good idea to turn on debug logging.  When debug logging is enabled a
  stack trace appears, instead of the cryptic ``Internal Server Error``
  message. It can be turned on by setting ``debug: False`` to ``debug: True`` in
  :origin:`settings.yml <searx/settings.yml>`.

.. sidebar:: :ref:`make test`

   Alternatively use the :ref:`make test` targets.

Run ``./manage.sh tests`` before creating a PR.
  Failing build on Travis is common because of PEP8 checks.  So a new commit
  must be created containing these format fixes.  This phase can be skipped if
  ``./manage.sh tests`` is run locally before creating a PR.