Add initial support for Travis CI

pull/4/merge
André Klitzing 2017-09-29 14:29:35 +02:00
parent 4c82591b8e
commit a5b97b53eb
4 changed files with 125 additions and 0 deletions

16
.travis.yml 100644
View File

@ -0,0 +1,16 @@
language: shell
sudo: required
env:
matrix:
- CHECK=format
- CHECK=docs
install:
- sudo resources/travis/setup.sh $CHECK
script:
- sudo resources/travis/build.sh $CHECK
notifications:
email: false

View File

@ -0,0 +1,44 @@
#!/bin/sh
set -e
. "$(dirname "$0")"/common.sh
for arg in "$@"
do
case "$arg" in
format) ENABLE_FORMAT=true;;
docs) ENABLE_DOCS=true;;
*) echo "Unknown command: $1" && exit 1
esac
done
alpine_run prepare <<-EOF
mkdir -p /tmp/build/format
mkdir -p /tmp/build/docs
EOF
if [ "$ENABLE_FORMAT" = true ]; then
alpine_run format <<-EOF
cd /tmp/build/format
cmake -Dtools.only=ON ~
make format
cd ~
git add .
git --no-pager diff --staged
git diff-index --quiet HEAD
EOF
fi
if [ "$ENABLE_DOCS" = true ]; then
alpine_run docs <<-EOF
cd /tmp/build/docs
cmake -Dtools.only=ON ~
make sdk
make notes
EOF
fi

View File

@ -0,0 +1,12 @@
readonly ALPINE_ROOT='/mnt/alpine'
readonly ALPINE_USER='governikus'
alpine_run() {
local folding="${1:-chroot}"
local user="${2:-${ALPINE_USER}}"
local cmd="${3:-sh}"
echo -e "travis_fold:start:$folding"
chroot "$ALPINE_ROOT" /usr/bin/env -i su -l $user sh -c "cd; $cmd"
echo -e "travis_fold:end:$folding"
}

View File

@ -0,0 +1,53 @@
#!/bin/sh
set -eu
. "$(dirname "$0")"/common.sh
readonly CLONE_DIR="${CLONE_DIR:-$(pwd)}"
MINIROOTFS_VERSION="3.6.2"
MINIROOTFS_SHA="df4bf81fdafdc72b32ad455c23901935fdfe5815993612ba7a2df4bae79d97ca"
MINIROOTFS="alpine-minirootfs-${MINIROOTFS_VERSION}-x86_64.tar.gz"
MINIROOTFS_URI="http://dl-cdn.alpinelinux.org/alpine/v${MINIROOTFS_VERSION%.*}/releases/x86_64/$MINIROOTFS"
cd /tmp
wget "$MINIROOTFS_URI"
echo "$MINIROOTFS_SHA $MINIROOTFS" | sha256sum -c
mkdir -p "${ALPINE_ROOT}"
tar xf "$MINIROOTFS" -C "${ALPINE_ROOT}"
chmod 755 "$ALPINE_ROOT"
cd "$ALPINE_ROOT"
cp /etc/resolv.conf etc/resolv.conf
mount -t proc none proc
mount --rbind /sys sys
mount --rbind /dev dev
mount --rbind /run run
ln -sf /run/shm dev/shm
PACKAGES="cmake make ninja git"
for arg in "$@"
do
case "$arg" in
format) PACKAGES="$PACKAGES uncrustify";;
docs) PACKAGES="$PACKAGES py2-sphinx py2-setuptools";;
*) echo "Unknown command: $1" && exit 1
esac
done
alpine_run packages root <<-EOF
adduser $ALPINE_USER -G users -s /bin/sh -D
apk upgrade -U -a
apk add $PACKAGES
EOF
mount --bind "$CLONE_DIR" "${ALPINE_ROOT}/home/${ALPINE_USER}"
alpine_run chown root <<-EOF
chown -R $ALPINE_USER: /home/${ALPINE_USER}
EOF