Skip to content

Commit

Permalink
Use Docker at Travis
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Jan 20, 2017
1 parent cf18c2b commit 9895971
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 12 deletions.
65 changes: 65 additions & 0 deletions .travis.sh
@@ -0,0 +1,65 @@
#! /bin/bash

# TODO: This is a modified copy of the
# https://github.com/yast/docker-yast-ruby/blob/master/yast-travis-ruby
# file which runs the tests builds the package as the "nobody" user.
#
# The problem is that the tests are silently skipped for non-root users
# and for root they fail. (They are probably broken for long time
# but very likely nobody noticed that...)

###########################################################################

# This is a CI build script for running inside the Travis builds.
# It's designed for the YaST packages written in Ruby.

# exit on error immediately, print the executed commands
set -e -x

rake check:pot

if [ -e .rubocop.yml ]; then
rubocop
else
# if rubocop is not used then at least check the syntax
rake check:syntax
fi;

if [ -e .spell.yml ]; then
rake check:spelling
fi

yardoc

chown -R nobody:nobody /usr/src/app

# autotools based package
if [ -e Makefile.cvs ]; then
make -f Makefile.cvs
make -s
make -s install
su nobody -c "make -s check VERBOSE=1 Y2DIR=`pwd`"
fi

# enable coverage reports
COVERAGE=1 CI=1 rake test:unit

# build the binary package locally, use plain "rpmbuild" to make it simple
rake tarball > /dev/null 2>&1

PKG_DIR=~nobody/rpmbuild

mkdir -p $PKG_DIR/SOURCES/
cp package/* $PKG_DIR/SOURCES/
chown -R nobody:nobody $PKG_DIR

# Build the binary package, skip the %check section,
# the tests have been already executed outside RPM build.
su nobody -c "rpmbuild -bb --nocheck package/*.spec"

# test the %pre/%post scripts by installing/updating/removing the built packages
# ignore the dependencies to make the test easier, as a smoke test it's good enough
rpm -iv --force --nodeps $PKG_DIR/RPMS/*/*.rpm
rpm -Uv --force --nodeps $PKG_DIR/RPMS/*/*.rpm
# get the plain package names and remove all packages at once
rpm -ev --nodeps `rpm -q --qf '%{NAME} ' -p $PKG_DIR/RPMS/*/*.rpm`
21 changes: 9 additions & 12 deletions .travis.yml
@@ -1,14 +1,11 @@
language: cpp
compiler:
- gcc
sudo: required
language: bash
services:
- docker

before_install:
# disable rvm, use system Ruby
- rvm reset
- wget https://raw.githubusercontent.com/yast/yast-devtools/master/travis-tools/travis_setup.sh
- sh ./travis_setup.sh -p "yast2-devtools yast2-testsuite yast2"
- docker build -t yast-ca-management-image .
script:
- make -f Makefile.cvs
- make
- sudo make install
- make check

# the "yast-travis-ruby" script is included in the base yastdevel/ruby image
# see https://github.com/yast/docker-yast-ruby/blob/master/yast-travis-ruby
- docker run -it -e TRAVIS=1 -e TRAVIS_JOB_ID="$TRAVIS_JOB_ID" yast-ca-management-image ./.travis.sh
9 changes: 9 additions & 0 deletions Dockerfile
@@ -0,0 +1,9 @@
FROM yastdevel/ruby
RUN zypper --gpg-auto-import-keys --non-interactive in --no-recommends \
perl-Date-Calc \
perl-URI \
perl-X500-DN \
perl-XML-Writer \
perl-camgm
COPY . /usr/src/app

0 comments on commit 9895971

Please sign in to comment.