How to reproduce a travis-ci build environment for debugging - travis-ci

I am seeing a build failure on travis-ci, which I cannot reproduce on my local machine. Are there instructions somewhere for setting up a VM that is identical to the travis-ci linux build environment? I'm glad to have travis-ci already reveal a new bug, but less excited to debug it by sending in commits that add debug code.

For container-based builds, there are now instructions on how to setup a docker image locally.
Unfortunately, quite a few steps are still manual. Here are the commands you need to get it up and running:
# change the image according to the language chosen in .travis.yml
$ docker run -it -u travis quay.io/travisci/travis-jvm /bin/bash
# now that you are in the docker image, switch to the travis user
sudo su - travis
# Install a recent ruby (default is 1.9.3)
rvm install 2.3.0
rvm use 2.3.0
# Install travis-build to generate a .sh out of .travis.yml
cd builds
git clone https://github.com/travis-ci/travis-build.git
cd travis-build
gem install travis
travis # to create ~/.travis
ln -s `pwd` ~/.travis/travis-build
bundle install
# Create project dir, assuming your project is `me/project` on GitHub
cd ~/builds
mkdir me
cd me
git clone https://github.com/me/project.git
cd project
# change to the branch or commit you want to investigate
travis compile > ci.sh
# You most likely will need to edit ci.sh as it ignores matrix and env
bash ci.sh

