Files
Joshua GoldsteinandGitHub 0d745b5238 fix(CI): fix test suite and add CI steps (#1808)
## Problem

Badger tests are run through a bash script called test.sh. It is
currently not working, and there are no CI workflows on the Badger
repository.

## Solution

We update test.sh and add CI workflow steps. Test suite now works for
Linux and Mac (x86, M1). To run the test suite, simply run `make test`.
If you are on Mac, see remark below.

### Why a Makefile?

Badger depends on jemalloc for efficient memory allocation (see
[here](https://dgraph.io/blog/post/manual-memory-management-golang-jemalloc/),
and z package in Ristretto). While Badger can be built without jemalloc,
many users will probably want to benefit from it. The makefile makes it
easy to install the jemalloc dependency with `make jemalloc`. Also now
the test.sh script contains only test related functionality.

This also has the advantage that now the CI workflow only needs
essentially two steps:

```
make dependency
make test
```

### Remarks
- In pb/gen.sh, `go get` is
[deprecated](https://go.dev/doc/go-get-install-deprecation) as a way to
retrieve and install an executable into our $GOBIN, which is what we
want to do here. We use `go install` instead.
- In test.sh, Teamcity flags no longer needed
- In test.sh, Installjemalloc no longer needed as it is in the Makefile,
simplifying the test script
- In test.sh, tests are now run sequentially and not in parallel
(currently broken)
- We remove .travisci because it is unused
- Important note for Mac users: for historical reasons, certain tools on
MacOS are different from the standard GNU tools everyone else uses. One
of these is the `mktemp` command, which is used in the test suite. In
order to get the GNU version of this tool, you can run:
```
brew install coreutils
export PATH="$(brew --prefix)/opt/coreutils/libexec/gnubin:$PATH"
make test
```

This will temporarily modify your path so that the GNU version of mktemp
is called in the script. Without this fix the script will complain that
it doesn't recognize the p flag in `mktemp -d -p .`

#### To-do
- tune lint tests
- add code coverage
- potentially add build target for badger in makefile
- bring test suite to parity with [old teamcity
setup](https://teamcity.dgraph.io/project.html?projectId=Badger)
- prune dependencies
2022-10-13 18:51:37 +00:00

8 lines
259 B
Bash
Executable File

#!/bin/bash
# Run this script from its directory, so that badgerpb2.proto is where it's expected to
# be.
go install github.com/gogo/protobuf/protoc-gen-gogofaster@latest
protoc --gogofaster_out=. --gogofaster_opt=paths=source_relative -I=. badgerpb3.proto