GitLab CI build scripts for GitLab projects

I’m putting here the build scripts that https://ci.gitlab.com uses to build GitLab projects.

GitLab Community Edition

Build settings

Get code: git clone
Timeout: 60

Spinach

export PATH=~/bin:/usr/local/bin:/usr/bin:/bin
ruby -v
which ruby
gem install bundler --no-ri --no-rdoc
cp config/database.yml.mysql config/database.yml
cp config/gitlab.yml.example config/gitlab.yml
sed "s/username\:.*$/username\: runner/" -i config/database.yml
sed "s/password\:.*$/password\: 'password'/" -i config/database.yml
sed "s/gitlabhq_test/gitlabhq_test_$((RANDOM/5000))/" -i config/database.yml
touch log/application.log
touch log/test.log
bundle --without postgres production
bundle exec rake db:create RAILS_ENV=test 
RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach 

Rspec

export PATH=~/bin:/usr/local/bin:/usr/bin:/bin

ruby -v
which ruby
gem install bundler --no-ri --no-rdoc
cp config/database.yml.mysql config/database.yml
cp config/gitlab.yml.example config/gitlab.yml
sed "s/username\:.*$/username\: runner/" -i config/database.yml
sed "s/password\:.*$/password\: 'password'/" -i config/database.yml
sed "s/gitlabhq_test/gitlabhq_test_$((RANDOM/5000))/" -i config/database.yml
touch log/application.log
touch log/test.log
bundle --without postgres production
bundle exec rake db:create RAILS_ENV=test 
RAILS_ENV=test SIMPLECOV=true bundle exec rake spec 

Jasmine

export PATH=~/bin:/usr/local/bin:/usr/bin:/bin
ruby -v
which ruby
gem install bundler --no-ri --no-rdoc
cp config/database.yml.mysql config/database.yml
cp config/gitlab.yml.example config/gitlab.yml
sed "s/username\:.*$/username\: runner/" -i config/database.yml
sed "s/password\:.*$/password\: 'password'/" -i config/database.yml
sed "s/gitlabhq_test/gitlabhq_test_$((RANDOM/5000))/" -i config/database.yml
touch log/application.log
touch log/test.log
bundle --without postgres production
bundle exec rake db:create RAILS_ENV=test 
RAILS_ENV=test SIMPLECOV=true bundle exec rake jasmine:ci 

Rubocop

export PATH=~/bin:/usr/local/bin:/usr/bin:/bin
ruby -v
which ruby
gem install bundler --no-ri --no-rdoc
cp config/database.yml.mysql config/database.yml
cp config/gitlab.yml.example config/gitlab.yml
bundle --without postgres production
bundle exec rubocop

Brakeman

export PATH=~/bin:/usr/local/bin:/usr/bin:/bin
ruby -v
which ruby
gem install bundler --no-ri --no-rdoc
cp config/database.yml.mysql config/database.yml
cp config/gitlab.yml.example config/gitlab.yml
bundle --without postgres production
bundle exec rake brakeman

GitLab CI

Build settings

Get code: git clone
Timeout: 30

Rspec

export PATH=~/bin:/usr/local/bin:/usr/bin:/bin
export RAILS_ENV=test
ruby -v
gem install bundler --no-ri --no-rdoc
cp config/database.yml.mysql config/database.yml
cp config/application.yml.example config/application.yml
sed "s/username\:.*$/username\: runner/" -i config/database.yml
sed "s/password\:.*$/password\: 'password'/" -i config/database.yml
bundle --without postgres --jobs $(($(nproc) + 1))
bundle exec rake db:setup
bundle exec rspec spec
status=$?
echo $status
exit $status

GitLab CI Runner

Build settings

Get code: git fetch
Timeout: 30

Rspec

bundle
bundle exec rspec

GitLab Shell

Build settings

Get code: git clone
Timeout: 30

Rspec

export PATH=/home/gitlab-runner/bin:/usr/local/bin/usr/bin:/bin
gem install bundler
cp config.yml.example config.yml
bundle
bundle exec rspec spec

Thank you axil :smile:

A little info for the people who want to use a digitalocean droplet for the runner and want to run these tests:
You need a plan with at least 4 GB Ram. Otherwise the RSpec tests will fail because the runner could not allocate enough memory.

@haynes you set up your own runners for https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/304 ?

@axil yes. I first tried it with the 2 GB option from digitalocean, but ran into memory issues with it. With 4 GB it worked fine.

Cool! Perhaps you could overcome the memory issue if you had swap enabled. But yes, the more the RAM the quicker the builds are :smile: