README.rst 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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 on IRC in the channel ``#pagure`` of the freenode server
  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. Once installed, create the folder that will receive the projects, forks, docs,
  31. requests and tickets' git repo. Run this command exactly as it appears from
  32. within the cloned git repo folder::
  33. $ mkdir -p lcl/{repos,remotes,attachments,releases}
  34. A docker compose environment is available to run pagure. First use the following
  35. command to build the containers. ::
  36. $ docker-compose -f dev/docker-compose.yml build
  37. Once all the containers are built, run the following command to start the containers. ::
  38. $ docker-compose -f dev/docker-compose.yml up
  39. Once all the containers have started, you can access pagure on http://localhost:5000.
  40. To stop the containers, press Ctrl+C.
  41. Once the containers are up and running after running the previous command, run
  42. this command to populate the container with test data and create a new account ::
  43. $ docker-compose -f dev/docker-compose.yml exec web python dev-data.py --all
  44. You can then login with any of the created users, by example:
  45. - username: pingou
  46. - password: testing123
  47. Vagrant
  48. ^^^^^^^
  49. For a more thorough introduction to Vagrant, see
  50. https://fedoraproject.org/wiki/Vagrant.
  51. An example Vagrantfile is provided as ``Vagrantfile.example``. To use it,
  52. just copy it and install Vagrant. Instructions for Fedora::
  53. $ cp dev/Vagrantfile.example Vagrantfile
  54. $ sudo dnf install ansible libvirt vagrant-libvirt vagrant-sshfs vagrant-hostmanager
  55. $ vagrant up
  56. On Ubuntu, install Vagrant directly `from the website <https://www.vagrantup.com/downloads.html>`_
  57. then run these commands instead::
  58. $ cp dev/Vagrantfile.example Vagrantfile
  59. $ sudo add-apt-repository ppa:ansible/ansible
  60. $ sudo apt update
  61. $ sudo apt install ansible libvirt0 openssh-server qemu libvirt-bin ebtables dnsmasq libxslt-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev
  62. $ vagrant plugin install vagrant-libvirt vagrant-sshfs vagrant-hostmanager
  63. If you get this error ``Block in synced_folders: Internal error. Invalid: sshfs``,
  64. when you run ``vagrant up`` , you need to install vagrant sshfs plugin, which can be done by::
  65. $ vagrant plugin install vagrant--sshfs
  66. and then::
  67. $ vagrant up
  68. The default ``Vagrantfile`` forwards ports from the host to the guest,
  69. so you can interact with the application as if it were running on your
  70. host machine.
  71. .. note::
  72. ``vagrant-hostmanager`` will automatically maintain /etc/hosts for you so you
  73. can access the development environment from the host using its hostname, which
  74. by default is ``pagure-dev.example.com``. You can choose not to use this
  75. functionality by simply not installing the ``vagrant-hostmanager`` plugin, but
  76. if you want Pagure to provide valid URLs in the UI for git repositories, you
  77. will need to adjust Pagure's configuration found in ~/pagure.cfg on the guest.
  78. When the vagrant VM is up and running, connect to it with::
  79. $ vagrant ssh
  80. This will log you into the VM as the user ``vagrant`` which has a couple of aliases
  81. preconfigured::
  82. $ pstart # Starts pagure, the workers and other tasks
  83. $ pstop # Stops all those tasks again
  84. $ pstatus # Shows pagure status
  85. The Vagrant pagure doesn't have its own log file, use ``journalctl -f`` to
  86. show the pagure output. The verbosity can be configured in the pagure config file
  87. with the ``LOGGING`` parameter.
  88. Running the unit-tests
  89. **********************
  90. To run the unit-tests, there is container available with all the dependencies needed.
  91. First you will need to have podman installed on your workstation. ::
  92. $ sudo dnf install podman
  93. Use the following command to run the tests ::
  94. $ ./dev/run-tests-container.py
  95. This command will build a fedora based container and execute the test suite.
  96. If you wish to execute the test suite on a centos based container run the following command ::
  97. $ ./dev/run-tests-container.py --centos
  98. When the test container image has been built you can skip the building step to save time
  99. and run directly the test suite. ::
  100. $ ./dev/run-tests-container.py --skip-build
  101. $ ./dev/run-tests-container.py --centos --skip-build
  102. You can also run a single test case ::
  103. $ ./dev/run-tests-container.py tests/test_pagure_flask_ui_priorities.py
  104. Or a single test ::
  105. $ ./dev/run-tests-container.py tests/test_pagure_flask_ui_priorities.py:PagureFlaskPrioritiestests.test_ticket_with_no_priority
  106. You can also get `run-tests-container` help ::
  107. $ ./dev/run-tests-container.py --help
  108. Manually
  109. ^^^^^^^^
  110. * Install the needed system libraries::
  111. sudo dnf install git python3 python3-devel libgit2-devel redis \
  112. libjpeg-devel gcc libffi-devel redhat-rpm-config
  113. .. note:: Do note the version of libgit2 that you install, for example
  114. in ``libgit2-0.26.8-1`` you need to keep in mind the ``0.26``
  115. .. note:: On RHEL and derivative (CentOS, Scientific Linux) there is no
  116. `python3` package. Just `python36` or `python34` available in
  117. EPEL 7 (EPEL 6 only has `python34`). Choose the one you prefer
  118. (3.6 is newer and generally a better choice).
  119. * Retrieve the sources::
  120. git clone https://pagure.io/pagure.git
  121. cd pagure
  122. * Install dependencies
  123. * create the virtual environment (use `python3.X` explicitly on EPEL)::
  124. python3 -m venv pagure_env
  125. source ./pagure_env/bin/activate
  126. * Install the correct version of pygit2::
  127. pip install pygit2==<version of libgit2 found>.*
  128. So in our example::
  129. pip install pygit2==0.26.*
  130. * Install the rest of the dependencies::
  131. pip install -r requirements.txt
  132. * Create the folder that will receive the projects, forks, docs, requests and
  133. tickets' git repo::
  134. mkdir -p lcl/{repos,remotes,attachments,releases}
  135. * Copy and edit the alembic.ini file (especially the ``script_location`` key)::
  136. cp files/alembic.ini .
  137. vim alembic.ini
  138. * Set the ``script_location`` to ``alembic``, ie: the folder where the revisions
  139. are stored, relative to the location of the ``alembic.ini`` file.
  140. * Create the inital database scheme::
  141. python createdb.py --initial alembic.ini
  142. * Enable and start redis server::
  143. sudo systemctl enable redis
  144. sudo systemctl start redis
  145. * Start a worker, in one terminal::
  146. ./runworker.py
  147. * Run the application, in another terminal::
  148. ./runserver.py
  149. * To get some profiling information you can also run it as::
  150. ./runserver.py --profile
  151. This will launch the application at http://127.0.0.1:5000
  152. * To run unit-tests on pagure
  153. * Install the dependencies::
  154. pip install -r requirements-testing.txt
  155. * Run it::
  156. python runtests.py run
  157. You may use::
  158. python runtests.py --help
  159. to check other options supported or read the source code ;-)
  160. .. note:: While testing for worker tasks, pagure uses celery in /usr/bin/
  161. Celery then looks for eventlet (which we use for testing only) at
  162. system level and not in virtual environment. You will need to
  163. install eventlet outside of your virtual environment if you are
  164. using one.