-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a way to run tests locally (#57)
- Loading branch information
1 parent
b35a788
commit 6336983
Showing
8 changed files
with
97 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,9 +21,6 @@ jobs: | |
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Test tools | ||
run: sudo apt-get install ca-certificates | ||
|
||
- name: Cache Go modules | ||
uses: actions/cache@v2 | ||
with: | ||
|
@@ -42,24 +39,19 @@ jobs: | |
- name: Install golangci-lint ${{ env.GOLANGCI_LINT_VERSION }} | ||
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VERSION} | ||
|
||
- name: Install golangci-lint | ||
run: golangci-lint run | ||
|
||
- name: Install stores | ||
run: | | ||
script/install_consul.sh 1.1.0 | ||
script/install_dynamodb_local.sh | ||
script/install_etcd.sh 3.3.8 | ||
script/install_zk.sh 3.4.14 | ||
script/install_redis.sh 4.0.10 | ||
- name: Install Compose | ||
uses: ndeloof/[email protected] | ||
with: | ||
legacy: true | ||
|
||
- name: Run stores | ||
run: | | ||
./consul agent -server -bootstrap -advertise=127.0.0.1 -data-dir /tmp/consul -config-file=./config.json 1>/dev/null & | ||
./etcd/etcd --listen-client-urls 'http://0.0.0.0:4001' --advertise-client-urls 'http://127.0.0.1:4001' >/dev/null 2>&1 & | ||
./zk/bin/zkServer.sh start ./zk/conf/zoo.cfg 1> /dev/null | ||
./redis/src/redis-server & | ||
java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -inMemory & | ||
- name: Install golangci-lint | ||
run: make validate | ||
|
||
- name: Run tests | ||
run: go test -v -race ./... | ||
run: make test | ||
env: | ||
TEST_ARGS: "--count=1" # disable go test cache | ||
|
||
- name: Display docker-compose logs | ||
if: failure() | ||
run: docker-compose -f script/docker-compose.yml logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
.PHONY: all | ||
all: validate test clean | ||
|
||
## Run validates | ||
.PHONY: validate | ||
validate: | ||
golangci-lint run | ||
|
||
PACKAGES=$(shell go list ./store/...) | ||
|
||
## Run tests | ||
.PHONY: test | ||
test: test-start-stack | ||
test: ${PACKAGES} | ||
|
||
## Run tests for ${PACKAGES} | ||
## Example: make github.com/kvtools/valkeyrie/store/redis | ||
.PHONY: ${PACKAGES} | ||
${PACKAGES}: | ||
go test -v -race ${TEST_ARGS} $@ | ||
|
||
## Launch docker stack for test | ||
.PHONY: test-start-stack | ||
test-start-stack: | ||
docker-compose -f script/docker-compose.yml up --wait | ||
|
||
## Clean local data | ||
.PHONY: clean | ||
clean: | ||
docker-compose -f script/docker-compose.yml down | ||
$(RM) goverage.report $(shell find . -type f -name *.out) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
version: "3.9" | ||
|
||
# when running test local, you can specify the image version using the | ||
# <service>_VERSION. | ||
# Example, to run consul with the version 1.8: | ||
# CONSUL_VERSION=1.8 make | ||
|
||
services: | ||
consul: | ||
image: consul:${CONSUL_VERSION:-1.1.0} | ||
container_name: consul | ||
command: agent -server -bootstrap -client 0.0.0.0 | ||
environment: | ||
CONSUL_LOCAL_CONFIG: '{"session_ttl_min": "1s"}' | ||
healthcheck: | ||
test: consul info | awk '/health_score/{if ($$3 >=1) exit 1; else exit 0}' | ||
ports: | ||
- 8500:8500 | ||
|
||
etcd: | ||
image: quay.io/coreos/etcd:${ETCD_VERSION:-v3.3.8} | ||
container_name: etcd | ||
command: etcd --listen-client-urls 'http://0.0.0.0:4001' --advertise-client-urls 'http://127.0.0.1:4001' | ||
healthcheck: | ||
test: etcdctl --endpoints http://127.0.0.1:4001 cluster-health | ||
ports: | ||
- 4001:4001 | ||
volumes: | ||
- /usr/share/ca-certificates/:/etc/ssl/certs | ||
|
||
zookeeper: | ||
image: zookeeper:${ZK_VERSION:-3.4.14} | ||
container_name: zookeeper | ||
healthcheck: | ||
test: nc -z localhost 2181 || exit 1 | ||
ports: | ||
- 2181:2181 | ||
|
||
redis: | ||
image: redis:${REDIS_VERSION:-4.0.10} | ||
container_name: redis | ||
healthcheck: | ||
test: redis-cli ping | ||
ports: | ||
- 6379:6379 | ||
|
||
dynamodb: | ||
image: amazon/dynamodb-local:${DYNAMODB_VERSION:-1.18.0} | ||
container_name: dynamodb | ||
healthcheck: | ||
test: curl localhost:8000 | ||
ports: | ||
- 8000:8000 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.