Correctly integrate Go unit tests with Jenkins

This commit is contained in:
Pablo Carranza Vélez 2015-07-23 18:14:50 -03:00
parent 30ce6f77c4
commit 300067febe
9 changed files with 25 additions and 24 deletions

View File

@ -32,8 +32,8 @@ RUN chmod +x /app/src/enterContainer.sh \
&& /app/node_modules/.bin/coffee -c /app/src \
&& ln -sf /app/entry.sh /start # Needed for legacy
RUN mv /app/gosuper/bin/linux_amd64/gosuper /app/gosuper/bin/
RUN chmod +x /app/gosuper/bin/gosuper
RUN mv /app/gosuper/bin/linux_amd64/gosuper /app/gosuper/bin/ && \
chmod +x /app/gosuper/bin/gosuper
ENV SUPERVISOR_IMAGE resin/amd64-supervisor
ENV CONFIG_MOUNT_POINT /boot/config.json

View File

@ -32,8 +32,8 @@ RUN chmod +x /app/src/enterContainer.sh \
&& /app/node_modules/.bin/coffee -c /app/src \
&& ln -sf /app/entry.sh /start # Needed for legacy
RUN mv /app/gosuper/bin/linux_arm/gosuper /app/gosuper/bin/
RUN chmod +x /app/gosuper/bin/gosuper
RUN mv /app/gosuper/bin/linux_arm/gosuper /app/gosuper/bin/ && \
chmod +x /app/gosuper/bin/gosuper
ENV SUPERVISOR_IMAGE resin/armv7hf-supervisor
ENV CONFIG_MOUNT_POINT /boot/config.json

View File

@ -1,12 +1,12 @@
FROM golang:1.4.2-cross
COPY . /usr/src/app/src/resin-supervisor
ENV GOOS linux
ENV GOPATH /usr/src/app
WORKDIR /usr/src/app
COPY . src/resin-supervisor
RUN chmod +x src/resin-supervisor/build_gosuper.sh
# Run go install with -a (force rebuilding of all packages)

View File

@ -32,8 +32,8 @@ RUN chmod +x /app/src/enterContainer.sh \
&& /app/node_modules/.bin/coffee -c /app/src \
&& ln -sf /app/entry.sh /start # Needed for legacy
RUN mv /app/gosuper/bin/linux_386/gosuper /app/gosuper/bin/
RUN chmod +x /app/gosuper/bin/gosuper
RUN mv /app/gosuper/bin/linux_386/gosuper /app/gosuper/bin/ && \
chmod +x /app/gosuper/bin/gosuper
ENV SUPERVISOR_IMAGE resin/i386-supervisor
ENV CONFIG_MOUNT_POINT /boot/config.json

View File

@ -32,7 +32,7 @@ RUN chmod +x /app/src/enterContainer.sh \
&& /app/node_modules/.bin/coffee -c /app/src \
&& ln -sf /app/entry.sh /start # Needed for legacy
RUN mv /app/gosuper/bin/linux_arm/gosuper /app/gosuper/bin/
RUN chmod +x /app/gosuper/bin/gosuper
RUN mv /app/gosuper/bin/linux_arm/gosuper /app/gosuper/bin/ && \
chmod +x /app/gosuper/bin/gosuper
CMD ["/app/entry.sh"]

View File

@ -55,6 +55,9 @@ go-builder:
gosuper: go-builder
-mkdir -p gosuper/bin
docker run -v $(shell pwd)/gosuper/bin:/usr/src/app/bin -e GOARCH=$(GOARCH) resin/go-supervisor-builder:$(SUPERVISOR_VERSION)
docker run -v $(shell pwd)/gosuper/bin:/usr/src/app/bin -e USER_ID=$(shell id -u) -e GROUP_ID=$(shell id -g) -e GOARCH=$(GOARCH) resin/go-supervisor-builder:$(SUPERVISOR_VERSION)
test-gosuper: go-builder
docker run -v $(shell pwd)/gosuper/bin:/usr/src/app/bin resin/go-supervisor-builder:$(SUPERVISOR_VERSION) bash -c "cd src/resin-supervisor && go test -v ./..."
.PHONY: supervisor deploy supervisor-dind run-supervisor

View File

@ -8,6 +8,9 @@ ESCAPED_BRANCH_NAME=$(echo $sourceBranch | sed 's/[^a-z0-9A-Z_.-]/-/g')
# Try pulling the old build first for caching purposes.
docker pull resin/${ARCH}-supervisor:${ESCAPED_BRANCH_NAME} || docker pull resin/${ARCH}-supervisor:master || true
# Test the gosuper
make SUPERVISOR_VERSION=${VERSION} test-gosuper
# Build the images
make SUPERVISOR_VERSION=${ESCAPED_BRANCH_NAME} ARCH=${ARCH} DEPLOY_REGISTRY= deploy
make SUPERVISOR_VERSION=${VERSION} ARCH=${ARCH} DEPLOY_REGISTRY= deploy

View File

@ -1,12 +1,13 @@
#!/bin/bash
set -e
go install -a -v ./...
RETURN_VALUE=$?
# For consistency, always keep the binary within a linux_$GOARCH folder
if (( $GOARCH == "amd64" )); then
if [ $GOARCH == "amd64" ]; then
mkdir $GOPATH/bin/linux_$GOARCH || true
cp $GOPATH/bin/gosuper $GOPATH/bin/linux_$GOARCH/
fi
chmod -R a+rwx $GOPATH/bin
chown -R $USER_ID:$GROUP_ID $GOPATH/bin
exit $RETURN_VALUE

View File

@ -2,7 +2,7 @@ package main
import (
"encoding/json"
"os"
"io/ioutil"
)
type UserConfig struct {
@ -20,19 +20,13 @@ func ReadConfig(path string) (UserConfig, error) {
var config UserConfig
f, err := os.Open(path)
if err != nil {
return config, err
}
data := make([]byte, 1000)
count, err := f.Read(data)
data, err := ioutil.ReadFile(path)
if err != nil {
return config, err
}
err = json.Unmarshal(data[:count], &config)
err = json.Unmarshal(data, &config)
return config, err
}