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
Related
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'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
I am trying to deploy a rails project into heroku using travis. Build is successful and tests are also passing. Deployment is also successful. but when I test the heroku app, I find that image files in my app/assets/images directory are not getting displayed in the deployed application.
Here is my .travis.yml file.
language: ruby
rvm:
- 2.2.3
gemfile:
- gemfiles/Gemfile.rails-4.2.5
env:
- DB=sqlite
script:
- RAILS_ENV=test bundle exec rake db:migrate --trace
- bundle exec rake db:test:prepare
- RAILS_ENV=test bundle exec rspec -f d
install:
- bundle install
deploy:
provider: heroku
skip_cleanup: true
app: <my app name>
api_key:
secure: <proper key>
on:
gemfile: gemfiles/Gemfile.rails-4.2.5
strategy: git
run:
- "rake db:migrate"
Can somebody help me understand why image files are missing. I can see them in my github application folder. but they are not getting deployed properly by travis to heroku.
thanks
I see you are usign Rails 4, are you sure to be setting serve_static_assets = true in production.rb?
Refer to Rails 4 images not loading on heroku.
Also, make sure to precompile your assets as you deploy from Travis CI. So add under deploy: run:
deploy:
...
run:
- "rake db:migrate"
- "RAILS_ENV=production bundle exec rake assets:precompile"
I'm using Wercker on my Ruby on Rails project. My wercker.yml looks like this:
box: ruby
services:
- postgres
build:
steps:
- script:
name: Nokogiri fix
code: bundle config build.nokogiri --use-system-libraries
- bundle-install
- rails-database-yml
- script:
name: Set up db
code: bundle exec rake db:schema:load RAILS_ENV=test
- script:
name: rspec
code: bundle exec rspec
after-steps:
- slack-notifier:
url: $SLACK_URL
channel: notifications
username: werckerbot
The problem is that wercker every time download gems with bundle install instead of get them from cache. With that my build takes almost 2 minutes instead of a few seconds... How can I fix that?
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