Setup Guide
Prerequisites
Clone the repo (obviously) from https://github.com/csesoc/chaos. To be able to contribute properly without making your own fork, you’ll need to be added to the Chaos GitHub team. This should be done for you in the coming weeks. You’ll need 2FA enabled on your GitHub account as it’s a requirement for the CSESoc organisation.
I assume you all already know to do this, but clone the repo with SSH not HTTPS, and use an SSH key.
If you’re on MacOS, I recommend you use homebrew to install tools needed. If you’re on Windows, I recommend using WSL.
The Vault
CSESoc uses Bitwarden (using a self-hosted Vaultwarden instance), a secure password manager, which can also act as a secrets sharer. We use it to store our backend environment files that you’ll need to run Chaos locally. You do not already have an account by default on this.
Sign up for an account at https://vault.csesoc.org.au using your CSESoc email
Ask @Jared Lohtaja (Unlicensed) (you can find him in the dev discord) for access to the vault, sending him the email address you signed up with
You should receive an invite via email with a link to accept it, and once you do, Jared will have to confirm again on his end
Once you’re confirmed you should see CSESoc Development and all its items in your home/vaults page, one of them being
CHAOS backend .env file
. This is what you need
Backend
This is the most involved part of the setup process. A lot of this is from the README in the backend folder in the repo.
Install the Rust toolchain using Rustup
Install PostgreSQL (e.g.,
sudo apt install postgresql-all
,brew install postgresql
,sudo pacman -S postgresql
, etc)Download the backend .env file from the vault as shown in the previous section into the root of the backend folder in the repo
Setup postgres
Guide for Arch Linux: https://wiki.archlinux.org/title/PostgreSQL#Initial_configuration, ignore section 4 onwards (should be similar on other Linux distributions/WSL)
Guide for MacOS: https://www.sqlshack.com/setting-up-a-postgresql-database-on-mac/
Windows: just use WSL please
Create a user named
postgres
with the password equal to the one in the.env
fileYou can get it from the
DATABASE_URL
field (formatpostgres://postgres:<password>@localhost/chaos
)
People have often had trouble setting up postgres properly in the past, if you’re having trouble you can ask on Discord/in VC and hopefully one of us can help you
Install diesel-cli with
cargo install diesel_cli --no-default-features --features postgres
Run
diesel setup && diesel migration run
If you get a server connection error, check out this stackoverflow thread
this might delete code in the backend, make sure to restore any deletions (this has never happened for me, but it’s in the readme 🤷)
Run the server with
cargo run --bin server
The first startup will likely take a while as it compiles everything
If you want to run the server and get it to restart upon changes, you can install
cargo watch
withcargo install cargo-watch
Then, run
cargo watch -x 'run --bin server'
insteadIt will watch files and continually re-compile upon changes
Scripts
Scripts should be run from the chaos/backend
directory:
scripts/seed.sh
- will wipe your database and add some dummy dataIf you are getting a
bad variable nameread answer
error, ensure the file has LF-style newlinesYou should run this script first after setting up the database, assuming you want some data to start off with
Again, this will wipe your database so do NOT run it if you have data in there that you want to keep, but this should only be used in local development environments, so there likely isn’t
scripts/become_super_user
- will prompt for the email address to turn into a GLOBAL super userRun this script after running the above script and creating an account
This will give you admin perms in every organisation, useful for testing, and also you need to be a superuser to create an organisation
Frontend
This setup is a lot more straightforward than the backend
(Optionally) install nvm, and run
nvm use
inside the frontend folder to ensure a consistent Node versionOr just install Node, most reasonably modern versions should work fine, but if you want to guarantee consistency use nvm
Install yarn. We use 1.x currently
If you’re on Arch, you can
sudo pacman -S yarn
Run
yarn
to install dependenciesRun
yarn
again whenever you pull changes that update dependencies (if you seepackage.json
oryarn.lock
changed when yougit pull
, or checkout a branch with changes in those files)
Run
yarn start
to start the dev serverIf shit hits the fan with dependency changes and you’re getting weird errors that probably shouldn’t be happening (and running
yarn
again doesn’t fix it), you can tryrm -rf node_modules
and reinstalling the dependencies withyarn
lmao
Staging
You can access the staging deployment here: https://chaos.csesoc.app/
Whenever a commit is pushed to the main branch (including PRs getting merged), the backend and frontend automatically get built and deployed to the staging environment
To become a superuser here, an existing superuser needs to do it for you
Create an account and then send the email you used to @Michael Vo (Unlicensed) to make you a superuser