Get the sources¶
git clone https://pagure.io/pagure.git
git clone ssh://firstname.lastname@example.org/pagure.git
Install the build dependencies of pagure:
sudo dnf install git python-virtualenv libgit2-devel \ libjpeg-devel gcc libffi-devel redhat-rpm-config
The python dependencies of pagure are listed in the file
at the top level of the sources.
virtualenv pagure_env source ./pagure_env/bin/activate pip install pygit2==<version of libgit2 found>.* # e.g. 0.23.* pip install -r requirements.txt
Run pagure for development¶
Adjust the configuration file (secret key, database URL, admin group...) See Configuration for more detailed information about the configuration.
Create the database scheme:
Create the folder that will receive the different git repositories:
Run the server:
If you want to change some configuration key you can create a file, place the configuration change in it and use it with
./runserver.py -c <config_file>
For example, create the file
config with in it:
from datetime import timedelta # Makes the admin session longer ADMIN_SESSION_LIFETIME = timedelta(minutes=20000000) # Use a postgresql database instead of sqlite DB_URL = 'postgresql://user:pass@localhost/pagure' # Change the OpenID endpoint FAS_OPENID_ENDPOINT = 'https://id.stg.fedoraproject.org' APP_URL = '*' EVENTSOURCE_SOURCE = 'http://localhost:8080' EVENTSOURCE_PORT = '8080' DOC_APP_URL = '*' # Avoid sending email when developping EMAIL_SEND = False
and run the server with:
./runserver.py -c config
To get some profiling information you can also run it as:
You should be able to access the server at http://localhost:5000
Every time you save a file, the project will be automatically restarted so you can see your change immediately.
Create a pull-request for testing¶
When working on pagure, it is pretty often that one wanted to work on a feature or a bug related to pull-requests needs to create one.
Making a pull-request for development purposes isn’t hard, if you remember that since you’re running a local instance, the git repos created in your pagure instance are also local.
So here are in a few steps that one could perform to create a pull-request in a local pagure instance.
Create a project on your pagure instance, let’s say it will be called
Create a folder
clonessomewhere in your system (you probably do not want it in the
reposfolder created above, next to it is fine though):
Clone the repo of the
testproject into this
clonesfolder and move into it:
cd clones git clone ~/path/to/pagure/repos/test.git cd test
Add and commit some files:
echo "*~" > .gitignore git add .gitignore git commit -m "Add a .gitignore file" echo "BSD" > LICENSE git add LICENSE git commit -m "Add a LICENSE file"
Push these changes:
git push -u origin master
Create a new branch and add a commit in it:
git branch new_branch git checkout new_branch touch test git add test git commit -m "Add file: test"
Push this new branch:
git push -u origin new_branch
Then go back to your pagure instance running in your web-browser, check the
test project. You should see two branches:
from there you should be able to open a new pull-request, either from the
front page or via the
File Pull Request button in the
We are also inspecting the code using pylint and aim of course for a 10/10 code (but it is an assymptotic goal).
both pep8 and pylint are available in Fedora:
dnf install python-pep8 pylint
yum install python-pep8 pylint
The easiest way to work on pagure is to make your own branch in git, make your changes to this branch, commit whenever you want, rebase on master, whenever you need and when you are done, send the patch either by email, via the trac or a pull-request (using git or github).
The workflow would therefore be something like:
git branch <my_shiny_feature> git checkout <my_shiny_feature> <work> git commit file1 file2 <more work> git commit file3 file4 git checkout master git pull git checkout <my_shiny_feature> git rebase master git format-patch -2
This will create two patch files that you can send by email to submit in a ticket
on pagure, by email or after forking the project on pagure by submitting a
pull-request (in which case the last step above
git format-patch -2 is not
Pagure has a number of unit-tests.
We aim at having a full (100%) coverage of the whole code (including the Flask application) and of course a smart coverage as in we want to check that the functions work the way we want but also that they fail when we expect it and the way we expect it.
Tests checking that function are failing when/how we want are as important as tests checking they work the way they are intended to.
So here are a few steps that one could perform to run unit-tests in a local pagure instance.
Install the dependencies:
pip install -r tests_requirements.txt
runtests.sh, located at the top of the sources, helps to run the
unit-tests of the project with coverage information using python-nose.
You can specify additional arguments to the nose command used in this script by just passing arguments to the script.
For example you can specify the
Stop running tests after the first error or failure by just doing
Each unit-tests files (located under
tests/) can be called
by alone, allowing easier debugging of the tests. For example:
In order to have coverage information you might have to install
dnf install python-coverage
yum install python-coverage