I have created a rubygem which can installed by:
* gem install youtube_dlhelper
* cd .rvm/gems/ruby-2.2.1/gems/youtube_dlhelper-0.1.9.5
* rake setup
I set up my .travis.yml:
os:
-linux
dist: trusty
language: ruby
rvm:
- 2.2.1
- 2.2.2
env:
global:
- JRUBY_OPTS=-Xcext.enabled=true
- CI=true
- TRAVIS=true
- LANG=en_US.UTF-8
- LC_ALL=en_US.UTF-8
before_install:
- sudo apt-get update
- sudo apt-get install ffmpeg
before_script:
- cd $GEM_HOME/gems/youtube_dlhelper-0.1.9.5
- rake setup
after_success:
- CI=true TRAVIS=true coveralls --verbose
notifications:
email:
- samannsml#directbox.com
But travis don't find the directory. Also i tried:
before_script:
- cd $GEM_HOME/gems
- ls
But it looks like the directory is empty.
Maybe anyone has a solution for this problem?
I have seen that the ci uses the git code directly. So it is enough to use
before_script:
- rake setup
So it runs :-)
Related
We originally were using Ruby 2.2.3 for our application, however, now I'm updating the gems due to vulnerabilities and as a result, I have to update the ruby version that the application is running on. Locally, this was fairly straight forward (using rbenv), however, when I push it to GitHub, it fails the CircleCi build because it's pulling the ruby version from an old docker image that's using the old ruby version.
So far, I've pulled the old docker image down using docker pull, ran the image using docker run -it, opened it in VSCode using the Remote Extension, and downloaded rbenv, updated the ruby version, committed the changes with docker commit, pushed it to GitHub with docker push, and tested it but it's still failing the CircleCi build with an error saying that the updated gems need to use the updated version of ruby.
config.yml:
version: 2.1
jobs:
build:
docker:
- image: 073991710092.dkr.ecr.us-east-1.amazonaws.com/signage-dev:latest-v2
environment:
RAILS_LOG_TO_STDOUT: 'true'
RAILS_ENV: test
APP_ENV: development
DB_USERNAME: *******
DB_PASSWORD: *******
DB_HOST: mysql
CACHE_HOST: redis
TZ: "America/New_York"
- image: mysql:5.6.37
name: mysql
environment:
MYSQL_ROOT_PASSWORD: *******
MYSQL_USER: *******
MYSQL_PASSWORD: *******
MYSQL_DATABASE: *******
- image: redis:2.8.6
name: redis
command: redis-server
steps:
- checkout
- run:
name: setup
command: |
mkdir app/log
touch app/log/oink.log
chmod a+rw app/log/oink.log
touch app/rspec.xml
mkdir -p app/tmp/cache/assets/test/sprockets/v3.0
- run:
name: setup database
command: (cd ./app && gem install bundler && bundle install && bundle exec rake --trace db:setup)
- run:
name: run tests
command: |
cd ./app
mkdir /tmp/test-results
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
bundle exec rspec --format progress \
--format RspecJunitFormatter \
--out /tmp/test-results/rspec.xml \
--format progress \
$TEST_FILES
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: /tmp/test-results
destination: test-results
Here's what happens when I open the image in a container and check the ruby version:
docker run -it 073991710092.dkr.ecr.us-east-1.amazonaws.com/signage-dev:latest-v2 bash
root#836591d2e6bf:/# ls
Gemfile bin dev home lib media opt root sbin sys usr
Gemfile.lock boot etc index.html lib64 mnt proc run srv tmp var
root#836591d2e6bf:/# ruby -v
ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux]
Error message in CircleCi (Setup Database):
#!/bin/bash -eo pipefail
(cd ./app && gem install bundler && bundle install && bundle exec rake --trace db:setup)
ERROR: Error installing bundler:
bundler requires Ruby version >= 2.3.0.
Exited with code exit status 1
CircleCI received exit code 1
I sat the config.yml and .ruby-version to upgrade ruby.
But I got an error message unknown Ruby: ruby-2.6.2
It used the ruby-2.3, and It has no problems.
How can I set ruby 2.6.2 with config.yml?
config.yml
defaults: &defaults
macos:
xcode: "10.0"
shell: /bin/bash --login -eo pipefail
aliases:
- &prepare
|
git submodule update --init --recursive
gem install bundler
bundle install
- &filter-only-master
branches:
only:
- master
version: 2
jobs:
ios:
<<: *defaults
steps:
- checkout
- run: *prepare
- run: bundle exec rake test:ios
- run: bash <(curl -s https://codecov.io/bash)
- store_test_results:
path: build/reports
macos:
<<: *defaults
steps:
- checkout
- run: *prepare
- run: bundle exec rake test:macos
- run: bash <(curl -s https://codecov.io/bash)
- store_test_results:
path: build/reports
facebook_utils:
<<: *defaults
steps:
- checkout
- run: *prepare
- run: bundle exec rake test:facebook_utils:ios
- run: bash <(curl -s https://codecov.io/bash)
- store_test_results:
path: build/reports
twitter_utils:
<<: *defaults
steps:
- checkout
- run: *prepare
- run: bundle exec rake test:twitter_utils:ios
- run: bash <(curl -s https://codecov.io/bash)
- store_test_results:
path: build/reports
parseui:
<<: *defaults
steps:
- checkout
- run: *prepare
- run: bundle exec rake test:parseui:all
deployment:
<<: *defaults
steps:
- checkout
- run: *prepare
- run: |
xcrun simctl create "Apple TV 1080p" com.apple.CoreSimulator.SimDeviceType.Apple-TV-1080p com.apple.CoreSimulator.SimRuntime.tvOS-11-0
bundle exec rake package:release
jazzy:
<<: *defaults
steps:
- checkout
- run: *prepare
- run: ./Scripts/jazzy.sh
carthage:
<<: *defaults
steps:
- checkout
- run: *prepare
- run: bundle exec rake test:carthage
cocoapods:
<<: *defaults
steps:
- checkout
- run: *prepare
- run: bundle exec rake test:cocoapods
workflows:
version: 2
pr:
jobs:
- ios
- macos
- facebook_utils
- twitter_utils
- parseui
- jazzy
nightly:
jobs:
- deployment
- cocoapods:
requires:
- deployment
- carthage:
requires:
- deployment
triggers:
- schedule:
cron: "0 1 * * *"
filters: *filter-only-master
.ruby-version
ruby-2.6.2
I get an error message below
#!/bin/bash --login -eo pipefail
git submodule update --init --recursive
gem install bundler
bundle install
^D^Dchruby: unknown Ruby: ruby-2.6.2
Exited with code 1
In CircleCI 2.0 you need to check which ruby versions are installed for the specific macOS container image that you are building with.
Our macOS containers contain multiple versions of Ruby. The default version is the system-installed Ruby. The containers also include the latest stable versions of Ruby at the time that the container is built. We determine the stable versions of Ruby using the Ruby-Lang.org downloads page. The version of Ruby that are installed in each image are listed in the software manifests of each container.
https://circleci.com/docs/2.0/testing-ios/#using-custom-ruby-versions
Since you are building in Xcode 10. The macOS container image 10.0.0: Xcode 10.0 (Build 10A255), ruby versions 2.3.7, 2.4.4, 2.5.1 are available to chruby.
I have the following yml configuration file with 3 different jobs:
stages:
- build
- test
- analyze
build:
stage: build
script:
- apt-get update -qy
- apt-get install -y python3-dev python3-pip
- pip3 install -r requirements.txt
test:
stage: test
script:
- coverage run --source='.' manage.py test
cache:
paths:
- .coverage
analyze:
stage: analyze
script:
- flake8
- coverage report
In the first job I install the requirements, among which are coverage or flake8. But these tools are used in the following jobs. I have tried using 'dependencies' or 'cache', but it didn't work: only files/dirs under the project root directory can be shared, not the binaries under /user/local/bin.
I have tried to indicate another directory for pip install, but the binary is installed in /user/local/bin.
The workaround I have found is to install the dependencies in each job, but I think that this is the less optimal solution.
I think that there must be a better solution for that.
Thanks.
I just found a solution, at least for python3 (enough for me):
python3 has a built-in tool for managing virtual envs: venv
Using venv, we can create the virtual env in the project root dir, cache this dir, and enable our virtual env in each job.
variables:
VENV_NAME: "env"
cache:
paths:
- $VENV_NAME
first_job:
script:
- apt-get update -qy
- apt-get install -y python3-dev python3-pip python3-venv
- python3 -m venv $VENV_NAME
- source $VENV_NAME/bin/activate
- pip3 install -r requirements.txt
next_jobs:
script:
- source $VENV_NAME/bin/activate
- echo "hello world!"
PD: don't forget to exclude virtual env dir from coverage or other analysis tools
The pipeline .gitlab-ci.yml code successfully works till yesterday, but today i got the error which says “dpl command not found”
the below is my .gitlab-ci.yml file
image: node:8.9.3
stages:
- job1
- test
- production
job1:
stage: job1
script: "ls -l"
test:
stage: test
script:
- npm install
production:
type: deploy
stage: production
image: ruby:latest
script:
- apt-get update -qy
- apt-get install -y ruby-dev
- gem install dpl
- dpl --provider=heroku --app=quailapp --api-key=$HEROKU_PRODUCTION_API_KEY
only:
- master
This is the log Generated,
Setting up rake (10.5.0-2) ...
Setting up libruby2.3:amd64 (2.3.3-1+deb9u2) ...
Setting up ruby2.3 (2.3.3-1+deb9u2) ...
Setting up ruby2.3-dev:amd64 (2.3.3-1+deb9u2) ...
Setting up ruby-dev:amd64 (1:2.3.3) ...
Setting up ruby (1:2.3.3) ...
Processing triggers for libc-bin (2.24-11+deb9u3) ...
$ gem install dpl
Successfully installed dpl-1.9.6
1 gem installed
$ dpl --provider=heroku --app=quailapp --api-key=$HEROKU_PRODUCTION_API_KEY
/bin/bash: line 68: dpl: command not found
ERROR: Job failed: exit code 1
please help me for finding the solution.
Same here, Issuing the command to install dpl with verbosity: gem install dpl --verbose I've been able to see something weird:
/usr/local/bundle/bin/dpl
Successfully installed dpl-1.9.6
1 gem installed
I don't know why but it is installed in a non-default path. As a workaround I've added the /usr/local/bundle/bin in $PATH environment variable issuing the following command:
export PATH=$PATH:/usr/local/bundle/bin
It works for me and my gitlab ci pipelines are now working again.
BTW, It would be great to know why it has changed suddenly...
Same problem here. I think, it's a problem in docker image. See https://github.com/docker-library/ruby/pull/209
They made some changes and broke path for gems binaries. We have to wait until they merge fix.
UPDATE:
It's already merged and their fix works for me.
I have a ruby script that fails the GitLab CI build with:
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- git (LoadError)
The ruby script:
require 'git'
Here's the .gitlab-ci.yml file:
image: gitlab/gitlab-ce:latest
job1:
script:
- apt-get update && apt-get -y install ruby && apt-get install git
- gem install git
- ./script.rb
I've also tried adding a gemfile with the git gem and running:
image: gitlab/gitlab-ce:latest
job1:
script:
- apt-get update && apt-get -y install ruby && apt-get install git
- gem install bundler
- bundle install
- ./script.rb
But I get the same error
So it was quite simple.
Needed to sudo the gem install:
image: gitlab/gitlab-ce:latest
job1:
script:
- apt-get update && apt-get -y install ruby && apt-get install git
- sudo gem install git
- ./script.rb