Get the code

Clone the repository with the following command:

git clone https://phabricator.wikimedia.org/diffusion/MSCA/scap.git

Scap-Vagrant

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

Code Review

The scap team uses Phabricator for code review. To contribute to this project you should use Phabricator’s code review tool, arcanist to submit your changes for review.

Read the Arcanist Quick Start guide to learn about installing arcanist.

Once you have installed arcanist, you can use the arc diff command to submit a revision based on the last commit in your working tree.

Other useful arc sub-commands:

  • arc lint - run lint (pep8) on the changes in your working tree.
  • arc unit - run unit tests on the changes in your working tree.

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 arc lint 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 `arc lint` and `tox -e doc`
# before each commit, aborting the commit if there is a lint error.


lint=`arc lint`
if [ $? != 0 ]; then
    arc 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