Skip to content

Commit

Permalink
feat(testing): automate local testing workflow (#8304)
Browse files Browse the repository at this point in the history
* add root makefile

* add makefile in t

* small updates

* small fix

* get gopath

* Update Makefile
  • Loading branch information
joshua-goldstein authored Sep 16, 2022
1 parent 3ab3ebf commit 4fd7c96
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 14 deletions.
30 changes: 16 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ BUILD_DATE ?= $(shell git log -1 --format=%ci)
BUILD_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
BUILD_VERSION ?= $(shell git describe --always --tags)

MODIFIED = $(shell git diff-index --quiet HEAD || echo "-mod")
MODIFIED = $(shell git diff-index --quiet HEAD || echo "-mod")

SUBDIRS = dgraph
GOPATH ?= $(shell go env GOPATH)

###############

.PHONY: $(SUBDIRS) all oss version install install_oss oss_install uninstall test help image
.PHONY: dgraph all oss version install install_oss oss_install uninstall test help image image-local local-image
all: $(SUBDIRS)

$(SUBDIRS):
$(MAKE) -w -C $@ all
dgraph:
GOOS=linux GOARCH=amd64 $(MAKE) -w -C $@ all

oss:
$(MAKE) BUILD_TAGS=oss
GOOS=linux GOARCH=amd64 $(MAKE) BUILD_TAGS=oss

version:
@echo Dgraph ${BUILD_VERSION}
Expand All @@ -46,33 +46,34 @@ version:
install:
@(set -e;for i in $(SUBDIRS); do \
echo Installing $$i ...; \
$(MAKE) -C $$i install; \
GOOS=linux GOARCH=amd64 $(MAKE) -C $$i install; \

This comment has been minimized.

Copy link
@matthewmcneely

matthewmcneely Oct 7, 2022

Member

@joshua-goldstein I'm going thru the README checking that instructions there are correct. The README states you can make install to get a dgraph binary. Setting the GOOS and GOARCH here makes an unusable image if you're not running on Linux/amd64. Was there some reason the install target needed to be linux/amd64?

This comment has been minimized.

Copy link
@joshua-goldstein

joshua-goldstein Oct 7, 2022

Author Contributor

Given the previous lack of documentation around build architecture this was the easiest way to get those on a Mac to use Docker. But I agree this is definitely not clean and we should 1.) make it clear that currently only linux/amd64 is stable, 2.) Mac users currently need to use Docker with linux/amd64 binary. Happy to hear your thoughts.

done)

install_oss oss_install:
$(MAKE) BUILD_TAGS=oss install
GOOS=linux GOARCH=amd64 $(MAKE) BUILD_TAGS=oss install

uninstall:
@(set -e;for i in $(SUBDIRS); do \
echo Uninstalling $$i ...; \
$(MAKE) -C $$i uninstall; \
done)

test:
@echo Running ./test.sh
./test.sh
test: image-local
@cp dgraph/dgraph ${GOPATH}/bin
@rm dgraph/dgraph
@$(MAKE) -C t test

image:
@GOOS=linux $(MAKE) dgraph
@GOOS=linux GOARCH=amd64 $(MAKE) dgraph
@mkdir -p linux
@mv ./dgraph/dgraph ./linux/dgraph
@docker build -f contrib/Dockerfile -t dgraph/dgraph:$(subst /,-,${BUILD_BRANCH}) .
@rm -r linux

image-local:
image-local local-image:
@GOOS=linux GOARCH=amd64 $(MAKE) dgraph
@mkdir -p linux
@mv ./dgraph/dgraph ./linux/dgraph
@cp ./dgraph/dgraph ./linux/dgraph
@docker build -f contrib/Dockerfile -t dgraph/dgraph:local .
@rm -r linux

Expand All @@ -86,4 +87,5 @@ help:
@echo " make uninstall - Uninstall known targets"
@echo " make version - Show current build info"
@echo " make help - This help"
@echo " make test - Make local image and run t.go"
@echo
33 changes: 33 additions & 0 deletions t/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#
# Copyright 2018 Dgraph Labs, Inc. and Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# linux || darwin
GOOS ?= $(shell go env GOOS)
GOPATH ?= $(shell go env GOPATH)

.PHONY: test

all: test

test:
# build the t.go binary
@go build .
# clean go testcache
go clean -testcache
# run the tests
@./t --skip systest/backup,systest/online-restore,systest/loader,tlstest
# clean up docker containers after test execution
./t -r

0 comments on commit 4fd7c96

Please sign in to comment.