This document describes how to set up your workstation to develop for Code.org.
You can do Code.org development using OSX, Ubuntu, or Windows (running Ubuntu in a VM). Setup for Windows is more complicated and relatively few developers use it. Start with the instructions for your platform in the subsections below, followed by the Common Setup section.
- Install Homebrew:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- Run
sudo chown -R $(whoami):admin /usr/local/
. (Brew assumes it can write to subdirectories of /usr/local/, which not all installs of OSXallow. Running brew as root is discouraged.) brew install https://raw.github.com/quantiverge/homebrew-binary/pdftk/pdftk.rb enscript gs mysql imagemagick rbenv ruby-build coreutils sqlite phantomjs
- If it complains about an old version of
<package>
, runbrew unlink <package>
and runbrew install <package>
again - Set up MySQL
- Have launchd start mysql at login:
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
- Start mysql now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
- Set up RBENV, ruby-build, and Ruby 2.2
- Add
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
to~/.profile
or whatever profile gets sourced when you start your terminal. You should only have to do this once. - source
~/.profile
or whatever you changed in the above step. You should only have to do this once. git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
brew update
brew upgrade rbenv ruby-build
rbenv install 2.2.3
rbenv global 2.2.3
rbenv rehash
- Set up nvm
- These steps are now necessary because of problems with the newest versions of node. We want to be on node 0.12.4 and npm 2.10.1.
- Install node version manager
brew install nvm
1. follow the instructions in the output of the previous command to finish installing nvm. It should be something like this:echo "source $(brew --prefix nvm)/nvm.sh" >> ~/.bashrc
- Install the right version of node
nvm install v0.12.4
- Make that your default version
nvm alias default v0.12.4
- reinstall node_modules
cd apps; rm -rf node_modules && npm install; cd ..
(can be skipped if your version of node did not just change) - Check that you have the correct versions of everything:
- open a new Terminal window
ruby --version # --> ruby 2.2.3
nvm ls # --> v0.12.4
node --version # --> v0.12.4
npm --version # --> 2.10.1
sudo apt-get update
sudo apt-get install -y git mysql-server mysql-client libmysqlclient-dev libxslt1-dev libssl-dev zlib1g-dev imagemagick libmagickcore-dev libmagickwand-dev openjdk-7-jre-headless libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev curl pdftk libsqlite3-dev phantomjs
- Hit enter and select default options for any configuration popups
- Upgrade npm to 2.0. If
npm -v
says less than 2.0,
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
- Either A. Install Ruby 2.2 from OS packages; B. Setup
rbenv
; or C. Setuprvm
- A. OS packages (from the Brightbox Ubuntu PPA):
sudo apt-get install software-properties-common
sudo apt-add-repository ppa:brightbox/ruby-ng
sudo apt-get update
sudo apt-get install ruby2.2 ruby2.2-dev
- B.
rbenv
: (instructions)- Install
rbenv
andruby-build
rbenv install 2.2.3
rbenv global 2.2.3
rbenv rehash
- Install
- C.
rvm
. A few folks have had more luck with rvm vs rbenv on linux.- Install rvm from https://rvm.io/
rvm install 2.2.3
- A. OS packages (from the Brightbox Ubuntu PPA):
- Install Node.js 0.12.4 and npm 2.10.1
- Option A - nodesource repository
1.
curl -sL https://deb.nodesource.com/setup_0.12 | sudo -E bash -
1.sudo apt-get install -y nodejs
- Option B - Manual install 1. Nodejs.org
- Check that you have the correct versions of everything:
- open a new Terminal window
ruby --version # --> ruby 2.2.3
node --version # --> v0.12.4
npm --version # --> 2.10.1
Many Windows developers have found that setting up an Ubuntu virtual machine is less painful than getting Ruby and other prerequisites running on Windows.
- Option A: Use VMWare Player and an Ubuntu 14.04 iso image
- Option B: Use vagrant (install):
- First clone the code.org git repo to get the provided Vagrantfile (you will be able to skip step 1 of the common setup instructions):
git clone https://github.com/code-dot-org/code-dot-org.git
cd code-dot-org
vagrant up
vagrant ssh
- Goto step 2 of the common setup instructions
- First clone the code.org git repo to get the provided Vagrantfile (you will be able to skip step 1 of the common setup instructions):
- Option C: Use AWS EC2: launch Ubuntu 14.04 AMI
git clone https://github.com/code-dot-org/code-dot-org.git
sudo gem install bundler -v 1.10.6
rbenv rehash
(if using rbenv)cd code-dot-org
bundle install
rake install
rake install:hooks
(recommended, to install precommit linting hooks)rake build
sudo chown -R $(whoami) $HOME/.npm
(do we still need this step when using nvm?)
Our code is segmented into four parts:
- Blockly Core is the visual programming language platform used for the interactive tutorials.
- Blockly includes apps—blockly puzzles built based on Blockly Core.
- Dashboard, is the tutorial platform which organizes blockly levels into tutorials.
- Pegasus is the main site which also includes the teacher dashboard (support for teachers to track student progress).
cd code-dot-org
rake build:dashboard
(Generally, do this after each pull)bin/dashboard-server
- Visit http://localhost.studio.code.org:3000/
cd code-dot-org
rake build:pegasus
(Generally, do this after each pull)bin/pegasus-server
- Visit http://localhost.code.org:3000/
The studio.code.org default dashboard install includes a static build of blockly and of the shared js, but if you want to make modifications to these you'll want to enable building them in the build:
You'll need to do this once:
- OS X:
- Install the Java 8 JDK
cd code-dot-org
- To build apps/blocky-core, edit
locals.yml
to add: - Add
build_apps: true
- Add
build_blockly_core: true
(if you want to build blockly core -- not necessary if you only want to make changes to apps) - Add
use_my_apps: true
- To build shared js, edit
locals.yml
to add: - Add
build_shared_js: true
- Add
use_my_shared_js: true
rake install
This configures your system to build apps/blockly-core/shared whenever you run rake build
and to use the versions that you build yourself.
cd code-dot-org
rake build
This will build everything you have set to build in locals.yml
.
You can use rake build:apps
, rake build:blockly_core
and rake build:shared
to build a specific project.
You can also set build_dashboard: false
and/or build_pegasus: false
in locals.yml
if you don't need to build these frequently. They default to true
.
Alternatively, you can run: rake build:core_and_apps_dev
, which will build blockly core and the apps bundle without running tests and without localization.
We'd love to have you join our group of contributors! Please e-mail your areas of interest and your availability to Alice ([email protected]), and we’ll be happy to match you with a project. You can start setting up with these next steps.
-
Anyone who would like to contribute to code.org projects must read and sign the Contributor License Agreement. We can't accept pull requests from contributors who haven't yet signed the CLA.
-
Join our community development HipChat room for help getting set up, picking a task, etc. We're happy to have you! If you want to make sure you get our attention, include an @all (everyone) or @here (everyone currently in the room) in your message.
-
Get your build setup, following this README. Fork our repo and make sure to merge our staging branch in WEEKLY as we do update frequently.
Please check your PR against our tests before submitting.
Running rake lint
locally will find most Ruby warnings. For other languages see the style guide.
We support recent versions of Firefox, Chrome, IE9, iOS Safari and the Android browsers (full list of supported browsers and versions). Be sure to try your feature out in IE9, iOS and Android if it's a risk. BrowserStack live or Sauce Labs manual let you run manual tests in these browsers remotely.
For dashboard changes, be sure to test your changes using rake test
. For apps or blockly changes, see our grunt testing instructions.
Our continuous integration server regularly runs a suite of UI tests using Selenium / Cucumber which run against many browsers via BrowserStack Automate, and can also be run locally using chromedriver
. See the README in that folder for instructions.
If your changes might affect level paths, blockly UI, or critical path site logic, be sure to test your changes with a local UI test.
Contributors should follow the GitHub fork-and-pull model to submit pull requests into this repository.
- On your fork, you'll either push to your own finished branch or checkout a new branch for your feature before you start your feature
git checkout -b branch_name
- Develop the new feature and push the changes to your fork and branch
git add YYY
git commit -m "ZZZ"
git push origin branch_name
- Go to the code-dot-org GitHub page
- For your submission to be reviewed
- Click on the "Pull Request" link, look over and confirm your diff
- Submit a pull request for your branch to be merged into staging
- For bonus points, include screenshots in the description. Command + Ctrl + Shift + 4 in OS X lets you copy a screen selection to your clipboard, which GitHub will let you paste right into the description
- After your pull request is merged into staging, you can review your changes on the following sites: