Skip to content
This repository has been archived by the owner on Mar 22, 2023. It is now read-only.

Commit

Permalink
add travis integration
Browse files Browse the repository at this point in the history
  • Loading branch information
lplewa committed Dec 11, 2018
1 parent a7dbbaf commit 62e8592
Show file tree
Hide file tree
Showing 9 changed files with 690 additions and 0 deletions.
1 change: 1 addition & 0 deletions .travis.yml
30 changes: 30 additions & 0 deletions travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
dist: trusty

sudo: required

language: c

services:
- docker

env:
matrix:
- TYPE=normal OS=ubuntu OS_VER=18.04 PUSH_IMAGE=1 COVERAGE=1
- TYPE=normal OS=fedora OS_VER=28 PUSH_IMAGE=1

before_install:
- echo $TRAVIS_COMMIT_RANGE
- export HOST_WORKDIR=`pwd`
- export GITHUB_REPO=pmem/vmemcache
- export DOCKERHUB_REPO=pmem/vmemcache
- cd utils/docker
- ./pull-or-rebuild-image.sh
- if [[ -f push_image_to_repo_flag ]]; then PUSH_THE_IMAGE=1; fi
- if [[ -f skip_build_package_check ]]; then export SKIP_CHECK=1; fi
- rm -f push_image_to_repo_flag skip_build_package_check

script:
- ./build.sh

after_success:
- if [[ $PUSH_THE_IMAGE -eq 1 ]]; then images/push-image.sh $OS-$OS_VER; fi
95 changes: 95 additions & 0 deletions utils/docker/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/usr/bin/env bash
#
# Copyright 2017-2018, Intel Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# * Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#
# build-local.sh - runs a Docker container from a Docker image with environment
# prepared for running tests.
#
#
# Notes:
# - run this script from its location or set the variable 'HOST_WORKDIR' to
# where the root of this project is on the host machine,
# - set variables 'OS' and 'OS_VER' properly to a system you want to build this
# repo on (for proper values take a look on the list of Dockerfiles at the
# utils/docker/images directory), eg. OS=ubuntu, OS_VER=16.04.
#

set -e

if [[ -z "$OS" || -z "$OS_VER" ]]; then
echo "ERROR: The variables OS and OS_VER have to be set " \
"(eg. OS=ubuntu, OS_VER=16.04)."
exit 1
fi

if [[ -z "$HOST_WORKDIR" ]]; then
HOST_WORKDIR=$(readlink -f ../..)
fi

chmod -R a+w $HOST_WORKDIR

imageName=${DOCKERHUB_REPO}:${OS}-${OS_VER}
containerName=vmemcache-${OS}-${OS_VER}

if [[ "$command" == "" ]]; then
command="./run-build.sh";
fi

if [ -n "$DNS_SERVER" ]; then DNS_SETTING=" --dns=$DNS_SERVER "; fi

WORKDIR=/vmemcache
SCRIPTSDIR=$WORKDIR/utils/docker

echo Building ${OS}-${OS_VER}

ci_env=`bash <(curl -s https://codecov.io/env)`
# Run a container with
# - environment variables set (--env)
# - host directory containing source mounted (-v)
# - working directory set (-w)
docker run --privileged=true --name=$containerName -ti \
$DNS_SETTING \
${docker_opts} \
$ci_env \
--env http_proxy=$http_proxy \
--env https_proxy=$https_proxy \
--env GITHUB_TOKEN=$GITHUB_TOKEN \
--env WORKDIR=$WORKDIR \
--env SCRIPTSDIR=$SCRIPTSDIR \
--env COVERAGE=$COVERAGE \
--env TRAVIS_REPO_SLUG=$TRAVIS_REPO_SLUG \
--env TRAVIS_BRANCH=$TRAVIS_BRANCH \
--env TRAVIS_EVENT_TYPE=$TRAVIS_EVENT_TYPE \
-v $HOST_WORKDIR:$WORKDIR \
-v /etc/localtime:/etc/localtime \
-w $SCRIPTSDIR \
$imageName $command
73 changes: 73 additions & 0 deletions utils/docker/images/Dockerfile.fedora-28
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#
# Copyright 2016-2018, Intel Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# * Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#
# Dockerfile - a 'recipe' for Docker to build an image of fedora-based
# environment prepared for running libvmemcache tests.
#

# Pull base image
FROM fedora:28
MAINTAINER [email protected]

# Install basic tools
RUN dnf update -y \
&& dnf install -y \
clang \
cmake \
gcc \
git \
hub \
libunwind-devel \
make \
man \
pandoc \
passwd \
rpm-build \
sudo \
tar \
wget \
which \
&& dnf clean all

# Add user
ENV USER user
ENV USERPASS pass
RUN useradd -m $USER
RUN echo $USERPASS | passwd $USER --stdin
RUN gpasswd wheel -a $USER
USER $USER

# Set required environment variables
ENV OS fedora
ENV OS_VER 28
ENV PACKAGE_MANAGER rpm
ENV NOTTY 1
69 changes: 69 additions & 0 deletions utils/docker/images/Dockerfile.ubuntu-18.04
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#
# Copyright 2016-2018, Intel Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# * Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#
# Dockerfile - a 'recipe' for Docker to build an image of ubuntu-based
# environment prepared for running libvmemcache tests.
#

# Pull base image
FROM ubuntu:18.04
MAINTAINER [email protected]

# Update the Apt cache and install basic tools
RUN apt-get update \
&& apt-get install -y software-properties-common \
clang \
cmake \
curl \
debhelper \
devscripts \
gcc \
gdb \
git \
libunwind8-dev \
pkg-config \
sudo \
wget \
whois \
&& rm -rf /var/lib/apt/lists/*

# Add user
ENV USER user
ENV USERPASS pass
RUN useradd -m $USER -g sudo -p `mkpasswd $USERPASS`
USER $USER

# Set required environment variables
ENV OS ubuntu
ENV OS_VER 18.04
ENV PACKAGE_MANAGER deb
ENV NOTTY 1
69 changes: 69 additions & 0 deletions utils/docker/images/build-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env bash
#
# Copyright 2016-2018, Intel Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# * Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#
# build-image.sh <OS-VER> - prepares a Docker image with <OS>-based
# environment for testing libvmemcache, according
# to the Dockerfile.<OS-VER> file located
# in the same directory.
#
# The script can be run locally.
#

set -e

function usage {
echo "Usage:"
echo " build-image.sh <DOCKERHUB_REPO> <OS-VER>"
echo "where <OS-VER>, for example, can be 'ubuntu-16.04', provided " \
"a Dockerfile named 'Dockerfile.ubuntu-16.04' exists in the " \
"current directory."
}

# Check if the first and second argument is nonempty
if [[ -z "$1" || -z "$2" ]]; then
usage
exit 1
fi

# Check if the file Dockerfile.OS-VER exists
if [[ ! -f "Dockerfile.$2" ]]; then
echo "ERROR: wrong argument."
usage
exit 1
fi

# Build a Docker image tagged with ${DOCKERHUB_REPO}:OS-VER
docker build -t $1:$2 \
--build-arg http_proxy=$http_proxy \
--build-arg https_proxy=$https_proxy \
-f Dockerfile.$2 .
Loading

0 comments on commit 62e8592

Please sign in to comment.