wied03 / karma-opal-rspec

Opal-RSpec Karma plugin
0 stars 0 forks source link

Travis CI stucked on `bundle install` #15

Closed merongivian closed 8 years ago

merongivian commented 8 years ago

When running travis with karma i get the following

27 01 2016 00:58:03.144:WARN [reporter]: Can not load "specjson", it is not registered!

  Perhaps you are missing some plugin?

27 01 2016 00:58:03.164:INFO [init.opal]: Getting metadata from Sprockets, this can take a while the first time

bundler: command not found: rackup

Install missing gem executables with `bundle install`

then it gets stucked on bundle install, here is my package.json :

{
  "name": "opal-music",
  "version": "0.0.1",
  "description": "create tunes with ruby in the browser",
  "main": "index.js",
  "scripts": {
    "test": "node_modules/karma/bin/karma start karma.conf.js --browsers Chrome --single-run"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/merongivian/opal-music.git"
  },
  "keywords": [
    "music"
  ],
  "author": "Jose Anasco",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/merongivian/opal-music/issues"
  },
  "homepage": "https://github.com/merongivian/opal-music#readme",
  "devDependencies": {
    "karma": "^0.13.19",
    "karma-chrome-launcher": "^0.2.2",
    "karma-opal-rspec": "^1.0.9"
  }
}

and my karma config:

// Karma configuration
// Generated on Mon Nov 09 2015 15:27:11 GMT-0700 (MST)

module.exports = function (config) {
    config.set({

        // base path that will be used to resolve all patterns (eg. files, exclude)
        basePath: '',

        // frameworks to use
        // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
        frameworks: ['opal'],

        // list of files / patterns to load in the browser
        files: [
            'spec/**/*_spec.rb'
        ],

        // list of files to exclude
        exclude: [],

        // preprocess matching files before serving them to the browser
        // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
        // TODO: https://github.com/karma-runner/karma/blob/master/test/unit/preprocessor.spec.js
        // PR to include {dot: true} on mm call

        // test results reporter to use
        // possible values: 'dots', 'progress'
        // available reporters: https://npmjs.org/browse/keyword/karma-reporter
        reporters: ['progress', 'specjson'],

        specjsonReporter: {
            outputFile: 'test_run.json'
        },

        // web server port
        port: 9876,

        // enable / disable colors in the output (reporters and logs)
        colors: true,

        // level of logging
        // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
        logLevel: config.LOG_INFO,

        // enable / disable watching file and executing tests whenever any file changes
        autoWatch: true,

        // start these browsers
        // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
        browsers: ['Chrome'],

        // Continuous Integration mode
        // if true, Karma captures browsers, runs the tests and exits
        singleRun: false,

        // Concurrency level
        // how many browser should be started simultanous
        concurrency: Infinity
    })
}
wied03 commented 8 years ago

@merongivian Did you include the dependencies from the README in your Gemfile? Rack is a dependency of sprockets and Opal depends on sprockets, so you should have rackup.

merongivian commented 8 years ago

@wied03 i have this inside the gemspec file:

  spec.add_dependency 'opal-browser'
  spec.add_dependency 'opal-audio'
  spec.add_runtime_dependency "opal", ">= 0.7.0", "<= 0.9.0"
  spec.add_development_dependency "bundler", "~> 1.9"
  spec.add_development_dependency "rake", "~> 10.0"
  spec.add_development_dependency "opal-rspec", "~> 0.5.0"
wied03 commented 8 years ago

Can you run Karma outside of Travis? In your Travis before_install section, have you tried adding bundle exec rackup --version to the before_script section and checking the output?

merongivian commented 8 years ago

@wied03 i fixed the spec-json missing package, so now it works locally, im getting this for before_script still:

0.32s$ bundle exec rackup --version

bundler: command not found: rackup

Install missing gem executables with `bundle install`

The command "bundle exec rackup --version" failed and exited with 127 during .

Your build has been stopped.
wied03 commented 8 years ago

@merongivian - A couple things:

  1. opal-rspec 0.5 isn't supported on less than Opal 0.9.1 and your gemspec says <= 0.9.0. You might want to loosen that version restriction.
  2. Your Travis config (as examined on the public github repo) is a nodejs config. There's probably not anything wrong with that but when that's the case, Travis doesn't run bundle install for you because it assumes you are not doing anything Ruby related. You need to add bundle install as a before_install or before_script command. You may need to consult the Travis documentation about ensuring a Ruby is available via RVM to run that.
wied03 commented 8 years ago

If you look at this project's Travis config, you'll see that we have a Ruby config that we add a (newer version of) nodejs on top of. You're coming at it from the opposite direction, which is fine.

merongivian commented 8 years ago

@wied03 yea indeed you were right, i had to add ruby in the travis conf.... I run into other problem though, Karma won't load other gems paths i have as dependencies, this gems are opal gems, one is opal-browser and the other os opal-audio , this is my config.ru which works when i run the tests locally on firefox:

require 'opal/rspec'
require 'opal-browser'
require 'opal-audio'

sprockets_env = Opal::RSpec::SprocketsEnvironment.new
run Opal::Server.new(sprockets: sprockets_env) { |s|
  s.main = 'opal/rspec/sprockets_runner'
  s.append_path 'opal'
  sprockets_env.add_spec_paths_to_sprockets
  s.debug = false
}

i got this error when i run karma locally, which can't find the browser file from opal-browser:

[2016-01-27 12:18:05] INFO  WEBrick 1.3.1
[2016-01-27 12:18:05] INFO  ruby 2.1.2 (2014-05-08) [x86_64-darwin13.0]
[2016-01-27 12:18:05] INFO  WEBrick::HTTPServer#start: pid=48150 port=9292
Sprockets::FileNotFound: couldn't find file 'browser' with type 'application/javascript'

Im aware this is a diferent issue :), let me know if a should open a new one

wied03 commented 8 years ago

It looks like you're hitting a case I hadn't planned for. In my case the only time I've used other opal GEMs is with Rails, in which case this Karma project boots up the rails environment and the asset paths get appended to. I opened a separate issue (#16) for that.

wied03 commented 8 years ago

@merongivian - try out a development version and see if that fixes your problem. If it does, let me know and I'll create another release. The feature is documented at https://github.com/wied03/karma-opal-rspec/blob/enhancement/16/README.md under 'Additional Requires'

To use this from github, in your package.json dependencies:

{"karma-opal-rspec": "wied03/karma-opal-rspec#enhancement/16"}
merongivian commented 8 years ago

@wied03 it worked :+1: thanks, yea let me know when u realize this, im planning to use this in other opal gems i have

wied03 commented 8 years ago

I will say this. If you have your assets in your Gemfile, Bundler will require them automatically unless you use require: false. This wouldn't be necessary in that case. I can understand though that, being a runtime dependency, you wouldn't want to duplicate those deps in the Gemfile.

wied03 commented 8 years ago

@merongivian - 1.0.10 is released. That said, I think you should be able to remove the mriRequires stuff from your Karma config because I tackled the bigger picture problem of Bundler.require