From e8acf1decf0a5ddd2f5065f41597570a20562502 Mon Sep 17 00:00:00 2001 From: Derek Straka Date: Fri, 28 Oct 2016 13:34:49 -0500 Subject: [PATCH] add Jenkinsfile to test each PR and branch commits This includes a basic test that attempts to compile the rustfmt crate. Ensures that the workspace is always removed at the end of the build. It utilizes available caches to speed up the build process and parallelizes the build across i386, x86_64, arm32, and arm64 targets. Signed-off-by: Derek Straka --- Jenkinsfile | 36 ++++++++++++++++++++++++++++++++++++ conf/local.conf.sample | 4 ++++ scripts/cleanup-env.sh | 5 +++++ scripts/fetch.sh | 8 ++++++-- scripts/setup-env.sh | 7 +++++++ 5 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 Jenkinsfile create mode 100755 scripts/cleanup-env.sh create mode 100755 scripts/setup-env.sh diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..2fc6fdc --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,36 @@ +def targets = [ 'qemux86', 'qemux86-64', 'qemuarm', 'qemuarm64' ] + +def machine_builds = [:] + +for (int i = 0; i < targets.size(); i++) { + def machine = targets.get(i) + + machine_builds["$machine"] = { + node { + try { + stage('Checkout') { + checkout scm + } + stage('Setup Environment') { + sh "./scripts/setup-env.sh" + } + stage('Yocto Fetch') { + sh "GIT_LOCAL_REF_DIR=/srv/git-cache/ ./scripts/fetch.sh master" + } + stage('Build') { + sh "MACHINE=${machine} ./scripts/build.sh" + } + } catch (e) { + echo "Caught: ${e}" + throw e + } finally { + stage('Cleanup Environment') { + sh "./scripts/cleanup-env.sh" + deleteDir() + } + } + } + } +} + +parallel machine_builds diff --git a/conf/local.conf.sample b/conf/local.conf.sample index a7b2d80..08e6e7e 100644 --- a/conf/local.conf.sample +++ b/conf/local.conf.sample @@ -220,6 +220,10 @@ BB_DISKMON_DIRS = "\ #file://.* http://someserver.tld/share/sstate/PATH;downloadfilename=PATH \n \ #file://.* file:///some/local/dir/sstate/PATH" +SSTATE_MIRRORS ?= "file://.* http://build-cache.asterius.io/sstate/PATH;downloadfilename=PATH \n" + +SOURCE_MIRROR_URL ?= "http://build-cache.asterius.io/downloads/" +INHERIT += "own-mirrors rm_work" # # Qemu configuration diff --git a/scripts/cleanup-env.sh b/scripts/cleanup-env.sh new file mode 100755 index 0000000..1367724 --- /dev/null +++ b/scripts/cleanup-env.sh @@ -0,0 +1,5 @@ +#!/bin/bash -e + +sudo umount build + +exit 0 diff --git a/scripts/fetch.sh b/scripts/fetch.sh index 2d4897a..4a54df3 100755 --- a/scripts/fetch.sh +++ b/scripts/fetch.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -x # the repos we want to check out, must setup variables below # NOTE: poky must remain first @@ -33,7 +33,11 @@ update_repo() { git fetch origin || die "unable to fetch ${uri}" else echo "Cloning '${path}'" - git clone ${uri} ${path} || die "unable to clone ${uri}" + if [ -z "${GIT_LOCAL_REF_DIR}" ]; then + git clone ${uri} ${path} || die "unable to clone ${uri}" + else + git clone --reference ${GIT_LOCAL_REF_DIR}/`basename ${path}` ${uri} ${path} + fi pushd ${path} > /dev/null fi diff --git a/scripts/setup-env.sh b/scripts/setup-env.sh new file mode 100755 index 0000000..e5fc3b1 --- /dev/null +++ b/scripts/setup-env.sh @@ -0,0 +1,7 @@ +#!/bin/bash -e + +mkdir -p build + +sudo mount -t tmpfs -o size=64G,mode=755,uid=${UID} tmpfs build + +exit 0