1
0
mirror of https://github.com/rancher/os.git synced 2025-08-31 22:32:14 +00:00

Use drone-0.4 for CI and migrate build to dapper

This commit is contained in:
Ivan Mikushin
2015-12-14 16:38:19 +05:00
parent d18ec0d34b
commit 99bec55a2f
11 changed files with 62 additions and 199 deletions

View File

@@ -1,3 +1,6 @@
image: rancher/dind:v1.9.1-rancher1
script:
- ./scripts/ci
build:
image: rancher/dapper:1.9.1
volumes:
- /var/run/docker.sock:/var/run/docker.sock
commands:
- dapper -k -O make DEV_BUILD=1 test

View File

@@ -1,4 +0,0 @@
FROM ros-build-base
COPY . ./
COPY .dockerignore.docker .dockerignore

View File

@@ -1,24 +1,26 @@
FROM debian:jessie
RUN apt-get update && \
apt-get -y dist-upgrade && \
apt-get -y install locales sudo vim less curl wget git rsync build-essential syslinux isolinux xorriso \
libblkid-dev libmount-dev libselinux1-dev cpio genisoimage qemu-kvm python-pip ca-certificates
libblkid-dev libmount-dev libselinux1-dev cpio genisoimage qemu-kvm python-pip ca-certificates && \
rm -rf /var/lib/apt/lists/*
RUN ln -s /usr/bin/genisoimage /usr/bin/mkisofs
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8
ENV TERM xterm
RUN curl -sL https://get.docker.com/builds/Linux/x86_64/docker-1.9.1 > /usr/bin/docker
RUN chmod +x /usr/bin/docker
RUN pip install tox
RUN curl -sSL https://storage.googleapis.com/golang/go1.5.2.linux-amd64.tar.gz | tar -xz -C /usr/local
ENV PATH $PATH:/usr/local/go/bin
RUN mkdir -p /go/src /go/bin && chmod -R 777 /go
ENV GOPATH /go
ENV PATH /go/bin:$PATH
ENV GO15VENDOREXPERIMENT 1
WORKDIR /go/src/github.com/rancher/os
RUN pip install tox
RUN curl -sSL https://storage.googleapis.com/golang/go1.5.2.linux-amd64.tar.gz | tar -xz -C /usr/local
RUN curl -sL https://get.docker.com/builds/Linux/x86_64/docker-1.9.1 > /usr/bin/docker
RUN chmod +x /usr/bin/docker
ENV DAPPER_SOURCE /go/src/github.com/rancher/os
ENV DAPPER_OUTPUT ./bin ./dist
ENV DAPPER_RUN_ARGS --privileged
ENV SHELL /bin/bash
WORKDIR ${DAPPER_SOURCE}
COPY .dockerignore.docker .dockerignore

View File

@@ -3,45 +3,62 @@ FORCE_PULL := 0
DEV_BUILD := 0
compile: bin/rancheros
installer: minimal
docker build -t $(IMAGE_NAME):$(VERSION) .
bin/rancheros:
mkdir -p $(dir $@)
go build -tags netgo -installsuffix netgo -ldflags "-X github.com/rancher/os/config.VERSION=$(VERSION) -linkmode external -extldflags -static" -o $@
strip --strip-all $@
all: clean ros-build-base build-all
pwd := $(shell pwd)
include scripts/build-common
ros-build-base:
docker build -t ros-build-base -f Dockerfile.build-base .
assets/docker:
mkdir -p $(dir $@)
curl -L "$(DOCKER_BINARY_URL)" > $@
chmod +x $@
ros-build-image:
docker build -t ros-build -f Dockerfile.build .
$(DIST)/artifacts/vmlinuz: $(BUILD)/kernel/
mkdir -p $(dir $@)
mv $(BUILD)/kernel/boot/vmlinuz* $@
bin/rancheros: ros-build-image
./scripts/docker-run.sh make -f Makefile.docker $@
mkdir -p bin
docker cp ros-build:/go/src/github.com/rancher/os/$@ $(dir $@)
$(BUILD)/kernel/:
mkdir -p $@
([ -e "$(COMPILED_KERNEL_URL)" ] && cat "$(COMPILED_KERNEL_URL)" || curl -L "$(COMPILED_KERNEL_URL)") | tar -xzf - -C $@
build-all: ros-build-image
./scripts/docker-run.sh make -f Makefile.docker DEV_BUILD=$(DEV_BUILD) FORCE_PULL=$(FORCE_PULL) $@
mkdir -p bin dist
docker cp ros-build:/go/src/github.com/rancher/os/bin/rancheros bin/
docker cp ros-build:/go/src/github.com/rancher/os/dist/artifacts dist/
$(BUILD)/images.tar: bin/rancheros
FORCE_PULL=$(FORCE_PULL) ./scripts/mk-images-tar.sh
installer: ros-build-image
./scripts/docker-run.sh --rm make -f Makefile.docker DEV_BUILD=$(DEV_BUILD) FORCE_PULL=$(FORCE_PULL) $@
$(DIST)/artifacts/initrd: bin/rancheros assets/docker $(BUILD)/kernel/ $(BUILD)/images.tar
mkdir -p $(dir $@)
DFS_IMAGE=$(DFS_IMAGE) DEV_BUILD=$(DEV_BUILD) ./scripts/mk-initrd.sh
$(DIST)/artifacts/rancheros.iso: minimal
./scripts/mk-rancheros-iso.sh
$(DIST)/artifacts/iso-checksums.txt: $(DIST)/artifacts/rancheros.iso
./scripts/mk-iso-checksums-txt.sh
version:
@echo $(VERSION)
all: minimal installer iso
clean:
rm -rf bin build dist gopath .dockerfile
minimal: $(DIST)/artifacts/initrd $(DIST)/artifacts/vmlinuz
iso: $(DIST)/artifacts/rancheros.iso $(DIST)/artifacts/iso-checksums.txt
.PHONY: all compile clean build-all ros-build-image ros-build-base version bin/rancheros installer
test: minimal
cd tests/integration && tox
.PHONY: build-all minimal iso installer version bin/rancheros integration-tests

View File

@@ -1,64 +0,0 @@
include build.conf
FORCE_PULL := 0
DEV_BUILD := 0
bin/rancheros:
mkdir -p $(dir $@)
go build -tags netgo -installsuffix netgo -ldflags "-X github.com/rancher/os/config.VERSION=$(VERSION) -linkmode external -extldflags -static" -o $@
strip --strip-all $@
pwd := $(shell pwd)
include scripts/build-common
assets/docker:
mkdir -p $(dir $@)
curl -L "$(DOCKER_BINARY_URL)" > $@
chmod +x $@
$(DIST)/artifacts/vmlinuz: $(BUILD)/kernel/
mkdir -p $(dir $@)
mv $(BUILD)/kernel/boot/vmlinuz* $@
$(BUILD)/kernel/:
mkdir -p $@
([ -e "$(COMPILED_KERNEL_URL)" ] && cat "$(COMPILED_KERNEL_URL)" || curl -L "$(COMPILED_KERNEL_URL)") | tar -xzf - -C $@
$(BUILD)/images.tar: bin/rancheros
FORCE_PULL=$(FORCE_PULL) ./scripts/mk-images-tar.sh
$(DIST)/artifacts/initrd: bin/rancheros assets/docker $(BUILD)/kernel/ $(BUILD)/images.tar
mkdir -p $(dir $@)
DFS_IMAGE=$(DFS_IMAGE) DEV_BUILD=$(DEV_BUILD) ./scripts/mk-initrd.sh
$(DIST)/artifacts/rancheros.iso: minimal
./scripts/mk-rancheros-iso.sh
$(DIST)/artifacts/iso-checksums.txt: $(DIST)/artifacts/rancheros.iso
./scripts/mk-iso-checksums-txt.sh
version:
@echo $(VERSION)
installer: minimal
docker build -t $(IMAGE_NAME):$(VERSION) .
build-all: minimal installer iso
minimal: $(DIST)/artifacts/initrd $(DIST)/artifacts/vmlinuz
iso: $(DIST)/artifacts/rancheros.iso $(DIST)/artifacts/iso-checksums.txt
integration-tests:
cd tests/integration && tox
.PHONY: build-all minimal iso installer version bin/rancheros integration-tests

View File

@@ -8,9 +8,9 @@ if [ "$1" != "--dev" ]; then
echo
echo For \"developer\" builds, run ./build.sh --dev
echo
make all
dapper -k make all
else
make DEV_BUILD=1 all
dapper -k make DEV_BUILD=1 all
fi

View File

@@ -3,10 +3,4 @@ set -ex
cd $(dirname $0)/..
if [ -x "$(which wrapdocker)" ] && ! docker info >/dev/null 2>&1; then
wrapdocker
fi
docker build -t ros-build-base -f Dockerfile.build-base .
docker build -t ros-build -f Dockerfile.build .
./scripts/docker-run.sh --name ros-ci make -f Makefile.docker DEV_BUILD=1 minimal integration-tests
dapper -k -O make DEV_BUILD=1 test

View File

@@ -1,39 +0,0 @@
#!/bin/bash
set -e
DOCKER_ARGS=
if [ -n "$BIND_DIR" ]; then
if [ "$BIND_DIR" = "." ]; then
BIND_DIR=$(pwd)
fi
DOCKER_ARGS="-t -v $BIND_DIR:/go/src/github.com/rancher/os"
fi
if [ -c /dev/kvm ] || [ "${KVM}" == "1" ]; then
DOCKER_ARGS="${DOCKER_ARGS} --device=/dev/kvm:/dev/kvm"
fi
NAME=ros-build
while [ "$#" -gt 0 ]; do
case $1 in
--name)
shift 1
NAME="$1"
;;
--rm)
NAME=$(mktemp ${NAME}-XXXXXX)
rm $NAME
DOCKER_ARGS="${DOCKER_ARGS} --rm"
;;
-t)
DOCKER_ARGS="${DOCKER_ARGS} -t"
;;
*)
break
;;
esac
shift 1
done
DOCKER_ARGS="${DOCKER_ARGS} --name=${NAME}"
docker rm -fv ${NAME} >/dev/null 2>&1 || true
exec docker run -i -v /var/run/docker.sock:/var/run/docker.sock $DOCKER_ARGS ros-build "$@"

View File

@@ -1,6 +0,0 @@
IMAGE_NAME=rancher/os
VERSION=v0.4.0-test
DOCKER_BINARY_URL=https://github.com/rancher/docker/releases/download/v1.8.2-rc1-ros/docker-1.8.2-rc1
COMPILED_KERNEL_URL=https://github.com/imikushin/os-kernel/releases/download/4.2/linux-4.2.0-rancher-x86.tar.gz
DFS_IMAGE=rancher/docker:1.8.1

View File

@@ -1,10 +0,0 @@
#!/bin/bash
set -ex
cd $(dirname $0)/../../../..
cp ./tests/integration/assets/test_02/build.conf ./
make -f Makefile.docker DEV_BUILD=1 minimal
exec ./scripts/run --qemu --no-rebuild --no-rm-usr --fresh

View File

@@ -1,30 +0,0 @@
from __future__ import print_function
import subprocess
import pytest
import rostest.util as u
@pytest.fixture(scope="module")
def build_and_run(request):
print('\nBuilding and running RancherOS with custom kernel')
p = subprocess.Popen(['./scripts/docker-run.sh', '--rm',
'./tests/integration/assets/test_02/test-custom-kernel.sh'],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
def fin():
print('\nTerminating docker-run test-custom-kernel')
p.terminate()
p.wait()
request.addfinalizer(fin)
return p
@pytest.mark.timeout(30)
def test_system_boot(build_and_run):
version = u.rancheros_version('./tests/integration/assets/test_02/build.conf')
print('parsed version: ' + version)
u.flush_out(build_and_run.stdout, 'RancherOS {v} started'.format(v=version))