#! /bin/bash

set -eu

# Tune the GC to use more memory to reduce the number of garbage collections
export GOGC=400
export GOPATH="$(pwd):$(pwd)/vendor"
export PATH="$PATH:$(pwd)/vendor/bin:$(pwd)/bin"

echo "Installing lint search engine..."
go install github.com/alecthomas/gometalinter/
gometalinter --config=linter.json ./... --install

echo "Looking for lint..."
gometalinter --config=linter.json ./... --enable-gc

echo "Double checking spelling..."
misspell -error src *.md

echo "Testing..."
gb test

# Check that all the packages can build.
# When `go build` is given multiple packages it won't output anything, and just
# checks that everything builds. This seems to do a better job of handling
# missing imports than `gb build` does.
echo "Double checking it builds..."
go build github.com/matrix-org/dendrite/cmd/...

echo "Done!"