I'm running into a problem when I try to run some tests using appium through CircleCI. I want to test a web app through CircleCI using xcode to host the simulator. I know CircleCI allows you to build an OSX environment. But I was wondering if there was another way to test it without needing to build the OSX through CircleCI.
Here is the error that I'm getting when I run the tests through Appium on CircleCI:
.1) Failure/Error: page.set_rack_session(hash)
Selenium::WebDriver::Error::UnknownError:
An unknown server-side error occurred while processing the command. Original error: Could not find path to Xcode by symlinks located in /var/db/xcode_select_link, or /usr/share/xcode-select/xcode_dir_link
If anyone knows what's going on here, please point me in the right direction. Thanks!
circle.yml
machine:
node:
version: 0.12
xcode:
version: 7.3
ruby:
version: 2.3.0
pre:
- wget http://chromedriver.storage.googleapis.com/2.22/chromedriver_linux64.zip
- unzip chromedriver_linux64.zip
- sudo mv -f chromedriver /usr/local/bin
database:
override:
- mv ci/database.yml config/database.yml
- bundle exec rake db:create db:schema:load --trace
dependencies:
pre:
- gem install bundler
- npm install appium
test:
pre:
- appium:
background: true
override:
- CI_NAME=circle_ci RAILS_ENV=test bundle exec rake mobile nodes=4 --trace:
parallel: true
Related
I am trying to upgrade my rails app to run in the latest Ubuntu environment for GitHub Workflows (https://github.blog/changelog/2022-08-09-github-actions-the-ubuntu-18-04-actions-runner-image-is-being-deprecated-and-will-be-removed-by-12-1-22/).
I've upgraded my workflow yaml file as follows:
name: Precompile assets
"on": [push]
jobs:
compile:
runs-on: ubuntu-latest
However when this flow runs I get the following error:
Run bundle exec rails assets:precompile
bundle exec rails assets:precompile
shell: /usr/bin/bash -e {0}
rails aborted!
LoadError: libmysqlclient.so.20: cannot open shared object file: No such file or directory - /home/runner/work/platform/platform/vendor/bundle/ruby/2.7.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.so
I also get this error if I specify ubuntu-20.04 or ubuntu-22.04 as well. Reverting the Ubuntu version back to 18.04 resolves the issue however with this version being deprecated I'd really like to upgrade. Has anyone seen this before?
For context I'm running ruby 2.7.2 with rails 6.0.3.4, the mysql2 gem is 0.5.3
I built a new rails app and when I have configured the .travis.yml file it exits with one all the time.
Here is my travis configuration:
language: ruby
node_js:
- 12
cache:
bundler: true
yarn: true
services:
- redis-server
sudo: required
before_install:
- sudo apt-get update
- sudo apt-get install google-chrome-stable
addons:
postgresql: '9.6'
before_script:
- psql -c 'create database product_hunt_clone_test;' -U postgres
script:
- bundle install
- bundle exec rake db:schema:load
- bundle exec rake db:test:prepare
- SECRET_KEY_BASE=a RAILS_ENV=production bundle exec rake assets:precompile
- bundle exec rake test
- bundle exec rake test:system
and here are the errors travis is giving me:
screenshot from travis console
You have apparently create the initial application using the --skip-sprockets parameter. As such, you have disable the use of the assets pipeline in your application and with that have disable the need (and possibility) to run rake assets:precompile.
If you do need assets pipeline (and thus the rails-sprockets gem), you can re-enable it by adding
gem "sprockets-rails"
to your Gemfile and uncommenting the line
# require "sprockets/railtie"
in your config/application.rb file. You would also need to create the asset files as necessary. Please refer to the documentation for the assets pipeline for details.
If you actually want to skip the assets pipeline, you can just remove the call to the assets:precompile task from your .travis.yml.
Are you correctly installing your gems (with bundle install) before executing your rake commands? Seems like you would need sprockets before compiling the assets.
I struggle setting up Wercker on a rails / Webpacker project.
I first had to add steps to install node, then another to pre-compile react packs, then to install yarn. First it was good but then I added dependencies to the project and know I'm stuck on 3 dependencies with the same error message :
ERROR in ./app/javascript/app/index.js
Module not found: Error: Can't resolve 'redux-thunk' in '/pipeline/source/app/javascript/app'
# ./app/javascript/app/index.js 5:0-32
# ./app/javascript/packs/app.js
That's happening only with redux-thunk, react-redux-i18n and react-spinkit
I've tried to add a step yarn install which passes through the process but doesn't solve the problem.
Here is my wercker.yml:
# wercker.yml
box: ruby:2.4.1
services:
- redis
- postgres
build:
steps:
- louischavane/install-phantomjs#0.0.5
- rails-database-yml
- script:
name: nokogiri tricks
code: bundle config build.nokogiri --use-system-libraries
- bundle-install
- bigtruedata/install-node#2.1.1
- akupila/yarn#0.2.0
- script:
name: yarn-install
code: yarn install
- script:
name: pre-compile react packs
code: NODE_ENV=test bundle exec rails webpacker:compile
- script:
name: run migration
code: rake db:migrate RAILS_ENV=test
- script:
name: load fixture
code: rake db:fixtures:load RAILS_ENV=test
- script:
name: run rubocop
code: bundle exec rubocop
- script:
name: test
code: bundle exec rake test RAILS_ENV=test
Found a way around adding a step to remove node modules before pre-compiling :
- script:
name: delete node modules
code: rm -rf node_modules
UPDATE
I now have a clean Wercker setup handling tests, system tests with chrome headless, rubocop, eslint and stylelint. You can find it here: https://gist.github.com/adesurirey/7c013bfa1a9bed9d56ffea54db5d6288
The protractor configuration and scripts work as expected both on our local development environment and in a continuous integration environment (similar to Codeship).
The project structure is the following (I'm describing the Codeship env. status below):
The AngularJS app requests data from the REST API build with the Ruby on rails app, using AJAX requests.
In our Codeship configuration we set up the rails app, migrate and seed the database so that all necessary data is available.
The AngularJS app is also configured correctly since the login page is rendered as expected (I'm doing a print screen, and the main page is loaded correctly).
The usename and password are filled in by protractor using valid credentials (available in the mysql DB).
But when clicking the 'Log In' button the returned response from the AJAX call is a 405 Method Not Allowed.
As we never encountered this response in our other environments we believe it has something to do with the specific codeship setup.
Any thoughts why the API would return 405 only on Codeship?
The setup is below:
rvm use 2.2.0 --install
cp config/database.codeship.yml config/database.yml
bundle install
export RAILS_ENV="test"
bundle exec rake db:drop RAILS_ENV=test
bundle exec rake db:create RAILS_ENV=test
bundle exec rake db:test:prepare
bundle exec rake db:migrate RAILS_ENV=test
bundle exec rake seed:migrate RAILS_ENV=test
cd frontend && npm install && cd ..
npm install -g grunt-cli
npm install -g http-server
cd frontend && npm install bower && cd ..
cd frontend && bower install && cd ..
cd frontend && grunt build && cd ..
cd frontend && webdriver-manager update --standalone && cd ..
export RAILS_ENV="development"
rake db:structure:load
rake seed:migrate
http-server public -a 127.0.0.1 -p 9000 > /dev/null &
http-server app > /dev/null &
bundle exec rake
cd frontend && grunt test && cd ..
Here is the part of the screenshot that shows the API response:
In the end, the solution for us was to use protractor-rails
- basically using the base url of the rails server instead of trying to run the app on a different URL through grunt. Our setup now looks like this:
rvm use 2.2.0 --install
cp config/database.codeship.yml config/database.yml
bundle install
# protractor tests
export RAILS_ENV="development"
rake db:structure:load
rake seed:migrate
npm install
webdriver-manager update
bundle exec rake protractor:init RAILS_ENV=development
bundle exec rake protractor:spec RAILS_ENV=development
# rails tests
bundle exec rake db:test:prepare
bundle exec rake db:migrate RAILS_ENV=test
bundle exec rake seed:migrate RAILS_ENV=test
bundle exec rake
I have a rails project and am running tests for my JavaScript test (Jasmine) through Karma
.travis.yml file
language: ruby
rvm:
- 2.0.0
script:
- RAILS_ENV=test bundle exec rake --trace db:migrate test
- karma start --single-run --browsers PhantomJS test/karma/config/unit.js
Travis fails saying it does not find karma. is there a way to define node_js as another language and install karma on the build VM?
It is not possible yet to have several languages on travis configuration file.
On the other hand, all environments run node.js. The following script does the trick:
language: ruby
rvm:
- 2.0.0
before_script:
- npm install karma
script:
- RAILS_ENV=test bundle exec rake --trace db:migrate test
- karma start --single-run --browsers PhantomJS test/karma/config/unit.js
Help found on an old thread in a google group
K-Yo's answer got me moving in the right direction, but far short of success. Here is what I needed:
First in my .travis.yml:
language: ruby
rvm:
- 2.1.1
before_script:
- psql -c 'create database spokenvote_test;' -U postgres
- cp config/database.travis.yml config/database.yml
- rake db:test_prep
- npm install karma
- npm install karma-jasmine
- npm install karma-coverage
- npm install karma-phantomjs-launcher
- npm install karma-coffee-preprocessor
script:
- bundle exec rspec spec # basic for ruby
- node_modules/karma/bin/karma start config/karma.conf.js --single-run --browsers PhantomJS
Then I also placed this code in my package.json, though I'm not sure if it was needed:
"devDependencies": {
"karma": "~0.12",
"karma-jasmine": "~0.2",
"karma-coverage": "~0.2.6",
"karma-phantomjs-launcher": "~0.1.4",
"karma-coffee-preprocessor": "~0.2.1"
},
Finally, I learned that Travis is case sensitive, so:
'bower_components/jquery/dist/jquery.min.js',
in my karma.conf.js needed to be:
'bower_components/jQuery/dist/jquery.min.js',
When the language key in .travis.yml is set to node, Travis will run nvm install 0.12 at the beginning of the build. Similarly, for a Ruby project, Travis will run rvm use 2.2.2 --install --binary --fuzzy at the beginning of the build.
I've had success running both commands in a Bash build