We recommend following all of these steps on supernova, the staff login server, because it is already configured to run ocfweb in development mode with minimal extra setup.
Clone the repo, and be sure to check out submodules:
$ git submodule update --init
$ make install-hooks
If you get an error about not being able to import bootstrap, it's because you forgot to run the second command.
On supernova[0]run make dev
. The first time will take a while, but
future runs will be almost instant thanks to
pip-faster.
It will start listening on a deterministically random port (really, 8000 plus the last 3 digits of your user id) which is printed to you. You can then view the site in development.
Run make scss
to build SCSS. You can also use make watch-scss
to rebuild it
automatically when SCSS files change.
To run tests locally, run make test
. Please don't push to master with
failing tests—Jenkins will refuse to deploy your code, and nobody will be able
to deploy until it's fixed.
If you make a pull request to the OCF GitHub organization from your fork of
ocfweb, Jenkins will attempt to build and test your branch automatically.
If your build fails, you can log into Jenkins to see which tests you've failed
and fix them, if running make test
locally didn't already tell you.
You can run individual tests with venv/bin/pytest -k <test_name>
or
venv/bin/pytest <test_file>::<test_name>
if running all tests is too slow.
We use pre-commit to lint our code before commiting. While some of the rules might seem a little arbitrary, it helps keep the style consistent, and ensure annoying things like trailing whitespace don't creep in.
You can simply run make install-hooks
to install the necessary git hooks;
once installed, pre-commit will run every time you commit.
Alternatively, if you'd rather not install any hooks, you can simply use make test
as usual, which will also run the hooks.
Almost all build failures of ocfweb can be tied to something pre-commit
probably would have caught.
To install a package to the production environment, add it to
requirements-minimal.txt
, then run make update-requirements
. Similarly, to
install to the development environment, add to requirements-dev-minimal.txt
and run make update-requirements
. Use as loose a version requirement as
possible, e.g. try django
or django>=1.10,<1.10.999
before
django==1.10.0
.
[0]: If you have a staff VM, you can also use that to run ocfweb. You will have
to add the ocf_ocfweb::dev_config
class to your
Hiera node config.
Specifically, add:
classes:
- ocf_ocfweb::dev_config
It's probably easier to just run everything on supernova
.