Commit 00745783 authored by Darren Shepherd's avatar Darren Shepherd
Browse files

Update build scripts

parent 0f53a3d4
Showing with 302 additions and 240 deletions
+302 -240
---
pipeline:
build:
privileged: true
image: rancher/dapper:1.11.2
volumes:
- /var/run/docker.sock:/var/run/docker.sock
commands:
- dapper ci
stage-binaries:
image: rancher/dapper:1.11.2
commands:
- cp -f ./bin/rio-incluster ./package/rio
when:
branch: master
event: tag
publish-image:
image: plugins/docker
dockerfile: package/Dockerfile
repo: rancher/rio
context: package/
tag: ${DRONE_TAG}
secrets: [docker_username, docker_password]
when:
branch: master
event: tag
github_binary_prerelease:
image: plugins/github-release
kind: pipeline
name: amd64
platform:
os: linux
arch: amd64
steps:
- name: build
image: rancher/dapper:v0.4.1
commands:
- dapper ci
volumes:
- name: docker
path: /var/run/docker.sock
- name: github_binary_release
image: plugins/github-release
settings:
api_key:
from_secret: github_token
prerelease: true
checksum:
- sha256
checksum_file: CHECKSUMsum-amd64.txt
checksum_flatten: true
files:
- dist/artifacts/*
- "dist/artifacts/*"
when:
instance:
- drone-publish.rancher.io
ref:
- refs/head/master
- refs/tags/*
event:
- tag
- name: docker-publish
image: plugins/docker
settings:
dockerfile: package/Dockerfile
password:
from_secret: docker_password
repo: "rancher/rio-controller"
tag: "${DRONE_TAG}-amd64"
username:
from_secret: docker_username
when:
instance:
- drone-publish.rancher.io
ref:
- refs/head/master
- refs/tags/*
event:
- tag
volumes:
- name: docker
host:
path: /var/run/docker.sock
---
kind: pipeline
name: arm64
platform:
os: linux
arch: arm64
steps:
- name: build
image: rancher/dapper:v0.4.1
commands:
- dapper ci
volumes:
- name: docker
path: /var/run/docker.sock
- name: github_binary_release
image: plugins/github-release
settings:
api_key:
from_secret: github_token
prerelease: true
checksum:
- sha256
secrets: [github_token]
when:
branch: master
event: tag
ref:
include: [ refs/tags/*rc* ]
github_binary_release:
image: plugins/github-release
- sha256
checksum_file: CHECKSUMsum-arm64.txt
checksum_flatten: true
files:
- dist/artifacts/*
- "dist/artifacts/*"
when:
instance:
- drone-publish.rancher.io
ref:
- refs/head/master
- refs/tags/*
event:
- tag
- name: docker-publish
image: plugins/docker
settings:
dockerfile: package/Dockerfile
password:
from_secret: docker_password
repo: "rancher/rio-controller"
tag: "${DRONE_TAG}-arm64"
username:
from_secret: docker_username
when:
instance:
- drone-publish.rancher.io
ref:
- refs/head/master
- refs/tags/*
event:
- tag
volumes:
- name: docker
host:
path: /var/run/docker.sock
---
kind: pipeline
name: arm
platform:
os: linux
arch: arm
steps:
- name: build
image: rancher/dapper:v0.4.1
commands:
- dapper ci
volumes:
- name: docker
path: /var/run/docker.sock
- name: github_binary_release
image: plugins/github-release
settings:
api_key:
from_secret: github_token
prerelease: true
checksum:
- sha256
secrets: [github_token]
when:
branch: master
event: tag
ref:
exclude: [ refs/tags/*rc* ]
- sha256
checksum_file: CHECKSUMsum-arm.txt
checksum_flatten: true
files:
- "dist/artifacts/*"
when:
instance:
- drone-publish.rancher.io
ref:
- refs/head/master
- refs/tags/*
event:
- tag
- name: docker-publish
image: plugins/docker
settings:
dockerfile: package/Dockerfile
password:
from_secret: docker_password
repo: "rancher/rio-controller"
tag: "${DRONE_TAG}-arm"
username:
from_secret: docker_username
when:
instance:
- drone-publish.rancher.io
ref:
- refs/head/master
- refs/tags/*
event:
- tag
volumes:
- name: docker
host:
path: /var/run/docker.sock
---
kind: pipeline
name: manifest
platform:
os: linux
arch: amd64
steps:
- name: manifest
image: plugins/manifest:1.0.2
settings:
username:
from_secret: docker_username
password:
from_secret: docker_password
platforms:
- linux/amd64
- linux/arm64
- linux/arm
target: "rancher/rio-controller:${DRONE_TAG}"
template: "rancher/rio-controller:${DRONE_TAG}-ARCH"
when:
instance:
- drone-publish.rancher.io
ref:
- refs/head/master
- refs/tags/*
event:
- tag
depends_on:
- amd64
- arm64
- arm
{
"linters": {
"disable-all": true,
"enable": [
"govet",
"golint",
"goimports",
"misspell",
"ineffassign",
"gofmt"
]
},
"run": {
"skip-files": [
"/zz_generated_"
],
"deadline": "5m"
},
"issues": {
"exclude-rules": [
{
"path":"cli/cmd",
"text":"don't use underscores in Go names",
"linters":["golint"]
}
]
}
}
FROM golang:1.12-alpine3.9
FROM golang:1.12.1-alpine3.9
RUN apk -U --no-cache add bash git gcc musl-dev docker vim less file curl wget ca-certificates jq linux-headers zlib-dev tar zip squashfs-tools npm coreutils \
python3 py3-pip python3-dev openssl-dev libffi-dev
RUN pip3 install 'tox==3.6.0'
RUN apk -U --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/main/ add sqlite-dev sqlite-static
ARG DAPPER_HOST_ARCH
ENV ARCH $DAPPER_HOST_ARCH
RUN apk -U add bash git gcc musl-dev docker vim less file curl wget ca-certificates
RUN go get -d golang.org/x/lint/golint && \
git -C /go/src/golang.org/x/lint/golint checkout -b current 06c8688daad7faa9da5a0c2f163a3d14aac986ca && \
go install golang.org/x/lint/golint && \
rm -rf /go/src /go/pkg
RUN go get -d github.com/alecthomas/gometalinter && \
git -C /go/src/github.com/alecthomas/gometalinter checkout -b current v2.0.11 && \
go install github.com/alecthomas/gometalinter && \
gometalinter --install && \
rm -rf /go/src /go/pkg
RUN mkdir -p /go/src/golang.org/x && \
cd /go/src/golang.org/x && git clone https://github.com/golang/tools && \
git -C /go/src/golang.org/x/tools checkout -b current aa82965741a9fecd12b026fbb3d3c6ed3231b8f8 && \
go install golang.org/x/tools/cmd/goimports
RUN rm -rf /go/src /go/pkg
RUN if [ "${ARCH}" == "amd64" ]; then \
curl -sL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.15.0; \
fi
ENV DAPPER_RUN_ARGS --privileged
ENV DAPPER_ENV REPO TAG DRONE_TAG
ENV DAPPER_SOURCE /go/src/github.com/rancher/rio/
ENV DAPPER_OUTPUT ./bin ./dist
ENV DAPPER_DOCKER_SOCKET true
ENV HOME ${DAPPER_SOURCE}
ENV CROSS true
WORKDIR ${DAPPER_SOURCE}
ENTRYPOINT ["./scripts/entry"]
CMD ["ci"]
FROM alpine
RUN apk -U --no-cache add ca-certificates git
ENV RIO_IN_CLUSTER=true
COPY rio-controller /usr/bin
FROM alpine:3.9
COPY bin/rio-controller /usr/bin/
CMD ["rio-controller"]
......@@ -5,27 +5,7 @@ source $(dirname $0)/version
cd $(dirname $0)/..
LDFLAGS="-X github.com/rancher/rio/version.Version=$VERSION -w -s"
STATIC="-extldflags -static"
STATIC_SQLITE="-extldflags '-static -lm -ldl -lz -lpthread'"
cross()
{
echo Building windows CLI
GOOS=windows GOARCH=amd64 go build -ldflags "$LDFLAGS" -o bin/rio-windows ./cli/main.go
echo Building mac CLI
GOOS=darwin GOARCH=amd64 go build -ldflags "$LDFLAGS" -o bin/rio-darwin ./cli/main.go
}
mkdir -p bin
if [ -n "$CROSS" ]; then
cross
fi
echo Building incluster
GOOS=linux GOARCH=amd64
CGO_ENABLED=0 go build -ldflags "$LDFLAGS $STATIC" -o bin/rio-controller
echo Building cli
CGO_ENABLED=1 go build -ldflags "$LDFLAGS $STATIC_SQLITE" -o bin/rio ./cli/main.go
[ "$(uname)" != "Darwin" ] && LINKFLAGS="-extldflags -static -s"
CGO_ENABLED=0 go build -ldflags "-X github.com/rancher/rio/pkg/version.VERSION=$VERSION $LINKFLAGS" -o bin/rio ./cli
CGO_ENABLED=0 go build -ldflags "-X github.com/rancher/rio/pkg/version.VERSION=$VERSION $LINKFLAGS" -o bin/rio-controller
......@@ -3,7 +3,7 @@ set -e
cd $(dirname $0)
./validate
./build
./test
./validate
./package
#./test
#!/bin/bash
set -e
cd $(dirname $0)/../bin
# Prime sudo
sudo echo Compiling CLI
go build -tags "k8s no_etcd" -o rio-agent ../cli/main.go
echo Building image and agent
../image/build
echo Running
exec sudo ENTER_ROOT=../image/main.squashfs ./rio-agent --debug agent -s https://localhost:7443 -t $(<${HOME}/.rancher/rio/server/node-token)
#!/bin/bash
set -e
cd $(dirname $0)/../bin
echo Running
go run -tags "k8s no_etcd" ../cli/main.go --debug server --disable-controllers --disable-agent
#!/bin/bash
set -e
cd $(dirname $0)/../bin
rio login -s https://localhost:5443 -t $(<${HOME}/.rancher/rio/server/client-token)
#!/bin/bash
set -e
cd $(dirname $0)/../bin
echo Running
go run -tags k3s ../cli/main.go --debug server --disable-agent
#!/bin/bash
set -e
cd $(dirname $0)
source $(dirname $0)/version
./package-image
./package-cli
./package-tar
ARCH=${ARCH:-"amd64"}
SUFFIX="-${ARCH}"
cd $(dirname $0)/..
TAG=${TAG:-${VERSION}${SUFFIX}}
REPO=${REPO:-rancher}
if echo $TAG | grep -q dirty; then
TAG=dev
fi
mkdir -p dist/artifacts
cp bin/rio dist/artifacts/rio${SUFFIX}
IMAGE=${REPO}/rio:${TAG}
DOCKERFILE=package/Dockerfile
if [ -e ${DOCKERFILE}.${ARCH} ]; then
DOCKERFILE=${DOCKERFILE}.${ARCH}
fi
docker build -f ${DOCKERFILE} -t ${IMAGE} .
echo Built ${IMAGE}
#!/bin/bash
set -e
source $(dirname $0)/version
./build
#!/bin/bash
set -e
source $(dirname $0)/version
cd $(dirname $0)/../package
TAG=${TAG:-${VERSION}${SUFFIX}}
REPO=${REPO:-rancher}
cp ../bin/rio-controller ./rio-controller
IMAGE=${REPO}/rio-controller:${TAG}
docker build -t ${IMAGE} .
mkdir -p ../dist
#!/bin/bash
cd $(dirname $0)/..
. ./scripts/version
mkdir -p dist/artifacts
tar cvzf dist/artifacts/rio-${VERSION}-linux-amd64.tar.gz -h bin/rio --xform='s!^bin!rio-'${VERSION}'-linux-amd64!'
tar cvzf dist/artifacts/rio-${VERSION}-darwin.tar.gz bin/rio-darwin --xform='s!.*!rio-'${VERSION}'-darwin/rio!'
W=rio-${VERSION}-windows
mkdir -p $W
trap "rm -rf $W" EXIT
cp -f bin/rio-windows $W/rio.exe
zip dist/artifacts/rio-${VERSION}-windows.zip $W/rio.exe
#!/bin/bash
if [ ! -d $1/staging/src/k8s.io ]; then
echo Kubernetes source not found at $1
exit 1
fi
cd $(dirname $0)/../vendor/k8s.io
for i in $1/staging/src/k8s.io/*; do
rm -rf $(basename $i)
ln -s $i .
done
rm -rf kubernetes
mkdir -p kubernetes
cd kubernetes
ln -s $1/{cmd,pkg,plugin,third_party} .
......@@ -4,46 +4,4 @@ set -e
cd $(dirname $0)/..
echo Running tests
mkdir -p ./build
mkdir -p /var/lib/rancher/rio/agent
mount -t tmpfs none /var/lib/rancher/rio/agent
./bin/rio server --disable-agent | grep -v level=info > /var/lib/rancher/rio/agent/agent.log 2>&1 &
for i in {1..120}; do
if [ ! -e /var/lib/rancher/rio/server/node-token ]; then
sleep .5
continue
fi
curl -sf http://localhost:7080/healthz >/dev/null && break
sleep .5
done
curl -sf http://localhost:7080/healthz >/dev/null
rm -rf ./image/root
unsquashfs -d ./image/root ./image/main.squashfs
ENTER_ROOT=$(pwd)/image/root ./bin/rio --debug agent -s https://localhost:7443 -t $(</var/lib/rancher/rio/server/node-token) >>/var/lib/rancher/rio/agent/agent.log 2>&1 &
export PATH=$(pwd)/bin:$PATH
rio login -s https://localhost:7443 -t /var/lib/rancher/rio/server/client-token
echo Waiting for istio/istio-gateway
rio --project=rio-system wait istio/istio-gateway
rio --project=rio-system ps
rio --project=rio-system ps -c
chmod +x ./tests/init-nfs.bash
# ./tests/init-nfs.bash
# export RUN_NFS_TEST=true
cd ./tests
PROC=$(nproc)
if [ "$PROC" > 8 ]; then
PROC=8
fi
tox -- -n $PROC
cd ..
go test -cover -tags=test ./...
......@@ -7,18 +7,18 @@ echo Running validation
PACKAGES="$(go list ./...)"
echo Running: go vet
go vet ${PACKAGES}
echo Running: gometalinter
for i in ${PACKAGES}; do
if [ -n "$(gometalinter $i | \
grep -v 'should have comment.*or be unexported' | \
grep -v 'cli/cmd.*don.t use underscores in Go name' | \
grep -v 'cli/cmd.*should be DNS' | \
tee /dev/stderr)" ]; then
failed=true
fi
done
test -z "$failed"
if ! command -v golangci-lint; then
echo Skipping validation: no golangci-lint available
exit
fi
echo Running validation
echo Running: golangci-lint
golangci-lint run
echo Running: go fmt
test -z "$(go fmt ${PACKAGES} | tee /dev/stderr)"
echo Running: go mod verify
go mod verify
\ No newline at end of file
......@@ -14,5 +14,5 @@ else
fi
if [ -z "$ARCH" ]; then
ARCH=amd64
ARCH=$(go env GOHOSTARCH)
fi
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment