-
Notifications
You must be signed in to change notification settings - Fork 568
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor repository and build scripts
This commit includes updates that affects the build, testing, and deployment of Tile38. - The root level build.sh has been broken up into multiple scripts and placed in the "scripts" directory. - The vendor directory has been updated to follow the Go modules rules, thus `make` should work on isolated environments. Also some vendored packages may have been updated to a later version, if needed. - The Makefile has been updated to allow for making single binaries such as `make tile38-server`. There is some scaffolding during the build process, so from now on all binaries should be made using make. For example, to run a development version of the tile38-cli binary, do this: make tile38-cli && ./tile38-cli not this: go run cmd/tile38-cli/main.go - Travis.CI docker push script has been updated to address a change to Docker's JSON repo meta output, which in turn fixes a bug where new Tile38 versions were not being properly pushed to Docker
- Loading branch information
Showing
1,013 changed files
with
323,746 additions
and
192 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 |
---|---|---|
|
@@ -10,4 +10,4 @@ script: | |
- make test | ||
|
||
after_success: | ||
- ./build.sh travis-docker-push | ||
- scripts/travis-docker-push.sh |
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 |
---|---|---|
@@ -1,21 +1,46 @@ | ||
all: | ||
@./build.sh | ||
clean: | ||
rm -f tile38-server | ||
rm -f tile38-cli | ||
rm -f tile38-benchmark | ||
rm -f tile38-luamemtest | ||
all: tile38-server tile38-cli tile38-benchmark tile38-luamemtest | ||
|
||
.PHONY: tile38-server | ||
tile38-server: | ||
@./scripts/build.sh tile38-server | ||
|
||
.PHONY: tile38-cli | ||
tile38-cli: | ||
@./scripts/build.sh tile38-cli | ||
|
||
.PHONY: tile38-benchmark | ||
tile38-benchmark: | ||
@./scripts/build.sh tile38-benchmark | ||
|
||
.PHONY: tile38-luamemtest | ||
tile38-luamemtest: | ||
@./scripts/build.sh tile38-luamemtest | ||
|
||
test: | ||
@./build.sh test | ||
cover: | ||
@./build.sh cover | ||
@./scripts/test.sh | ||
|
||
package: | ||
@rm -rf packages/ | ||
@scripts/package.sh Windows windows amd64 | ||
@scripts/package.sh Mac darwin amd64 | ||
@scripts/package.sh Linux linux amd64 | ||
@scripts/package.sh FreeBSD freebsd amd64 | ||
@scripts/package.sh ARM linux arm | ||
@scripts/package.sh ARM64 linux arm64 | ||
|
||
clean: | ||
rm -rf tile38-server tile38-cli tile38-benchmark tile38-luamemtest | ||
|
||
distclean: clean | ||
rm -rf packages/ | ||
|
||
install: all | ||
cp tile38-server /usr/local/bin | ||
cp tile38-cli /usr/local/bin | ||
cp tile38-benchmark /usr/local/bin | ||
|
||
uninstall: | ||
rm -f /usr/local/bin/tile38-server | ||
rm -f /usr/local/bin/tile38-cli | ||
rm -f /usr/local/bin/tile38-benchmark | ||
package: | ||
@./build.sh package | ||
|
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
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,37 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
cd $(dirname "${BASH_SOURCE[0]}")/.. | ||
|
||
if [ "$1" == "" ]; then | ||
echo "error: missing argument (binary name)" | ||
exit 1 | ||
fi | ||
|
||
# Check the Go installation | ||
if [ "$(which go)" == "" ]; then | ||
echo "error: Go is not installed. Please download and follow installation"\ | ||
"instructions at https://golang.org/dl to continue." | ||
exit 1 | ||
fi | ||
|
||
# Hardcode some values to the core package. | ||
if [ -d ".git" ]; then | ||
VERSION=$(git describe --tags --abbrev=0) | ||
GITSHA=$(git rev-parse --short HEAD) | ||
LDFLAGS="$LDFLAGS -X github.com/tidwall/tile38/core.Version=${VERSION}" | ||
LDFLAGS="$LDFLAGS -X github.com/tidwall/tile38/core.GitSHA=${GITSHA}" | ||
fi | ||
LDFLAGS="$LDFLAGS -X github.com/tidwall/tile38/core.BuildTime=$(date +%FT%T%z)" | ||
|
||
# Generate the core package | ||
core/gen.sh | ||
|
||
# Set final Go environment options | ||
LDFLAGS="$LDFLAGS -extldflags '-static'" | ||
export CGO_ENABLED=0 | ||
export GO111MODULE=on | ||
export GOFLAGS=-mod=vendor | ||
|
||
# Build and store objects into original directory. | ||
go build -ldflags "$LDFLAGS" -o $1 cmd/$1/*.go |
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,46 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
cd $(dirname "${BASH_SOURCE[0]}")/.. | ||
|
||
PLATFORM="$1" | ||
GOOS="$2" | ||
GOARCH="$3" | ||
VERSION=$(git describe --tags --abbrev=0) | ||
|
||
echo Packaging $PLATFORM Binary | ||
|
||
# Remove previous build directory, if needed. | ||
bdir=tile38-$VERSION-$GOOS-$GOARCH | ||
rm -rf packages/$bdir && mkdir -p packages/$bdir | ||
|
||
# Make the binaries. | ||
GOOS=$GOOS GOARCH=$GOARCH make all | ||
rm -f tile38-luamemtest # not needed | ||
|
||
# Copy the executable binaries. | ||
if [ "$GOOS" == "windows" ]; then | ||
mv tile38-server packages/$bdir/tile38-server.exe | ||
mv tile38-cli packages/$bdir/tile38-cli.exe | ||
mv tile38-benchmark packages/$bdir/tile38-benchmark.exe | ||
else | ||
mv tile38-server packages/$bdir | ||
mv tile38-cli packages/$bdir | ||
mv tile38-benchmark packages/$bdir | ||
fi | ||
|
||
# Copy documention and license. | ||
cp README.md packages/$bdir | ||
cp CHANGELOG.md packages/$bdir | ||
cp LICENSE packages/$bdir | ||
|
||
# Compress the package. | ||
cd packages | ||
if [ "$GOOS" == "linux" ]; then | ||
tar -zcf $bdir.tar.gz $bdir | ||
else | ||
zip -r -q $bdir.zip $bdir | ||
fi | ||
|
||
# Remove build directory. | ||
rm -rf $bdir |
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,7 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
cd $(dirname "${BASH_SOURCE[0]}")/.. | ||
|
||
cd tests && go test && cd .. | ||
go test $(go list ./... | grep -v /vendor/ | grep -v /tests) |
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,35 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
cd $(dirname "${BASH_SOURCE[0]}")/.. | ||
|
||
# GIT_VERSION - always the last verison number, like 1.12.1. | ||
export GIT_VERSION=$(git describe --tags --abbrev=0) | ||
# GIT_COMMIT_SHORT - the short git commit number, like a718ef0. | ||
export GIT_COMMIT_SHORT=$(git rev-parse --short HEAD) | ||
# DOCKER_REPO - the base repository name to push the docker build to. | ||
export DOCKER_REPO=$DOCKER_USER/tile38 | ||
|
||
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then | ||
# never push from a pull request | ||
echo "Not pushing, on a PR or not running in Travis CI" | ||
elif [ "$TRAVIS_BRANCH" != "master" ]; then | ||
# only the master branch will work | ||
echo "Not pushing, not on master" | ||
else | ||
push(){ | ||
docker tag $DOCKER_REPO:$GIT_COMMIT_SHORT $DOCKER_REPO:$1 | ||
docker push $DOCKER_REPO:$1 | ||
echo "Pushed $DOCKER_REPO:$1" | ||
} | ||
# docker login | ||
echo $DOCKER_PASSWORD | docker login -u $DOCKER_LOGIN --password-stdin | ||
# build the docker image | ||
docker build -f Dockerfile -t $DOCKER_REPO:$GIT_COMMIT_SHORT . | ||
if [ "$(curl -s https://hub.docker.com/v2/repositories/$DOCKER_REPO/tags/$GIT_VERSION/ | grep "digest")" == "" ]; then | ||
# push the newest tag | ||
push "$GIT_VERSION" | ||
push "latest" | ||
fi | ||
push "edge" | ||
fi |
Oops, something went wrong.