You can use Travis Build which is a library (which means you've to place it in ~/.travis/) to generate a shell based build script (travis compile) which can be then uploaded to the VMs using SSH and executed.
Below steps are just guidance in order to get you into the right track (if anything is missing, let me know).
Docker
Example command to run container (which can be found at Docker Hub):
docker run -it travisci/ubuntu-ruby:18.04 /bin/bash
Run your container, clone your repository then test it manually.
See: Running a Container Based Docker Image Locally
SSH access
Check out this answer. Basically you need to setup bounce host, then configure your build to run SSH tunnel.
Here is the example .travis.yml:
sudo: required
dist: trusty
language: python
python: "2.7"
script:
- echo travis:$sshpassword | sudo chpasswd
- sudo sed -i 's/ChallengeResponseAuthentication no/ChallengeResponseAuthentication yes/' /etc/ssh/sshd_config
- sudo service ssh restart
- sudo apt-get install sshpass
- sshpass -p $sshpassword ssh -R 9999:localhost:22 -o StrictHostKeyChecking=no travisci#$bouncehostip
Local setup
Here are the steps to test it on your local environment:
cd ~
git clone https://github.com/travis-ci/travis-build.git
ln -s ~/travis-build/ ~/.travis/travis-build
sudo gem install bundler
bundle install --gemfile ~/.travis/travis-build/Gemfile
cd repo-dir/
travis login -g <github_token>
vim .travis.yaml
travis lint # to validate script
travis compile # to transform into shell script
Vagrant/VM
After you did travis compile which would produce the bash script as result of your .travis.yml, you can use use vagrant to run this script into virtualized environment using provided Vagrantfile and the following steps:
vagrant up
vagrant ssh
cd /vagrant
bundle exec rspec spec
You probably need to install more tools in order to test it.
Here is some git hint which avoids you to generates unnecessary commits when doing trial & errors commits for Travis CI testing:
Fork the repo (or use separate branch).
After initial commit, keep adding --amend to replace your previous commit:
git commit --amend -m 'Same message.' -a
Push the amended commit by force (e.g. into already opened PR):
git push fork -f
Now Travis CI would re-check the same commit over and over again.
See also: How to run travis-ci locally.

I'm facing the same issue right now. I used to use CircleCI before, where you could just login to VM via ssh, but this doesn't work with Travis-CI VMs.
I was able to debug it (to a certain point) by setting up Travis-ci VM clone via Travis-Cookbooks. You would need to install VirtualBox and Vagrant on your computer first before cloning this repository.
Once you have Travis-Cookbooks cloned, open the folder, launch command prompt|terminal and type vagrant up. Once Vagrant finishes setting up VM (may take a long time) on your machine, you can connect to it via ssh by running vagrant ssh.
From there, you would need to clone your own repository (or just copy the code to VM) and apply the steps from your .travis.yml file.

Eregon's answer failed for me at travis compile, there error looks like:
/home/travis/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- travis/support (LoadError)
I got it working with the following adjustments: (Adjustments marked with # CHANGED. I'm using the node environment)
# change the image according to the language chosen in .travis.yml
# Find images at https://quay.io/organization/travisci
docker run -it quay.io/travisci/travis-node-js /bin/bash
# now that you are in the docker image, switch to the travis user
su travis
# Install a recent ruby (default is 1.9.3) to make bundle install work
rvm install 2.3.0
rvm use 2.3.0
# Install travis-build to generate a .sh out of .travis.yml
sudo mkdir builds # CHANGED
cd builds
sudo git clone https://github.com/travis-ci/travis-build.git
cd travis-build
gem install travis
travis # to create ~/.travis
ln -s `pwd` ~/.travis/travis-build
bundle install
bundler add travis # CHANGED
sudo mkdir bin # CHANGED
sudo chmod a+w bin/ # CHANGED
bundler binstubs travis # CHANGED
# Create project dir, assuming your project is `me/project` on GitHub
cd ~/builds
mkdir me
cd me
git clone https://github.com/me/project.git
cd project
# change to the branch or commit you want to investigate
~/.travis/travis-build/bin/travis compile > ci.sh # CHANGED
# You most likely will need to edit ci.sh as it ignores matrix and env
# In particular I needed to edit --branch=’’ to the branch name
bash ci.sh

Related

jailshell: composer: command not found

When I SSH into my server and run composer install it works without any issues. However when the command is issued from my CI/CD that would SSH on my server to get the changes I get this error:
jailshell: composer: command not found
How do I fix this?
My CI/CD:
deploy:
stage: deploy
script:
- ssh -tt user#domain.com
"cd /path/to/public_html/ &&
git checkout master &&
git pull &&
composer install &&
exit"
Edit
To answer #NicoHaase's question. There was a guide about adding an alias on my .bashrc but it still didn't work so I ended up downloading composer.phar and added it to my repository and instead of composer install, I use php composer.phar install instead. I mean it works now but that's not the solution to this question so I'm not writing that as an answer.

How do I boot into Mendel OS on the sdcard with the Coral Dev board?

From this instruction it looks like Google allows booting to the sdcard. However, the image they provided (recovery.img) is only an image to boot the board automatically to U-boot, after which you'll still have to flash the MendelOS to eMMC with USB.
I'd like to have the entire OS on the sdcard, that way it's easier to make copy of it and save the state of the OS.
In order to create a MendelOS image that can be flashed in to an sd-card, you'll need to build the image your self. The steps for doing this:
Cloning the Mendel repo's source from here
# Get the repo binary that's necessary to clone Mendel
$ mkdir -p bin
$ export PATH=$PATH:$HOME/bin
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
# Setup your git env
$ git config --global user.name "Your Name"
$ git config --global user.email "you#example.com"
# clone the repo
$ mkdir mendel && cd mendel
$ repo init -u https://coral.googlesource.com/manifest -b release-day
$ repo sync -j$(nproc)
Make sure that the build system on your host machine meets these requirements:
# System
A 64-bit CPU
Kernel 4.15 or newer
binfmt-support 2.1.7 or newer
# OS
The suggested OSes are: Ubuntu 18.10+ or Debian Buster or newer.
# Install qemu
$ sudo apt-get install qemu-user-static
# Install docker
$ sudo apt-get install docker.io
$ sudo adduser $USER docker
Build:
$ sudo su
$ source build/setup.sh
$ FETCH_PACKAGES=true m docker-sdcard
After the build succeeds, you'll see your sdcard image in the out directory. You can install that to your sdcard using the dd command or some opensrouce tools like Balena Etcher.
Enable boot from the sd-card by switching the boot switch to as described ON OFF ON ON here.
Cheers!

How can i customize greenlight from big blue button

For my one project I use greenlight
first, I installed greenlight on the server but I want to customize the landing page but I don't how to do it. so I installed rails application in my server, I did some changes like adding a custom class. but no effect on the landing page.
can someone explain me how can I fully customize greenlight directly on the server ?
Its for Greenlight V1.
After searching bit i found below steps to setup ruby on rails greenlight app on server.
If you already setup greenlight with docker then please stop docker.
for docker compose you need to run command docker-compose down. it will stop docker image and you will see 404 on your server .
You need to fork greenlight from github first then clone that project in server you can clone it anywhere on server just make sure your server is running on port 5000.
you can checkout more from here
This are all the commands I used to have greenlight running without docker which works for me
======================
apt-get install curl
sudo apt-get install gnupg2
curl -sSL https://rvm.io/mpapis.asc | sudo gpg2 --import -
sudo gpg2 --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | sudo bash -s stable
source /etc/profile.d/rvm.sh
rvm requirements
rvm list known
rvm install 2.5.1
rvm use 2.5.1 --default
ruby --version
gem install rails
cd /
git clone https://github.com/bigbluebutton/greenlight.git
cd /greenlight
nano Gemfile
(mover dotenv-rails fuera del bloque test/development)
gem install bundler -v 1.16.1
sudo apt-get install libpq-dev
bundle
cp greenlight.nginx /etc/bigbluebutton/nginx/greenlight.nginx
systemctl restart nginx
rake secret
(Copy the secret generated, you will need it for .env)
bbb-conf --secret
(Copy the URL and Secret, you will need it for .env)
cp sample.env .env
nano .env
(fill the Secret and BigBlueButton credentials you generated before)
RAILS_ENV=production rake db:migrate
rails assets:precompile
rails s -p 5000 -e production
=======================================
In this project do changes as you require and run server again.
first of all you must have installed greenlight installed on server
for changing the color of theme :
vim config/application.rb
scroll down and you will found following code just replace code of color with your desire:
# Default primary color if the user does not specify one
config.primary_color_default = "#116ceb"
# Default primary color lighten if the user does not specify one
config.primary_color_lighten_default = "#e8eff9"
# Default primary color darken if the user does not specify one.
config.primary_color_darken_default = "#316cbe"
there is lots of things you can customize..(almost everything).
And one of the most important thing after making changes to any file you must have to rebuild your image of docker you can do that by running the command which is given at the end.
This command is for default settings if you have changed the name of your image please replace bigbluebutton/greenlight release-v2 with yourimage name.
you will find your image name here:
#this will open the yml file for docker settings
vim docker-compose.yml
#file will look like this:
ersion: '3'
services:
app:
entrypoint: [bin/start]
image: bigbluebutton/greenlight:release-v2 #nmae of your image
container_name: greenlight-v2
env_file: .env
restart: unless-stopped
ports:
- 127.0.0.1:5000:80
copy this command and past into the terminal blow command for rebuilding your docker image
docker-compose down && ./scripts/image_build.sh bigbluebutton/greenlight release-v2 && docker-compose up -d

How to build docker-ce from source on macOS

Anyone knows if there's a guide to build from source and replace docker binary on Mac with it?
The readme doesn't say so I try some make target but got https://github.com/docker/for-mac/issues/3353
Edited
What I was trying to do, to be exact, is to debug docker cli to see why the Auth doesn't work for a single developer in my former company, regardless all factor checked and verified to be correct.
To do this, checkout the repo of docker cli (it was confusing at first which part of docker live where). But the cli is at:
git#github.com:docker/cli.git
Build it( this build dist for all platform), assuming you have make already:
make -f docker.Makefile binary cross
Then either use this binary(this is for Mac), for example:
build/docker-darwin-amd64 pull mysql
Or backup and replace your original /usr/local/bin/docker with the binary above.
Since on macOS you're not going to run the engine, you may try a different approach. Building the docker client using the Makefile requires docker engine, and a docker client, which you may not have.
I'm building docker (the client) from the docker/cli repository as a plain Go project:
Clone the repo:
$ git clone https://github.com/docker/cli.git
Build master, or checkout a specific tag:
$ git checkout v19.03.6
cd into the repo, create a build directory, and create the require Go project structure:
$ cd cli
$ mkdir -p build/src/github.com/
$ cd build/src/github.com/
$ ln -s ../../.. cli
cd into the build directory and set the GOPATH:
$ cd ../..
$ export GOPATH=$(pwd)
Build the docker client:
$ go build github.com/docker/cli/cmd/docker
Copy the binary from the build directory, e.g.:
$ cp docker /usr/local/bin
You'll notice that some build-related information is not set:
./docker version
Client:
Version: unknown-version
API version: 1.40
Go version: go1.13.8
Git commit: unknown-commit
Built: unknown-buildtime
OS/Arch: darwin/amd64
Experimental: false
You can pass a suitable -ldflags argument to set those variables as in:
$ go build \
-ldflags \
"-X github.com/docker/cli/cli/version.GitCommit=${docker_gitcommit} \
-X github.com/docker/cli/cli/version.Version=${version} \
-X \"github.com/docker/cli/cli/version.BuildTime=${build_time}\""
provided you have set the docker_gitcommit, version and build_time variables. The escaped quotes in the third flag are required if build_time contain spaces (as the upstream docker binaries do).
Hope this helps.

docker suspend and resume using criu

I am building docker from this version of this source code:
https://github.com/boucher/docker/tree/cr-combined
after cloning the code :
git clone -b cr-combined --single-branch https://github.com/boucher/docker.git
cd docker
#make build
#make binary
And then copied the resulting file #./bundles/../docker to the usr/bin directory
After reopening the terminal and starting the docker engine again.
its shows that i am using my own built version but
This version should have two main docker commands that won't show up in my built one
1- checkpoint
2- restore
could you please help me and tell me where it went wrong
Here is what I do:
$ git clone https://github.com/boucher/docker
$ cd docker
$ git checkout cr-combined
$ env AUTO_GOPATH=1 DOCKER_EXPERIMENTAL=1 \
DOCKER_BUILDTAGS='exclude_graphdriver_btrfs \
exclude_graphdriver_devicemapper' ./hack/make.sh binary
$ ./bundles/1.10.0-dev/binary/docker-1.10.0-dev --help | grep checkpoint
checkpoint Checkpoint one or more running containers
restore Restore one or more checkpointed containers
Hope this helps.

Resources