Skip to content

Instantly share code, notes, and snippets.

@DrPsychick
Last active February 2, 2019 23:43
Show Gist options
  • Save DrPsychick/7b6ee820b23fc0d3023c54f25c37aabd to your computer and use it in GitHub Desktop.
Save DrPsychick/7b6ee820b23fc0d3023c54f25c37aabd to your computer and use it in GitHub Desktop.
compile .travis.yml into script to test locally

Run travis build locally

cd <to you project directory>
docker run -dt --rm --name travisbuild -v $PWD:/project travisci/ubuntu-ruby:16.04 /sbin/init
docker exec -it travisbuild /bin/bash
  • install travis as user travis
apt-get install sudo
useradd -m -u 1000 travis
echo "travis ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers
su - travis
git clone https://github.com/travis-ci/travis-build
(
cd travis-build
mkdir -p ~/.travis
ln -s $PWD ~/.travis/travis-build
sudo gem install bundler
bundle install
bundler add travis
bundler binstubs travis
)
# fix for travis compile
for repo in travis-support travis-rollout travis-github_apps; do
  git clone https://github.com/travis-ci/$repo.git
  (cd $repo
  gem build $repo.gemspec
  sudo gem install $repo
  )
  rm -rf $repo
done
exit
# remove sudo permission
sed -i -e '/^travis/d' /etc/sudoers
  • now run lint or compile as often as you want
docker exec -it -u travis -w /project travisbuild travis lint
docker exec -it -u travis -w /project travisbuild travis compile

how to run the compiled .travis.yml?!?

did not work

  • may be needed when using a different base image. on ubuntu-ruby it was not needed.
apt-get install -y -q ruby ruby-dev build-essential
gem install travis --no-rdoc --no-ri

alternative image

  • take image: caktux/travis-cli
  • running the script seems to require "apt-get"!
cd <your git project>
docker run --rm -it -v $PWD:/project --entrypoint /bin/sh caktux/travis-cli
(cd /
git clone https://github.com/travis-ci/travis-build
cd travis-build
mkdir -p ~/.travis
ln -s $PWD ~/.travis/travis-build
gem install bundler
gem install travis
# required dependencies
apk add -U gcc libc-dev make bash
bundle install --gemfile ~/.travis/travis-build/Gemfile
#bundler binstubs travis
)
travis compile > travis-test.sh
chmod +x travis-test.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment