Skip to content

Commit

Permalink
Fix run-test script
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Kassar committed Aug 29, 2018
1 parent 292f39b commit c336dfe
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 17 deletions.
21 changes: 9 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,12 @@ env:
- DOCKER_VERSION=17.12
- DOCKER_VERSION=18.03
- DOCKER_VERSION=18.06
jobs:
include:
- script: make
- stage: Run Test
script: make run-test
- stage: Build release
deploy:
provider: script
script: make release
skip_cleanup: true
on:
tags: true
script:
- make
- make run-test
deploy:
provider: script
script: make release
skip_cleanup: true
on:
tags: true
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# HBM (Harbormaster)

[![Build Status](https://travis-ci.org/kassisol/hbm.svg?branch=master)](https://travis-ci.org/kassisol/hbm)
[![Go Report Card](https://goreportcard.com/badge/github.com/kassisol/hbm)](https://goreportcard.com/report/github.com/kassisol/hbm)

Harbormaster is a basic extendable Docker Engine [access authorization plugin](https://docs.docker.com/engine/extend/plugins_authorization/) that runs on directly on the host.
Expand Down
10 changes: 10 additions & 0 deletions scripts/release
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ if [ $VERSION_OK -eq 0 ]; then
exit 100
fi

if [ ! -z "${TRAVIS}" ]; then
mkdir -p ${HOME}/.docker
echo -e "{\n\t\"auths\": {\n\t\t\"https://index.docker.io/v1/\": {\n\t\t\t\"auth\": \"${DOCKER_AUTH_TOKEN}\"\n\t\t}\n\t}\n}" > ${HOME}/.docker/config.json

if [ $TRAVIS_PULL_REQUEST == "true" ]; then
echo "No release on PR"
exit
fi
fi

./.github-release release --user ${GITHUB_USER} --repo ${REPO_NAME} --tag ${VERSION} --pre-release --draft

upload_file "bin"
Expand Down
20 changes: 15 additions & 5 deletions scripts/run-test
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ function cert-create() {
chmod 444 cert.pem
}

function image-exists() {
if [ $(docker image ls --format "{{.Repository}}\t{{.Tag}}\t{{.ID}}" -f "reference=${1}" | wc -l) -eq 0 ]; then
echo "Image '${1}' does not exist"
exit 1
fi
}

function container-running() {
sleep 5
if [ $(docker container ls --format "{{.ID}}\t{{.Image}}\t{{.Names}}" -f "name=${1}" | wc -l) -eq 0 ]; then
Expand Down Expand Up @@ -66,6 +73,9 @@ CERTS_PATH="${TEST_PATH}/certs"
mkdir -p ${DOCKER_PATH}/{conf,run}
mkdir -p ${CERTS_PATH}

docker image ls
image-exists ${HBM_IMAGE_NAME}

## Create certificates
ca-create

Expand All @@ -76,8 +86,8 @@ cert-create "client" "user1"

## Start HBM
docker container run -d --rm \
-v ${DOCKER_PATH}/conf:/etc/docker/plugins \
-v ${DOCKER_PATH}/run:/var/run/docker \
--mount type=bind,src=${DOCKER_PATH}/conf,dst=/etc/docker/plugins \
--mount type=bind,src=${DOCKER_PATH}/run,dst=/var/run/docker \
--name hbm-test \
${HBM_IMAGE_NAME}:${VERSION}

Expand All @@ -86,9 +96,9 @@ container-running "hbm-test"
## Start Docker DIND
docker container run -d --rm \
--privileged \
-v ${CERTS_PATH}/localhost:/etc/docker/tls \
-v ${DOCKER_PATH}/conf:/etc/docker/plugins \
-v ${DOCKER_PATH}/run:/var/run/docker \
--mount type=bind,src=${CERTS_PATH}/localhost,dst=/etc/docker/tls \
--mount type=bind,src=${DOCKER_PATH}/conf,dst=/etc/docker/plugins \
--mount type=bind,src=${DOCKER_PATH}/run:,dst=var/run/docker \
-p 127.0.0.1:2376:2376 \
--name docker-test \
${DOCKER_IMAGE_NAME} \
Expand Down
25 changes: 25 additions & 0 deletions scripts/validate
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -e

cd $(dirname $0)/..

echo "Running validation"

PACKAGES=". $(find -name '*.go' | xargs -I{} dirname {} | cut -f2 -d/ | sort -u | grep -Ev '(^\.$|.git|vendor|bin)' | sed -e 's!^!./!' -e 's!$!/...!')"

echo "Running: go vet"
go vet ${PACKAGES}

echo -e "\nRunning: golint"
for i in ${PACKAGES}; do
if [ -n "$(golint $i | grep -v 'should have comment.*or be unexported' | tee /dev/stderr)" ]; then
failed=true
fi
done
test -z "$failed"

echo -e "\nRunning: go fmt"
test -z "$(go fmt ${PACKAGES} | tee /dev/stderr)"

echo -e "\nRunning: megacheck"
test -z "$(go fmt ${PACKAGES} | tee /dev/stderr)"

0 comments on commit c336dfe

Please sign in to comment.