If you're not a developer, please go away now.
- We use branch-per-feature for development, so that master is always
clean and ready to deploy. NEVER PUSH MASTER THAT HAS FAILING TESTS.
EVER. See below for how to run tests. The main repo is
ucberkeley/moocchaton GitHub. - We use Pivotal Tracker to track features, bugs, releases, etc.
- Branch naming convention is
feature/XX/name-of-feature(where XX are initials of developer, eg "AF") for new features,bug/XX/description-of-bugfor bug fixes,test/XX/description-of-testfor changes that add test coverage, etc. - We are using CodeClimate to monitor our code quality
Google OAuth2 is used to enforce that only Instructors and Administrators may administer content. To make someone an instructor or administrator:
- Make sure the
typefield (i.e. subclass) of their entry in theuserstable is set to eitherInstructororAdministrator - Make sure they have a nonblank
emailattribute that exactly matches their Google email address.
Currently this must be done manually.
In production, you must setup a Google OAuth2 API
key and enable Google+ and Google Contacts on your Heroku
deployment, and wait
a few minutes for the changes to take effect on Google's side.
You must also set environment variable GOOGLE_CLIENT_ID to the OAuth2 client ID
provided by Google and GOOGLE_CLIENT_SECRET to the client secret
provided by Google for that key. (On Heroku, you do this
on the app's Settings page.) In addition, on the
Google settings for that API key, the
"Redirect URI" must be
https://your-app-name.herokuapp.com/auth/google_oauth2/callback.
In development, Google OAuth2 is turned off, and the "Google Login" button is replaced by a "Dev Mode Login" button. On the login form, enter your name and email exactly as they'd appear if you were authenticating with Google, and you'll be logged in.
For testing (Cucumber scenarios), if your scenario specifically
deals with testing authentication directly, give it the tag
@auth_test. You will then have to create OmniAuth mocks to simulate
the desired result of an authentication transaction; see
features/step_definitions/auth_steps.rb for an example. All
scenarios WITHOUT this tag will be preceded by a Before action (see
features/support/env.rb) that simulates an admin login, so these
scenarios can assume that an admin is logged in.
For testing (RSpec controller tests): TBD
sudo apt-get update && sudo apt-get upgrademkdir .ssh- Install your SSH key for Github in
~/.ssh/id_rsa chmod 600 ~/.ssh/id_rsasudo apt-get install git curl libpq-dev phantomjs chromium-chromedriver python-selenium nodejs postgresql default-jresudo ln -s /usr/lib/chromium-browser/chromedriver /usr/bin/chromedriversudo ln -s /usr/lib/chromium-browser/libs/lib*.so /usr/lib/sudo su postgres -c psql(this will enter the postgres environment where you will set up the database)CREATE USER yourusername CREATEDB;(use your UNIX username in place ofyourusername)\q(to exit postgres)curl -sSL https://get.rvm.io | bashsource ~/.rvm/scripts/rvmgit clone git@github.com:ucberkeley/moocchat.gitcd moocchatrvm install ruby-1.9.3-p547 --disable-binarybundle installmake checkforeman run local- Access http://localhost:3000 in a web browser to try the app.
- Clone this repo
- Change into app's root directory
- Run
bundle installto make sure you have all gems/libraries - Install PhantomJS to run JavaScript tests headlessly:
- Mac OS with homebrew:
brew install phantomjs - Other cases: download here
- Install Google Chrome and
chromedriverfor certain Cucumber tests that require it: - Mac OS with homebrew:
brew install chromedriver - Mac OS without homebrew, or other platforms:
Download here, but in general, after downloadsudo mv chromedriver /usr/bin/andsudo chmod +x /usr/bin/chromedriver; - Run
make check(that's make, not rake) to create development database, populate its schema, insert any initial data, and run regression tests to make sure all is well (see below under Deploying) foreman run localto start the app- It should now be live on
http://localhost:3000
- Before you do any merging: go back to master and do a git pull to make sure you have latest master
- Then switch back into your branch and rebase against master, fixing any conflicts, and making sure all your tests are passing.
- Running
make checkwill run the following, which "clean-tests" your branch:
rm -rf tmp/ # deletes any cached assets
rake db:schema:load # recreates fresh set of empty tables in DB
rake db:seed # loads fixed data
rake db:test:prepare # loads DB schema into test database
rake cucumber # runs all scenarios
rake spec # runs all specs, including javascriptto verify that there is no bug introduced 0. Then do pull request on your rebased branch
- Install the Heroku tools as instructed here: https://toolbelt.heroku.com
- First time:
heroku apps:create pick-some-app-name(or to use the existing moocchat deployment,heroku git:remote -a moocchat) - Make sure your changes are committed locally
git push heroku master- The first time you deploy, you must also
heroku run rake db:migrateto setup the database, andheroku run rake db:seedto populate it with necessary initial data. (Warning: thedb:seedtask wipes the database before re-seeding it, so don't use it if you want to preserve existing data!) - Your app should now be live at
http://pick-some-app-name.herokuapp.com - If you get an application failed error message, try 'heroku run rake db:migrate' then refresh page
- You can add tests in
spec/javascripts/*.jsor*.js.coffee - To run tests with browser GUI: start the app locally (
foreman start) then go tohttp://localhost:5000; each time you re-load this page, it re-runs all your JS specs - To run tests from command line:
rake spec:javascript(usesphantomjs)
Do not push code that causes these tasks to fail!
git push heroku masterdeploys on Heroku; don't push code that cannot be deployedrake diagram:allcreates three.svgpicture files indoc/that contain the app's class diagrams. The most interesting is probablydoc/models_complete.svgrake specruns all unit and functional testsrake spec:javascriptruns all JavaScript tests in headless moderake cucumberruns all features that should pass (user stories)rake metrics:allgenerates a bunch of metrics; to see them, open./tmp/metric_fu/output/index.htmlin a browser after running this command- CodeClimate code quality for this project
The app is hosted on Armando's Heroku account as
moocchat.herokuapp.com.
We have extended monitoring
turned on to help troubleshoot system load issues. heroku logs --tail
shows them.
NewRelic APM (application performance monitoring) is turned on. In
the app's Heroku resources
dashboard,
click New Relic.
- open moocchat/benchmark/chatserver/groups.py and modify number and size accordingly. number is total number of alive websockets at at the same time. size is size of a chat group.
- cd into moocchat/benchmark/chatserver/result
- run python ../groups.py
- result of load testing will be stored in moocchat/benchmark/chatserver/result. Scroll to the bottom of this file to for "Finish a total of: " to see total number of websockets successfully kept alive at the same time.