Skip to content
ocfPublic

Latest commit

 

History

2,624 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ocfweb

Build Status Code Health Checked with mypy

The main ocf website.

Working on ocfweb on the ocfstaff remote dev server

  1. Open a terminal on your local host and run ssh koi.ocf.io.
  2. Then, run git clone git@github.com:ocf/ocfweb.git, cd ocfweb, then devenv up.
    • The first run takes about a minute while Nix and uv download dependencies. Later runs start in seconds.
    • You will see a process-compose tui appear, with a process called "web" and the logs visible. Your user's port is what is generated in the log line Running on https://koi.ocf.berkeley.edu:YOUROWNPORT, based on your uid. This is to avoid conflicts with other users who might also be running dev servers on koi.
  3. Open an SSH tunnel on your local host (not on koi or other OCF servers): ssh -L YOUROWNPORT:localhost:YOUROWNPORT koi
    • to avoid this extra step in the future, add the following to your ~/.ssh/config:
    Host koi
        HostName koi.ocf.berkeley.edu
        LocalForward YOUROWNPORT localhost:YOUROWNPORT
    
  4. Go to https://localhost:YOUROWNPORT in your local browser!

Dependencies and Python version

pyproject.toml lists ocfweb's dependencies, and uv.lock pins their exact versions. Manage both with uv.

  • Add a package: uv add <package>. Use --dev for development-only tools.
  • Upgrade one package, such as ocflib: uv lock --upgrade-package ocflib.
  • Upgrade everything: make update-deps.

Commit pyproject.toml and uv.lock together, or the Docker build fails.

ocfweb runs on Python 3.14. To change that, update .python-version, requires-python in pyproject.toml, and devenv.nix.

Working on ocfweb on your own machine

We recommend working on koi instead. To run ocfweb locally anyway, install uv, then run:

git submodule update --init
DJANGO_DEBUG=1 make local-dev

Your machine doesn't have /etc/ocf and can't reach OCF's LDAP and MySQL servers, so the home page and stats pages hang or error, and many tests fail. You can still work on docs pages, templates, and SCSS.

BELOW THIS IS OUTDATED. WIP


We recommend following all of these steps on koi, 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.

Running in development mode

On supernova[0]run make dev. The first run installs dependencies with uv; later runs reuse them.

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.

Building SCSS

Run make scss to build SCSS. You can also use make watch-scss to rebuild it automatically when SCSS files change.

Running tests

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 uv run pytest -k <test_name> or uv run pytest <test_file>::<test_name> if running all tests is too slow.

Running pre-commit

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.


[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.

Releases

Packages

Used by

Contributors

Languages