POSTS
CircleCI
- 3 minutes read - 568 wordsIntroduction
circleci is a kind of Continuous Integration platform that you can build your own build pipeline. The platform provides nice ways to integrate with existing code repositories as well good features to use. It is free to use when doing some Open Source project and additional costs when use for commercial or private purposes.
Before test circleci, I’ve tried another platform called travisci. But I was looking to a feature which I could use to cache some objects easily and restore them later.
A basic working example
First of all, create a directory called .circleci, where all files and configurations
related to circleci will be hold. After that, create a new circleci config file called .circleci/config.yml and copy the below configuration to the new file.
1version: 2.1
2
3jobs:
4 build:
5 docker:
6 - image: crops/yocto:ubuntu-19.04-builder
7 environment:
8 LC_ALL: en_US.UTF-8
9 LANG: en_US.UTF-8
10 LANGUAGE: en_US.UTF-8
11
12 steps:
13 - checkout
14 - restore_cache:
15 keys:
16 - sstate-test-{{ .Branch }}-{{ .Revision }}
17 - sstate-test-{{ .Branch }}-
18 - sstate-test-master-
19 - sstate-test-
20 - run:
21 name: Clone poky
22 command: git clone -b warrior --single-branch git://git.yoctoproject.org/poky
23 - run:
24 name: Clone meta-oe
25 command: git clone -b warrior --single-branch https://github.com/openembedded/meta-openembedded.git meta-oe
26 - run:
27 name: Link meta-erlang
28 command: ln -sf . meta-erlang
29 - run:
30 name: Initialize build directory
31 command: TEMPLATECONF=../.circleci source poky/oe-init-build-env build
32 - run:
33 name: Build erlang
34 command: source poky/oe-init-build-env build && bitbake erlang
35 no_output_timeout: 50m
36 - run:
37 name: Build emqx
38 command: source poky/oe-init-build-env build && bitbake emqx
39 no_output_timeout: 50m
40
41 - save_cache:
42 key: sstate-test-{{ .Branch }}-{{ .Revision }}
43 paths:
44 - "build/sstate-cache/"
45
46workflows:
47 workflow:
48 jobs:
49 - buildThere are a few notes about the configuration:
A docker image called crops/yocto will be used. This is very important because we have garanties that the correct and compatible linux distro will be use during the build
steps are used to declare all the procedures necessary to build. Basic you need to descript your commands when use yocto/bitbake
The restore_cache and save_cache are two circleci features which allow use of a cache layer yo speed up the build
Providing Yocto CI configuration
Most of the time, during the CI, we need to have additional configurations that Yocto will use in order to build the desired recipes and images. An easy way to do this is configure the local.conf and bblayers.conf using the TEMPLATECONF.
With TEMPLATECONF we can pass a directory which have config sample files and bitbake will use these files as the template to local.conf and bblayers.conf. That way we can configure our CI build values.
Examples:
.circleci/local.conf.sample: any custom configuration should be place hereMACHINE ??= "qemuarm" DISTRO ?= "poky" PACKAGE_CLASSES ?= "package_ipk" EXTRA_IMAGE_FEATURES ?= "debug-tweaks" USER_CLASSES ?= "buildstats image-mklibs image-prelink" PATCHRESOLVE = "noop" BB_DISKMON_DIRS ??= "\ STOPTASKS,${TMPDIR},1G,100K \ STOPTASKS,${DL_DIR},1G,100K \ STOPTASKS,${SSTATE_DIR},1G,100K \ STOPTASKS,/tmp,100M,100K \ ABORT,${TMPDIR},100M,1K \ ABORT,${DL_DIR},100M,1K \ ABORT,${SSTATE_DIR},100M,1K \ ABORT,/tmp,10M,1K" PACKAGECONFIG_append_pn-qemu-system-native = " sdl" PACKAGECONFIG_append_pn-nativesdk-qemu = " sdl" CONF_VERSION = "1" SSTATE_DIR ?= "${TOPDIR}/sstate-cache" SSTATE_MIRRORS = "\ file://.* http://sstate.yoctoproject.org/dev/PATH;downloadfilename=PATH \n \ file://.* http://sstate.yoctoproject.org/2.6/PATH;downloadfilename=PATH \n \ file://.* http://sstate.yoctoproject.org/2.7.2/PATH;downloadfilename=PATH \n \ ".circleci/bblayers.conf.sample: where all the layers are declared:POKY_BBLAYERS_CONF_VERSION = "2" BBPATH = "${TOPDIR}" BBFILES ?= "" BBLAYERS ?= " \ ##OEROOT##/meta \ ##OEROOT##/meta-poky \ ##OEROOT##/meta-yocto-bsp \ ##OEROOT##/../meta-erlang \ ##OEROOT##/../meta-oe/meta-oe \ "
The final directory layout
.circleci/
.circleci/local.conf.sample
.circleci/bblayers.conf.sample
.circleci/config.yml