README.rst 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. Pagure
  2. ======
  3. :Author: Pierre-Yves Chibon <pingou@pingoured.fr>
  4. Pagure is a git-centered forge, python based using pygit2.
  5. With pagure you can host your project with its documentation, let your users
  6. report issues or request enhancements using the ticketing system and build your
  7. community of contributors by allowing them to fork your projects and contribute
  8. to it via the now-popular pull-request mechanism.
  9. Homepage: https://pagure.io/pagure
  10. See it at work: https://pagure.io
  11. Playground version: https://stg.pagure.io
  12. If you have any questions or just would like to discuss about pagure,
  13. feel free to drop by `our Matrix room <https://matrix.to/#/#pagure:fedora.im>`_.
  14. About its name
  15. ==============
  16. The name Pagure is taken from the French word 'pagure'. Pagure in French is used as the
  17. common name for the crustaceans from the `Paguroidea <https://en.wikipedia.org/wiki/Hermit_crab>`_
  18. superfamily, which is basically the family of the Hermit crabs.
  19. Originating from French it is pronounced with a strong 'g' as you can hear
  20. on `this recording <https://pagure.io/how-do-you-pronounce-pagure/raw/master/f/pingou.ogg>`_.
  21. Get it running
  22. ==============
  23. There are several options when it comes to a development environment.
  24. They are: Docker Compose, Vagrant, and manual. Choose an option below.
  25. Docker Compose
  26. ^^^^^^^^^^^^^^
  27. Docker Compose will provide you with a container which you can develop on.
  28. Install it `with these instructions <https://docs.docker.com/compose/install/>`_.
  29. For more information about docker-compose cli, see: https://docs.docker.com/compose/reference/.
  30. To build and run the containers, use the following command:
  31. .. code-block::
  32. ./dev/docker-start.sh
  33. Once all the containers have started, you can access pagure on http://localhost:5000.
  34. To stop the containers, press ``Ctrl+C``.
  35. Once the containers are up and running, run this command to populate the
  36. container with test data and create a new account:
  37. .. code-block::
  38. docker-compose -f dev/docker-compose.yml exec web python3 dev-data.py --all
  39. You can then log in with any of the created users, by example:
  40. - username: pingou
  41. - password: testing123
  42. Vagrant
  43. ^^^^^^^
  44. For a more thorough introduction to Vagrant, see
  45. https://fedoraproject.org/wiki/Vagrant.
  46. An example Vagrantfile is provided as ``Vagrantfile.example``. To use it,
  47. just copy it and install Vagrant. Instructions for Fedora:
  48. .. code-block::
  49. cp dev/Vagrantfile.example Vagrantfile
  50. sudo dnf install ansible libvirt vagrant-libvirt vagrant-sshfs vagrant-hostmanager
  51. vagrant up
  52. On Ubuntu, install Vagrant directly `from the website <https://www.vagrantup.com/downloads.html>`_
  53. then run these commands instead:
  54. .. code-block::
  55. cp dev/Vagrantfile.example Vagrantfile
  56. sudo add-apt-repository ppa:ansible/ansible
  57. sudo apt update
  58. sudo apt install ansible libvirt0 openssh-server qemu libvirt-bin ebtables dnsmasq libxslt-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev
  59. vagrant plugin install vagrant-libvirt vagrant-sshfs vagrant-hostmanager
  60. If you get this error ``Block in synced_folders: Internal error. Invalid: sshfs``,
  61. when you run ``vagrant up`` , you need to install vagrant sshfs plugin, which can be done by:
  62. .. code-block::
  63. vagrant plugin install vagrant--sshfs
  64. and then:
  65. .. code-block::
  66. vagrant up
  67. The default ``Vagrantfile`` forwards ports from the host to the guest,
  68. so you can interact with the application as if it were running on your
  69. host machine.
  70. .. note::
  71. ``vagrant-hostmanager`` will automatically maintain /etc/hosts for you so you
  72. can access the development environment from the host using its hostname, which
  73. by default is ``pagure-dev.example.com``. You can choose not to use this
  74. functionality by simply not installing the ``vagrant-hostmanager`` plugin, but
  75. if you want Pagure to provide valid URLs in the UI for git repositories, you
  76. will need to adjust Pagure's configuration found in ~/pagure.cfg on the guest.
  77. When the vagrant VM is up and running, connect to it with:
  78. .. code-block::
  79. vagrant ssh
  80. This will log you into the VM as the user ``vagrant`` which has a couple of aliases
  81. preconfigured:
  82. .. code-block::
  83. pstart # Starts pagure, the workers and other tasks
  84. pstop # Stops all those tasks again
  85. pstatus # Shows pagure status
  86. The Vagrant pagure doesn't have its own log file, use ``journalctl -f`` to
  87. show the pagure output. The verbosity can be configured in the pagure config file
  88. with the ``LOGGING`` parameter.
  89. Running the unit-tests in container
  90. ***********************************
  91. To run the unit-tests, there are containers available with all the dependencies needed.
  92. .. note::
  93. All build, test and shell activities executed via ``run-tests-container.py`` will automatically be logged.
  94. Every container has it's own ``dev/results_<test-container-name>`` folder, every run creates separate
  95. files with the current unix timestamp as prefix. You should cleanup this folder from time to time.
  96. First you will need to have podman and git installed on your workstation:
  97. .. code-block::
  98. sudo dnf install podman git
  99. Use the following command to run all tests on all container images, if the images not exist on your system, they will be build:
  100. .. code-block::
  101. ./dev/run-tests-container.py
  102. If you wish to execute the test suite on a centos based container run the following command:
  103. .. code-block::
  104. ./dev/run-tests-container.py --centos
  105. Container images are separated from the pagure source that will be tested.
  106. Therefore they will only automatically build if they not exist.
  107. A manual rebuild should be done from time to time to include new package versions.
  108. Also if you work on any changes in the pagure spec file, the tox config or any requirements.txt file,
  109. perform a rebuild to ensure your changed will taken into account.
  110. .. code-block::
  111. ./dev/run-tests-container.py --rebuild # all base and code container
  112. ./dev/run-tests-container.py --rebuild-code # code container only
  113. You can also run a single test case:
  114. .. code-block::
  115. ./dev/run-tests-container.py tests/test_pagure_flask_ui_priorities.py
  116. Or a single test:
  117. .. code-block::
  118. ./dev/run-tests-container.py tests/test_pagure_flask_ui_priorities.py:PagureFlaskPrioritiestests.test_ticket_with_no_priority
  119. You can also get ``run-tests-container.py`` help:
  120. .. code-block::
  121. ./dev/run-tests-container.py --help
  122. By default, tests run against the git repo and the active branch in the current folder.
  123. To override this behavior and run the tests on your remote development branch in your fork:
  124. .. code-block::
  125. ./dev/run-tests-container.py --repo https://pagure.io/forks/<username>/pagure.git --branch <name of branch to test>
  126. Running the unit-tests in tox
  127. *****************************
  128. You can run the tests using tox. This allows you to run the tests on local version of the code.
  129. .. note::
  130. This way of running tests could help you test your local changes,
  131. but the output could be different then from the containerized tests.
  132. Always check your branch after push with containerized tests as well.
  133. * Install the needed system libraries:
  134. .. code-block::
  135. sudo dnf install libgit2-devel redis gcc tox python-alembic
  136. .. note::
  137. You can also install any missing python interpreter.
  138. For example `sudo dnf install python35`
  139. * Run the whole test suite:
  140. .. code-block::
  141. tox
  142. * Or just single environment:
  143. .. code-block::
  144. tox -e py39
  145. * Or single module:
  146. .. code-block::
  147. tox tests/test_style.py
  148. Manually
  149. ^^^^^^^^
  150. * Install the needed system libraries:
  151. .. code-block::
  152. sudo dnf install git python3 python3-devel libgit2-devel redis \
  153. libjpeg-devel gcc libffi-devel redhat-rpm-config
  154. .. note::
  155. Do note the version of libgit2 that you install, for example
  156. in ``libgit2-0.26.8-1`` you need to keep in mind the ``0.26``
  157. .. note::
  158. On RHEL and derivative (CentOS, Scientific Linux) there is no
  159. `python3` package. Just `python36` or `python34` available in
  160. EPEL 7 (EPEL 6 only has `python34`). Choose the one you prefer
  161. (3.6 is newer and generally a better choice).
  162. * Retrieve the sources:
  163. .. code-block::
  164. git clone https://pagure.io/pagure.git
  165. cd pagure
  166. * Install dependencies
  167. * create the virtual environment (use `python3.X` explicitly on EPEL):
  168. .. code-block::
  169. python3 -m venv pagure_env
  170. source ./pagure_env/bin/activate
  171. * Install the correct version of pygit2:
  172. .. code-block::
  173. pip install pygit2==<version of libgit2 found>.*
  174. So in our example:
  175. .. code-block::
  176. pip install pygit2==0.26.*
  177. * Install the rest of the dependencies:
  178. .. code-block::
  179. pip install -r requirements.txt
  180. * Create the folder that will receive the projects, forks, docs, requests and
  181. tickets' git repo:
  182. .. code-block::
  183. mkdir -p lcl/{repos,remotes,attachments,releases}
  184. * Copy and edit the alembic.ini file (especially the ``script_location`` key):
  185. .. code-block::
  186. cp files/alembic.ini .
  187. vim alembic.ini
  188. * Set the ``script_location`` to ``alembic``, ie: the folder where the revisions
  189. are stored, relative to the location of the ``alembic.ini`` file.
  190. * Create the inital database scheme:
  191. .. code-block::
  192. python createdb.py --initial alembic.ini
  193. * Enable and start redis server:
  194. .. code-block::
  195. sudo systemctl enable redis
  196. sudo systemctl start redis
  197. * Start a worker, in one terminal:
  198. .. code-block::
  199. ./runworker.py
  200. * Run the application, in another terminal:
  201. .. code-block::
  202. ./runserver.py
  203. * To get some profiling information you can also run it as:
  204. .. code-block::
  205. ./runserver.py --profile
  206. This will launch the application at http://127.0.0.1:5000
  207. * To run unit-tests on pagure
  208. * Install the dependencies:
  209. .. code-block::
  210. pip install -r requirements-testing.txt
  211. * Run it:
  212. .. code-block::
  213. pytest tests/
  214. .. note::
  215. While testing for worker tasks, pagure uses celery in /usr/bin/
  216. Celery then looks for eventlet (which we use for testing only) at
  217. system level and not in virtual environment. You will need to
  218. install eventlet outside of your virtual environment if you are
  219. using one.
  220. .. note::
  221. This will also work in vagrant.