The Ranger Incident Management System is used by the Black Rock Rangers to track incidents that occur in Black Rock City.
- Clone the repo
- Install Go and have
go
on your PATH. https://go.dev/dl - (Optional: if you want to run the integration tests) install Docker Desktop or Docker Engine. https://www.docker.com/
- (Optional: if you want to run the Playwright tests) install Playwright: https://playwright.dev/docs/intro
- Do a one-time fetch of external build dependencies into your repo, by running
go run bin/fetchbuilddeps/fetchbuilddeps.go
To run all the tests (excluding Playwright), just do:
go test ./...
or to run all those tests and see a coverage report, do:
go test -coverprofile=coverage.out --coverpkg ./... ./... && go tool cover -html=coverage.out
- Have a local MariaDB server running. An empty database is fine, as the IMS program will
migrate your DB automatically on startup. e.g.
password=$(openssl rand -hex 16) echo "Password is ${password}" docker run -it \ -e MARIADB_RANDOM_ROOT_PASSWORD=true \ -e MARIADB_DATABASE=ims \ -e MARIADB_USER=rangers \ -e MARIADB_PASSWORD=${password} \ -p 3306:3306 mariadb:10.5.27
- Copy
.env.example
as.env
, and set the various flags. Especially read the part in.env.example
aboutIMS_DIRECTORY
if you want to use TestUsers rather than a Clubhouse DB. - Run the following to build and launch the server. These should work on Windows as well as OSX
and Linux, but Windows is so far untested.
go run bin/build/build.go ./ranger-ims-go serve
docker build --tag ranger-ims-go .
docker run --env-file .env -it -p 80:8080 ranger-ims-go:latest
or use docker compose up
Upgrade the Go toolchain simply by increasing the Go value in go.mod
, e.g. #64. Even Go major version upgrades (e.g. 1.23 to 1.24) are very unlikely to break anything, thanks to the Go 1.0 backward compatibility guarantee. If all the tests pass, you're all good.
This line in go.mod should be left as the only line in the repo that specifies the Go version. For example, the Dockerfile depends on Go, but it inherits the value in go.mod.
Upgrade all Go dependencies by running:
# Upgrade all normal and test dependencies
go get -t -u ./...
# Tidy up go.mod and go.sum
go mod tidy
- We didn't bring over support for a SQLite IMS database, so MariaDB is the only option currently. It's kind of a pain supporting two different sets of SQLs statements and needing an abstraction layer in the middle. Also, sqlc doesn't support SQLite well yet, and this Go version of IMS makes heavy use of sqlc's glorious code generation. If we do end up wanting some lighter alternative to MariaDB for some reason, the easier thing would be to make a fake version of the Querier interface, i.e. creating an in-memory DB.
- We use a
.env
file rather thanconf/imsd.conf
for local configuration. This ends up just being a lot simpler, since prod only uses env variables anyway, and this means each config setting just has one name. - We kept the "File" Directory type in spirit, but changed it to "TestUsers" and made it a compiled
source file,
testusers.go
.