README.rst 7.9 KB

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