Get the code

Clone the repository with the following command:

git clone https://gerrit.wikimedia.org/r/mediawiki/tools/scap

Scap-Vagrant

For testing scap deployments, we have created a vagrant development environment called scap-vagrant

Code Review

The scap team uses Wikimedia’s Gerrit install for code review. To contribute to this project you will need a Wikimedia Gerrit account, see the guide on mediawiki.org for setup instructions

Testing

Scap uses tox to run unit tests and to generate the documentation.

To run unit tests, lint, coverage and update documentation, simply run tox without any arguments.

Git pre-commit hook

There is an example pre-commit hook<pre-commit.sh>`_ that can run tox -e flake8 and tox -e doc before allowing a commit to proceed.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#!/bin/bash
# example pre-commit hook for git which runs `flake8` and `tox -e doc`
# before each commit, aborting the commit if there is a lint error.


lint=`tox -e flake8 2>&1`
if [ $? != 0 ]; then
    echo $lint
    exit 1
fi

# Remove the remaining code if you don't want to rebuild docs on each commit
tox=`tox -e doc 2>&1`
if [ $? != 0 ]; then
    echo $tox
    exit $?
fi

This can help you catch problems earlier, before preparing to submit a change for review. If you would like to install this hook in your repository, simply copy the pre-commit.sh into your .git/hooks folder and make it executable.

Specifically, run the following from the root of your scap repository:

cp docs/pre-commit.sh .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit