Skip to content

Commit

Permalink
[ci] Cleanup ci setup
Browse files Browse the repository at this point in the history
  • Loading branch information
hennevogel committed Aug 18, 2015
1 parent f472c90 commit 282fd20
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 241 deletions.
12 changes: 5 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ language: ruby
cache: bundler
rvm:
- 2.2
before_script:
- mysql -e 'create database ci_api_test;'
- sed -e 's,password:.*,password:,' -i src/api/config/database.yml.example
- travis_retry bash -x dist/ci/obs_testsuite_travis_before.sh
- bash -x dist/ci/obs_testsuite_travis_setup.sh
script: "bash -x dist/ci/obs_testsuite_travis.sh $TEST_SUITE"
gemfile: src/api/Gemfile
before_install: dist/ci/obs_testsuite_travis_install.sh
before_script: dist/ci/obs_testsuite_travis_before.sh
script: "dist/ci/obs_testsuite_travis.sh $TEST_SUITE"
env:
- TEST_SUITE=rubocop
- TEST_SUITE=api
Expand All @@ -21,5 +19,5 @@ notifications:
on_success: change
on_failure: change
services:
- memcached # will start memcached
- memcached
sudo: required
29 changes: 0 additions & 29 deletions dist/ci/README

This file was deleted.

67 changes: 0 additions & 67 deletions dist/ci/obs_testsuite_api.sh

This file was deleted.

61 changes: 0 additions & 61 deletions dist/ci/obs_testsuite_common.sh

This file was deleted.

54 changes: 18 additions & 36 deletions dist/ci/obs_testsuite_travis.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,38 +1,29 @@
#!/bin/sh
#
# This script runs all build service test suites depending on $SUBTEST
#
#!/bin/bash
# This script runs the test suites for the CI build

###############################################################################
# Script content for 'Build' step
###############################################################################
#
# Either invoke as described above or copy into an 'Execute shell' 'Command'.
#
# Be verbose and fail script on the first error
set -xe

# Which test suite should run? By default: all
if [ -z $1 ]; then
TEST_SUITE="all"
else
TEST_SUITE="$1"
fi
set -xe

. `dirname $0`/obs_testsuite_common.sh

ret=0
export OBS_REPORT_DIR=results/
export HEADLESS=forsure

cd src/api
pushd src/api

if test -z "$SUBTEST"; then
export DO_COVERAGE=1
export TESTOPTS="-v"
case $TEST_SUITE in
api)
bundle exec rake test:api
ruby -rcoveralls -e 'Coveralls.push!'
;;
webui)
bundle exec rake test:webui
ruby -rcoveralls -e 'Coveralls.push!'
;;
rubocop)
bundle exec rake rubocop
Expand All @@ -43,25 +34,16 @@ if test -z "$SUBTEST"; then
bundle exec rake rubocop
;;
esac
cat coverage/.last_run.json
ruby -rcoveralls -e 'Coveralls.push!'
fi

case $SUBTEST in
rake:*)
SUBTEST=${SUBTEST/rake:/}
bundle exec rake $SUBTEST --trace
;;
api:*)
SUBTEST=${SUBTEST/api:/}
thetest=${SUBTEST/:*/}
thename=${SUBTEST/*:/}
bundle exec ruby -Itest test/$thetest --name=$thename || ret=1
tail -n 6000 log/test.log
;;
esac

cd ../..
cleanup
exit $ret

echo "Killing backend processes"
if fuser -v $PWD | egrep 'perl|ruby'; then
list=`fuser -v $PWD 2>&1 | egrep 'perl|ruby' | sed -e "s,^ *$USER *,,;" | cut '-d ' -f1`
for p in $list; do
echo "Kill $p"
# the process might have gone away on its own, so use || true
kill $p || true
done
fi
60 changes: 30 additions & 30 deletions dist/ci/obs_testsuite_travis_before.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
#!/bin/sh
#
# This script installs dependencies on travis
#
#!/bin/bash
# This script prepares the CI build for running

###############################################################################
# Script content for 'Build' step
###############################################################################
#
# Either invoke as described above or copy into an 'Execute shell' 'Command'.
#
echo "Configuring backend"
sed -i -e "s|my \$hostname = .*$|my \$hostname = 'localhost';|" \
-e "s|our \$bsuser = 'obsrun';|our \$bsuser = 'jenkins';|" \
-e "s|our \$bsgroup = 'obsrun';|our \$bsgroup = 'jenkins';|" src/backend/BSConfig.pm.template
cp src/backend/BSConfig.pm.template src/backend/BSConfig.pm
chmod a+x src/api/script/start_test_backend

set -xe
pushd src/api
echo "Creating database"
mysql -e 'create database ci_api_test;'

sudo chmod a+w /etc/apt/sources.list.d
echo 'deb http://download.opensuse.org/repositories/OBS:/Server:/Unstable/xUbuntu_12.04 /' > /etc/apt/sources.list.d/opensuse.list
#sudo apt-get update
sudo apt-get update -o Dir::Etc::sourcelist="sources.list.d/opensuse.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
echo "Configuring database"
cp config/database.yml.example config/database.yml
sed -e 's,password:.*,password:,' -i config/database.yml
sed -i "s|database: api|database: ci_api|" config/database.yml

cat > /etc/apt/sources.list.d/security.list << EOF
deb http://security.ubuntu.com/ubuntu precise-security main restricted
deb http://security.ubuntu.com/ubuntu precise-security universe
deb http://security.ubuntu.com/ubuntu precise-security multiverse
EOF
sudo apt-get update -o Dir::Etc::sourcelist="sources.list.d/security.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
echo "Configuring frontend"
cp config/options.yml.example config/options.yml
cp config/thinking_sphinx.yml.example config/thinking_sphinx.yml
chmod a+x script/start_test_api

# dependencies of backend
sudo apt-get install --force-yes travis-deps libxml-parser-perl libfile-sync-perl python-rpm python-urlgrabber python-sqlitecachec python-libxml2 createrepo libbssolv-perl sphinxsearch libjson-xs-perl libxml-simple-perl libgd-gd2-perl
echo "Initialize database"
bundle exec rake db:drop db:create db:setup --trace

pushd src/api
if test "$REMOVEGEMLOCK" = true; then
rm Gemfile.lock
fi
gem install bundler
echo 'gem "coveralls"' >> Gemfile
bundle install
# Stuff
# travis rvm can not deal with our extended executable names
sed -i 1,1s,\.ruby2\.2,, {script,bin}/*
# Clear temp data
rm -rf log/* tmp/cache tmp/sessions tmp/sockets
popd

echo "Build apidocs"
pushd docs/api
make
popd
21 changes: 21 additions & 0 deletions dist/ci/obs_testsuite_travis_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
# This script installs dependencies for the CI build

# Be verbose and fail script on the first error
set -xe

# Install updates from our own repository
sudo chmod a+w /etc/apt/sources.list.d
echo 'deb http://download.opensuse.org/repositories/OBS:/Server:/Unstable/xUbuntu_12.04 /' > /etc/apt/sources.list.d/opensuse.list
sudo apt-get update -o Dir::Etc::sourcelist="sources.list.d/opensuse.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"

# Install ubuntu security updates
cat > /etc/apt/sources.list.d/security.list << EOF
deb http://security.ubuntu.com/ubuntu precise-security main restricted
deb http://security.ubuntu.com/ubuntu precise-security universe
deb http://security.ubuntu.com/ubuntu precise-security multiverse
EOF
sudo apt-get update -o Dir::Etc::sourcelist="sources.list.d/security.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"

# Install the dependencies of the backend
sudo apt-get install --force-yes travis-deps libxml-parser-perl libfile-sync-perl python-rpm python-urlgrabber python-sqlitecachec python-libxml2 createrepo libbssolv-perl sphinxsearch libjson-xs-perl libxml-simple-perl libgd-gd2-perl
11 changes: 0 additions & 11 deletions dist/ci/obs_testsuite_travis_setup.sh

This file was deleted.

1 change: 1 addition & 0 deletions src/api/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ AllCops:
Exclude:
- 'tmp/**/*'
- 'lib/templates/**/*'
- 'vendor/bundle/**/*'

# Someday we should add copyrights
Style/Copyright:
Expand Down
1 change: 1 addition & 0 deletions src/api/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ group :test do
gem 'ci_reporter'
# for test coverage reports
gem 'simplecov', require: false
gem 'coveralls', require: false
# to colorize minitest output
# gem 'minitest-colorize'
# for rspec like matchers
Expand Down
Loading

0 comments on commit 282fd20

Please sign in to comment.