Skip to content

Commit

Permalink
Linting Makefile, dockerfile/comose, markdown and shell (#8)
Browse files Browse the repository at this point in the history
* Markdown lint

Signed-off-by: Damien DUPORTAL <[email protected]>

* Lint Makefile + fix variables usage + simplify docker-compose section

Signed-off-by: Damien DUPORTAL <[email protected]>

* Do not use /Users/dadou/workspace/go-sind and shellcheck

Signed-off-by: Damien DUPORTAL <[email protected]>

* Speed up tool box build

Signed-off-by: Damien DUPORTAL <[email protected]>

* fix: create toolbox script, mount correct path for integration tests
  • Loading branch information
dduportal authored and jlevesy committed Mar 13, 2019
1 parent baade8d commit 0c9721f
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 35 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.gocache
dist
.git
39 changes: 25 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
DIST_DIR=dist
DIST_DIR ?= dist

all: build
COMPOSE_FILE ?= $(CURDIR)/integration/docker-compose.yaml
export COMPOSE_FILE

.PHONY: all
all: clean build test

#
# Release targets
Expand All @@ -18,21 +22,19 @@ dry_release: clean
# Test targets
#

.PHONY: test
test: unit_test integration_test

.phony: integration_test
integration_test:
docker-compose \
-f ./integration/docker-compose.yaml \
build \
--build-arg UID=$(shell id -u) \
--build-arg GID=$(shell id -g)
docker-compose \
-f ./integration/docker-compose.yaml \
up --exit-code-from client client
docker-compose \
-f ./integration/docker-compose.yaml \
down -v
down -v --remove-orphans

.PHONY: unit_test
unit_test:
Expand All @@ -41,7 +43,7 @@ unit_test:
-cover \
-timeout=5s \
-run=$(T) \
$(shell go list ./... | grep -v integration)
$(shell go list $(CURDIR)/... | grep -v integration)

.PHONY: lint
lint:
Expand All @@ -55,20 +57,23 @@ lint:
vendor:
go mod download

.PHONY: install
install:
mv ${DIST_DIR}/sind $${GOPATH}/bin/sind
mv $(DIST_DIR)/sind $(GOPATH)/bin/sind

.PHONY: build
build: clean dist binary

.PHONY: binary
binary:
CGO_ENABLED=0 go build -ldflags="-s -w" -o ${DIST_DIR}/sind ./cmd/sind
CGO_ENABLED=0 go build -ldflags="-s -w" -o $(DIST_DIR)/sind $(CURDIR)/cmd/sind

dist:
mkdir -p ${DIST_DIR}
mkdir -p $(DIST_DIR)

.PHONY: clean
clean:
rm -rf ${DIST_DIR}
rm -rf $(DIST_DIR)

#
# Toolbox setup
Expand All @@ -83,7 +88,13 @@ toolbox: cachedirs
-f Dockerfile.toolbox .

.PHONY: cachedirs
cachedirs:
@mkdir -p .gocache/mod
@mkdir -p .gocache/build
cachedirs: .gocache/mod .gocache/build

.PHONY: clean-cachedirs
rm -rf $(CURDIR)/.gocache

.gocache/mod:
@mkdir -p $(CURDIR)/.gocache/mod

.gocache/build:
@mkdir -p $(CURDIR)/.gocache/build
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ Head to the [base example](./example/base/main.go) or to the [integration test

### Installation

* Download the latest release for your platform from https://github.com/jlevesy/go-sind/releases
* Untar the downloaded archive and move the binary somewhere on your PATH
- Download the latest release for your platform from <https://github.com/jlevesy/go-sind/releases>
- Untar the downloaded archive and move the binary somewhere on your PATH

```
$ curl -sSL -o sind.tar.gz "https://github.com/jlevesy/go-sind/releases/download/v0.1.1/sind_0.1.1_$(uname -s)_$(uname -m).tar.gz"
```shell
curl -sSL -o sind.tar.gz "https://github.com/jlevesy/go-sind/releases/download/v0.1.1/sind_0.1.1_$(uname -s)_$(uname -m).tar.gz"

$ tar xzf ./sind.tar.gz
$ chmod a+x ./sind
$ mv ./sind /usr/local/bin/
tar xzf ./sind.tar.gz
chmod a+x ./sind
mv ./sind /usr/local/bin/
```

### Usage

```
```shell
# Will create a new cluster with 3 managers, 3 workers and the port 8080 of the host bound
# to the port 8080 of the ingress network of the cluster.
sind create --managers=3 --workers=3 -p 8080:8080
Expand All @@ -47,6 +47,6 @@ unset DOCKER_HOST
sind delete
```

## Why ?
## Why

Mostly for automated testing.
6 changes: 3 additions & 3 deletions integration/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ services:
context: ../
dockerfile: ./Dockerfile.toolbox
volumes:
- ${PWD}:/go/src/github.com/jlevesy/go-sind
- ${PWD}/.gocache/mod:/go/pkg/mod
- ${PWD}/.gocache/build:/go/.cache/go-build
- ../:/go/src/github.com/jlevesy/go-sind
- ../.gocache/mod:/go/pkg/mod
- ../.gocache/build:/go/.cache/go-build
environment:
DOCKER_HOST: tcp://dind:2375
depends_on:
Expand Down
9 changes: 0 additions & 9 deletions tool/box

This file was deleted.

12 changes: 12 additions & 0 deletions toolbox
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

CURRENT_DIR="$(cd "$(dirname "${0}")" && pwd -P)"

docker run \
-ti \
--rm \
-v "${CURRENT_DIR}:/go/src/github.com/jlevesy/go-sind" \
-v "${CURRENT_DIR}/.gocache/mod:/go/pkg/mod" \
-v "${CURRENT_DIR}/.gocache/build:/go/.cache/go-build" \
go-sind-toolbox \
"${*:-bash}"

0 comments on commit 0c9721f

Please sign in to comment.