How do you setup heroku_san with Sinatra? - deployment

For example how do you push code to specific heroku application using the heroku_san rake shortcut commands, eg.
rake otherapp heroku:push
(taken from http://jqr.github.com/2010/08/27/easy-heroku-deploys-with-heroku-san.html )
I keep getting:
rake aborted!
Don't know how to build task 'otherapp'
I have a config directory under my sinatra app. And this contains a heroku.yml as mentioned in the above guide. The file looks like this
apps:
production: mycoolherokuapp
otherapp: myotherherokuapp
I have otherapp already created on heroku.

heroku_san is Rails specific.
If you look at the lib code it uses: Rails.root.join, RAILS_ENV, Rails.configuration, and Railtie throughout.

I'm working on a fork of heroku_san that will (eventually) remove the coupling between Rails & heroku_san. Right now, I'm working on making a testable class. https://github.com/kmayer/heroku_san -- try it out and send me some feedback.

Ken actually completed the Sinatra compatibility code and just released version 3.0.0 which includes Sinatra support.
Update your Gemfile:
group :development do
gem 'heroku_san'
end
Update your Rakefile:
require "bundler/setup"
require "heroku_san"
config_file = File.join(File.expand_path(File.dirname(__FILE__)), 'config', 'heroku.yml')
HerokuSan.project = HerokuSan::Project.new(config_file, :deploy => HerokuSan::Deploy::Sinatra)
load "heroku_san/tasks.rb"
See documentation at https://github.com/fastestforward/heroku_san

Related

Symfony4 Deployment with Encore

The current documentation says, that I only need the files under public/build, created with ./node_modules/.bin/encore production, when I want to deploy for production. But also to add public/build to git ignore. Do I have to copy the content of public/build manually?
In Symfony3 my deploy looked like that:
git pull
bin/php bin/console cache:clear --env=prod --no-debug
bin/php bin/console assets:install --env=prod
bin/php bin/console assetic:dump --env=prod --no-debug
FYI, Using assetic was the »old« way, and starting Symfony 2.8 Assetic is not included in the standard framework anymore (but you can still add it).
Regarding public/build you misunderstood it a bit - the actual source files should be somewhere else, for example in assets/css/app.scss and assets/js/app.js. Using Webpack Encore, running ./node_modules/.bin/encore production will minify, uglify, etc (whatever you configure in webpack.config.js) these source files and then copy the generated files to public/build. So public/build will only contain the generated stuff and thus can be safely added to .gitignore (but you also need to run the encore script in production).
Your JavaScript file (i.e. in this case app.js) should include
require('../css/app.scss');
so that the app.scss is actually a dependency of app.js and you only need to tell the webpack.config.js to include the JavaScript file. The basic configuration of webpack.config.js might look like this:
// webpack.config.js
var Encore = require('#symfony/webpack-encore');
Encore
// this will put all your compiled stuff into public/build, that’s
// why you can put this into .gitignore, because you can re-build this
// from the source files.
.setOutputPath('public/build/')
// the public path used by the web server to access the previous directory
.setPublicPath('/build')
// this will create public/build/app.js, and also public/build/app.css
// since the scss file is a dependency of app.js
.addEntry('app', './assets/js/app.js')
// allow sass/scss files to be processed
.enableSassLoader()
[...]
;
// export the final configuration
module.exports = Encore.getWebpackConfig();
You can find some more explanation under https://symfony.com/doc/current/frontend/encore/simple-example.html (first example) or https://symfony.com/doc/current/frontend.html (overview)

React Redux 'npm run deploy' app not working

I'm having some issues when trying to deploy a simple react + redux app.
I'm using the react redux starter kit
When running the app in development npm run dev:nw all is good, the this.props.startTimer() function in componentWillMount() fires and updates the state in intervals in the module. Everything just works.
When i deploy the app with npm run deploy i get no errors and all seems to work without problems.
app:config Create configuration. +0ms
app:config Apply environment overrides for NODE_ENV "production". +3ms
app:webpack:config Create configuration. +839ms
app:webpack:config Enable plugins for production (OccurenceOrder, Dedupe & UglifyJS). +2ms
app:webpack:config Apply ExtractTextPlugin to CSS loaders. +69ms
app:bin:compile Run compiler +4ms
app:build:webpack-compiler Webpack compile completed. +14s
app:build:webpack-compiler Hash: ce8ff073e185128cb7b1
Version: webpack 1.12.9
Time: 13543ms
Alot of react/babel/redux built messages folllows. Finally the output ends with
app:build:webpack-compiler No errors or warnings encountered. +2ms
app:bin:compile Copy static assets to dist folder. +0ms
I navigate to http://domain/dist , page shows up looking just as in dev, but the this.props.startTimer() won't fire as it did just fine in development, nothing happens. The scripts are there and all looks just fine but nothing happens.
What could be causing this?
I've tried setting NODE_ENV to both base, development & production.
No changes.
In need of help
The issue was a misconfigured nginx that didn't handle the dist/ folder properly. Moved the content to the document root and it worked.

How can I fix tests in Ember testem with errors such as 'could not load', 'failed', 'could not find module' or 'died'?

I managed to get a couple of EAK/grunt based Ember apps upgraded to 1.11 with HTMLBars, and then got them migrated to Ember CLI/Brocolli. The unit tests were setup for karma test runner so I'm looking at how to get those running in the CLI projects now, but I didn't write the tests and really have no experience with unit testing javascript modules.
Searching around the iNet, I can see that others have also used karma becasue of its coverage output and are trying to get it to work with Ember CLI, but that Ember Core isn't supporting it, though they say anyone should be able to get it set up with a custom addon. I'm also trying to use the 'testem' runner to see what sticks with that.
The Ember site does have an 'automating tests with runners' page for v1.10, with sections on 'testem' and 'karma', but it doesn't appear for v1.11 so I can't tell from that site what is or isn't relevant. But it seems like I should be able to work out a solution for the karma test runner, so I added the old devDependencies to the project package.json:
"karma": "^0.12.31",
"karma-chai": "~0.1.0",
"karma-chrome-launcher": "~0.1.2",
"karma-coverage": "~0.2.1",
"karma-firefox-launcher": "~0.1.3",
"karma-junit-reporter": "~0.2.1",
"karma-mocha": "~0.1.3",
"karma-phantomjs-launcher": "~0.1.2",
"karma-sinon-chai": "~0.1.5"
I also dropped the old 'karma.conf.js' (along with a few other karma confs) in the project and updated the paths inside (from 'vendor' to 'bower_components'). I did find a 'ember-cli-karma' node mode and installed it, but it seems to just have a 'package.json'. It has no docs and seems like just a stubbed out starter project with no implementation. I also installed 'karma', 'karma-cli' and 'testem' node modules.
The testem docs say to add you src and test files to 'testem.json', but with out examples I don't know what that means; a list of every src and test file? With what path; relative, absolute? Forward slashes, backslashes? preceded with / or ./ or ../? I just left them out because I think the system just finds the src and tests by convention.
When I run 'karma init' I get:
readline.js:529
this.line = this.line.slice(this.cursor);
^
TypeError: Cannot read property 'slice' of undefined
When I run 'testem' I get:
TEST'EM 'SCRIPTS!
Open the URL below in a browser to connect.
http://localhost:7357/aN;0faN;NaNf
...then the project's '../tests/index.html' loads in a browser, but is not able to 'find' any of the asset files (css, js) so nothing executes or renders correctly. I just see template expressions ({{content-for 'head'}}, etc).
When I run 'ember test' I get:
Building...BuildingBuilding.Building..Building...Built project successfully.
1..0
# tests 0
# pass 0
# fail 0
# ok
No tests were run, please check whether any errors occurred in the page (ember test --server) and ensure that you have a test launcher (e.g. PhantomJS) enabled.
When I run 'ember test --server' I get:
The test index.html loaded in a browser with a test report. When I uncheck 'hide passed tests' the report indicates '29 passed, 28 failed'. It has 11 sections where a particular test may have 3 problems such as 'could not load', 'failed', 'could not find module', 'attempting to register an unknown factory' or 'died'.
With this, I'm obviously running testem and not karma, so may as well work on getting testem working and figure out karma later. If there were more examples and migration troubleshooting docs I might have a systematic way to work through some of these problems.
I ran into "No tests were run,..." problem recently after a node upgrade. I fixed it with a:
npm install -g phantomjs
This provides some additional options as well:
https://github.com/ember-cli/ember-cli/issues/3969
I had the Cannot read property 'slice' of undefined error on MS Windows, running via MSys2. I have solved it by using karma init from an ordinary cmd prompt.

How to configure PHPUnit with ZF version 1.12.11

I am using zend framework 1.12.11 and now I want to use PHPunit with it.Pear has stopped it's stopped support for phpunit.Now it's working with composer.
I have install composer and phpunit via composer.But Where I have to put composer json setting file and my project and what should include in my project which automatically take phpunit of composer
Per the PHPUnit documentation for Composer installation, add PHPUnit to the dependencies in your project's composer.json file, something like:
{
"require-dev": {
"phpunit/phpunit": "4.6.*"
}
}
Then run:
composer update -vvv phpunit/phpunit
to actually bring PHPUnit and its dependencies down into your project.
I usually add the -vvv (maximally verbose) flag to see what's going on under the hood. Feel free to omit if you prefer.
Once they are all installed, you can run phpunit the usual way by accessing the executable bin script that PHPUnit and Composer expose for you. From the project root, you should be able to run:
./vendor/bin/phpunit --version
to confirm the install is ok.
Once you have a phpunit.xml config file set up that your test suites and directories, you should be able to run your tests using:
./vendor/bin/phpunit -c /path/to/phpunit.xml

my coffeescript file compiles but mocha gives an error

I have a project that uses "coffee-script": "^1.7.1" in its package.json.
The code has this line in it:
[{id: id, name: name}, ...] = result.rows
This compiles fine using coffeescript version 1.7.1
The problem is that I am trying to use mocha for unit tests and it gives me an error on this line:
Parse error on line xyz: Unexpected '...'
Apparently mocha uses an older coffeescript. Is there a way to make it work without adjusting the source for mocha?
EDIT:
my Gruntfile.coffee:
'use strict'
module.exports = ->
#initConfig
cafemocha:
src: ['test/*.coffee']
options:
reporter: 'spec'
ui: 'bdd'
coffee:
compile:
files:
'lib/mylib.js': ['src/*.coffee']
#loadNpmTasks 'grunt-cafe-mocha'
#loadNpmTasks 'grunt-contrib-coffee'
#registerTask 'default', ['coffee', 'cafemocha']
I added mocha.opts to the test directory:
--require coffee-script/register
--compilers coffee:coffee-script/register
--reporter spec
--ui bdd
but, still, when I run grunt, it gives me the same error. I am new to this environment, and I find it too complicated, please help.
Starting from version 1.7.x CoffeeScript compiler should be explicitly registered (see change log for version 1.7.0).
So, the problem is that CoffeeScript compiler is not registered when you're running your mocha tests, so node.js treats all your .coffee files as .js files.
The best possible solution is to specify --compilers option for your mocha tests:
--compilers coffee:coffee-script/register
If you don't want to include it to every mocha call, you could set it up using mocha.opts file.
Here are some useful links:
issue about it on github
reference in mocha docs
the reason behind this breaking change in CoffeeScript engine
Update
Looks like your issue is much deeper then I thought.
First, grunt-cafe-mocha doesn't respect mocha.opts because it's running tests by requireing mocha as a dependency, instead of calling mocha test runner.
So, it would've been enough to add require('coffee-script/register') to the top of your gruntfile, if not for this old grunt issue.
In short, grunt uses coffee-script 1.3.x, forcing all its tasks to use the same version of coffee. I had the same problem with grunt-contrib-connect, being unable to use latest coffee-script in my express app.
So, the only help I can offer you is a small grunt task I wrote to solve similar problem in one of my projects. It runs mocha in a separate child process, thus completely isolating it from grunt.
N.B. I had a thought about releasing this task to npm, but considered it too minor.