Get the code¶
Clone the repository with the following command:
git clone https://gitlab.wikimedia.org/repos/releng/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 GitLab for code review. To contribute to this project you will need a Wikimedia GitLab account, see the guide on mediawiki.org for setup instructions
Testing¶
To run unit tests, lint, coverage and update documentation, simply run
scripts/check
without any arguments. For this to work you
must have shellcheck, pytest, flake8, and sphinx-build installed.
If you have Docker installed and you want to run tests without having
to install prerequisite packages on your system, you can run
make test
to run tests inside a properly-provisioned
container.
Git pre-commit hook¶
There is an example pre-commit hook that can
run tox -e flake8
and tox -e doc
before allowing a commit to
proceed.
1 #!/bin/bash
2 # example pre-commit hook for git which runs `flake8` and `tox -e doc`
3 # before each commit, aborting the commit if there is a lint error.
4
5
6 if ! lint=$(tox -e flake8 2>&1); then
7 echo "$lint"
8 exit 1
9 fi
10
11 # Remove the remaining code if you don't want to rebuild docs on each commit
12 if ! tox=$(tox -e doc 2>&1); then
13 echo "$tox"
14 exit 1
15 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/dev/pre-commit.sh .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit