Development:Setup:OSX: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
 
(33 intermediate revisions by 3 users not shown)
Line 3: Line 3:
* You must have root access (via sudo), or the required software must already be installed
* You must have root access (via sudo), or the required software must already be installed
==Install Git==
==Install Git==
[Git for OS X http://git-scm.com/download/mac]
[http://git-scm.com/download/mac Git for OS X]


==Get Expertiza==
==Get Expertiza==
====Expertiza Repository URLs====
====Fork Expertiza to your Github====
* If you don't have a Github account, register one, and remember the password!!
* go to https://github.com/expertiza/expertiza and click on the "Fork" button on the upper right side.
* When asked "Where should we fork this repository?" choose your account, which usually looks like this "@YourUsername"
* Then go to https://github.com/[YourUsername]/expertiza and click on the "Clone or Download" button
* Copy the url, which usually looks like "https://github.com/[YourUsername]/expertiza.git"
* Then go to your terminal and go to a folder of your choice where the codes will be downloaded into.
* To clone the project, type in "git clone https://github.com/[YourUsername]/expertiza.git"
* when asked for a password, enter your password
 
====Merge your changes to Expertiza====
* When you're done editing the code, commit the code to your local repository by executing this in terminal:
** git add -A #mark all changed files to be committed to the repository
** git commit -m "say what you have done to the code"  #commit your changes to the local repository
** git push #sync your changes to the remote repository
* Do commit as often as needed to store the states of the code. Do commit before you do changes that you're not sure about. It'd allow you to revert back to your previous states if you screw up the code.
* Do push less often (maybe every 5-10 commits)
* Before requesting for a merge, please refactor your code and put comments. Bad code won't be merged!
* After you're done with beautifying your project, go to https://github.com/[YourUsername]/expertiza, and click on "New pull request" on the left side.
* Your code will be reviewed and merged if the quality is good enough!
 
====[DEPRECATED. DO NOT USE UNLESS ADVISED]====
=====Expertiza Repository URLs=====
* (ssh, read/write) git@github.com:expertiza/expertiza.git
* (ssh, read/write) git@github.com:expertiza/expertiza.git
* (https, read/write) https://github.com/expertiza/expertiza.git
* (https, read/write) https://github.com/expertiza/expertiza.git
* (git, read-only) git://github.com/expertiza/expertiza.git
* (git, read-only) git://github.com/expertiza/expertiza.git
====Default====
=====Default [DEPRECATED]=====
<pre style="white-space:normal;">git clone <remote></pre>
<pre style="white-space:normal;">git clone <remote></pre>
<pre style="white-space:normal;">git clone git@github.com:expertiza/expertiza.git</pre>
<pre style="white-space:normal;">git clone git@github.com:expertiza/expertiza.git</pre>
====Options====
=====Options =====
<pre style="white-space:normal;">git clone -b <branch> <remote></pre>
<pre style="white-space:normal;">git clone -b <branch> <remote></pre>
<pre style="white-space:normal;">git clone -b production git@github.com:expertiza/expertiza.git</pre>
<pre style="white-space:normal;">git clone -b production git@github.com:expertiza/expertiza.git</pre>


==Install RVM==
==Install Homebrew==
[https://rvm.io/rvm/install/ RVM Install]
http://mxcl.github.io/homebrew
====Single User Mode (Recommended)====
<pre style="white-space:normal;">\curl -L https://get.rvm.io | bash -s stable</pre>
=====Load RVM as a Function=====
<pre style="white-space:normal;">source ~/.rvm/bin/rvm</pre>


====Multi User Mode====
==Install RBENV==
<pre style="white-space:normal;">\curl -L https://get.rvm.io | sudo bash -s stable</pre>
<pre>
=====Load RVM as a Function=====
$ brew update
<pre style="white-space:normal;">source /etc/profile</pre>
$ brew install rbenv
$ brew install ruby-build
</pre>


====Post-Installation====
==Install Ruby v. 2.1.5==
=====Is RVM a Function?=====
https://github.com/sstephenson/ruby-build/wiki#installing-187-on-os-x-108-mountain-lion
<pre style="white-space:normal;">$ type rvm | head -1
rvm is a shell function</pre>
If not, try loading RVM as a function again. If it is still not a function, try reinstalling RVM.
 
=====Make sure all the dependencies are met for RVM=====
<pre style="white-space:normal;">rvm requirements</pre>
This will show a yum command. Run it to install the dependancies for Ruby.
For example:
<pre style="white-space:normal;">sudo yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison iconv-devel</pre>
 
==Install Ruby v. 1.8.7==
<pre style="white-space:normal;">rvm install 1.8.7</pre>
<pre style="white-space:normal;">rvm use 1.8.7</pre>
 
==Create Expertiza Gemset (optional)==
<pre style="white-space:normal;">rvm use 1.8.7</pre>
<pre style="white-space:normal;">rvm gemset create expertiza</pre>
<pre style="white-space:normal;">rvm use 1.8.7@expertiza</pre>
====Create a .rvmrc File (optional)====
<pre style="white-space:normal;">echo 'rvm use 1.8.7@expertiza' > .rvmrc</pre>


==Install Native Expertiza Dependencies==
==Install Native Expertiza Dependencies==
Dependencies are for the gems raspell, rjb, nokogiri, and mysql.
Dependencies are for the gems raspell, rjb, nokogiri, and mysql.
<pre style="white-space:normal;">sudo yum install aspell-devel java-devel gcc ruby-devel libxml2 libxml2-devel libxslt libxslt-devel mysql-devel mysql-server graphviz</pre>
<pre style="white-space:normal;">brew install aspell gcc47 libxml2 libxslt graphviz openssl</pre>


==Install Bundled Gems==
==Install Bundled Gems==
Set JAVA_HOME for the rjb gem:
Set JAVA_HOME for the rjb gem (set it to a valid location, your path may vary):
<pre style="white-space:normal;">export JAVA_HOME=/etc/alternatives/java_sdk</pre>
<pre style="white-space:normal;">export JAVA_HOME=/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/</pre>
 
<pre style="white-space:normal;">bundle install</pre>
<pre style="white-space:normal;">bundle install</pre>
Possible alternate step if _bundle install_ command has build errors:
<pre>
$ bundle config build.eventmachine --with-cppflags=-I/usr/local/opt/openssl/include
$ brew install apple-gcc42
$ brew unlink apple-gcc42
$ brew link apple-gcc42
$ export CC=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2
$ export CXX=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/g++-4.2
$ export CPP=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/cpp-4.2
</pre>


==Set Up the Database==
==Set Up the Database==
====Enable and Start the MySql Daemon====
<pre style="white-space:normal;">sudo service mysqld enable</pre>
<pre style="white-space:normal;">sudo service mysqld start</pre>
====Set the MySql Root Password====
====Set the MySql Root Password====
This step is not necessary, but it is advised to set a root mysql password.
<pre style="white-space:normal;">mysqladmin -u root password</pre>
<pre style="white-space:normal;">mysqladmin -u root password</pre>
====Log in to MySql====
 
====Run SQL script to scrub DB====
Here is the link of Expertiza scrubbed DB (https://drive.google.com/a/ncsu.edu/file/d/0B2vDvVjH76uEMDJhNjZVOUFTWmM/view?usp=sharing)
Download the file, unzip it and dump to MySQL.
<pre style="white-space:normal;">mysql -uroot -p -h localhost < expertiza_scrubbed.sql</pre>
 
=====Log in to MySql=====
<pre style="white-space:normal;">mysql -uroot -p</pre>
<pre style="white-space:normal;">mysql -uroot -p</pre>
The following commands are executed inside mysql
The following commands are executed inside mysql
====Create the Expertiza User====
 
=====Create the Expertiza User=====
<pre style="white-space:normal;">create user expertiza@localhost;</pre>
<pre style="white-space:normal;">create user expertiza@localhost;</pre>


====Create the Databases====
=====Create the Databases=====
<pre style="white-space:normal;">create database pg_development;</pre>
<pre style="white-space:normal;">create database expertiza_development;</pre>
<pre style="white-space:normal;">create database pg_test;</pre>
<pre style="white-space:normal;">create database expertiza_test;</pre>
====Grant Privileges to the Expertiza User====
 
<pre style="white-space:normal;">grant all on pg_development.* to expertiza@localhost;</pre>
=====Grant Privileges to the Expertiza User=====
<pre style="white-space:normal;">grant all on pg_test.* to expertiza@localhost;</pre>
<pre style="white-space:normal;">grant all on expertiza_development.* to expertiza@localhost;</pre>
<pre style="white-space:normal;">grant all on expertiza_test.* to expertiza@localhost;</pre>
 


==Build the Expertiza Database==
==Build the Expertiza Database==
First, you have to copy the sample database config to a real one.
<pre style="white-space:normal;">cp config/database.yml.example config/database.yml</pre>
Then edit the file and put your mysql password in there so it can log into the db
<pre style="white-space:normal;">vi config/database.yml</pre>
Notice: You may need to prepend the following commands with <code>bundle exec</code>.
<pre style="white-space:normal;">rake db:migrate</pre>
<pre style="white-space:normal;">rake db:migrate</pre>
<pre style="white-space:normal;">rake db:test:prepare</pre>
<pre style="white-space:normal;">rake db:test:prepare</pre>
==Set up secrets file==
<pre style="white-space:normal;">cp config/secrets.yml.example config/secrets.yml</pre>
==Setup Bower==
First, install bower with npm (install npm first if not already installed)
<pre style="white-space:normal;">npm install bower -g</pre>
Then run this from the expertiza directory
<pre style="white-space:normal;">bower install --allow-root</pre>
==Setup Redis==
Please install redis on your machine and then run redis-server command.
These commands will help you run redis easily:
$ wget http://download.redis.io/releases/redis-4.0.1.tar.gz
$ tar xzf redis-4.0.1.tar.gz
$ cd redis-4.0.1
$ make
$ src/redis-server
==Start rails server==
<pre style="white-space:normal;">rails server</pre>
Then direct your browser to <code>http://localhost:3000</code>
You can log in using instructor6. student5000, student5001, etc. are good too.
The password for any account is "password".
====Import Production Data (Optional)====
====Import Production Data (Optional)====
This step requires that you have your ssh private/public key pairs loaded in the production server under the rails user.<br />
This step requires that you have your ssh private/public key pairs loaded in the production server under the rails user.<br />
[[How to Add SSH Keys to the Expertiza Production Server]] <br />
[[How to Add SSH Keys to the Expertiza Production Server]] <br />
You must run the following command from your local Expertiza project directory.
You must run the following command from your local Expertiza project directory.
<pre style="white-space:normal;">cap load_production_data</pre>
<pre style="white-space:normal;">cap production load_data</pre>

Latest revision as of 18:22, 10 November 2018

Prerequisites

  • You must have shell access
  • You must have root access (via sudo), or the required software must already be installed

Install Git

Git for OS X

Get Expertiza

Fork Expertiza to your Github

  • If you don't have a Github account, register one, and remember the password!!
  • go to https://github.com/expertiza/expertiza and click on the "Fork" button on the upper right side.
  • When asked "Where should we fork this repository?" choose your account, which usually looks like this "@YourUsername"
  • Then go to https://github.com/[YourUsername]/expertiza and click on the "Clone or Download" button
  • Copy the url, which usually looks like "https://github.com/[YourUsername]/expertiza.git"
  • Then go to your terminal and go to a folder of your choice where the codes will be downloaded into.
  • To clone the project, type in "git clone https://github.com/[YourUsername]/expertiza.git"
  • when asked for a password, enter your password

Merge your changes to Expertiza

  • When you're done editing the code, commit the code to your local repository by executing this in terminal:
    • git add -A #mark all changed files to be committed to the repository
    • git commit -m "say what you have done to the code" #commit your changes to the local repository
    • git push #sync your changes to the remote repository
  • Do commit as often as needed to store the states of the code. Do commit before you do changes that you're not sure about. It'd allow you to revert back to your previous states if you screw up the code.
  • Do push less often (maybe every 5-10 commits)
  • Before requesting for a merge, please refactor your code and put comments. Bad code won't be merged!
  • After you're done with beautifying your project, go to https://github.com/[YourUsername]/expertiza, and click on "New pull request" on the left side.
  • Your code will be reviewed and merged if the quality is good enough!

[DEPRECATED. DO NOT USE UNLESS ADVISED]

Expertiza Repository URLs
Default [DEPRECATED]
git clone <remote>
git clone git@github.com:expertiza/expertiza.git
Options
git clone -b <branch> <remote>
git clone -b production git@github.com:expertiza/expertiza.git

Install Homebrew

http://mxcl.github.io/homebrew

Install RBENV

$ brew update
$ brew install rbenv
$ brew install ruby-build

Install Ruby v. 2.1.5

https://github.com/sstephenson/ruby-build/wiki#installing-187-on-os-x-108-mountain-lion

Install Native Expertiza Dependencies

Dependencies are for the gems raspell, rjb, nokogiri, and mysql.

brew install aspell gcc47 libxml2 libxslt graphviz openssl

Install Bundled Gems

Set JAVA_HOME for the rjb gem (set it to a valid location, your path may vary):

export JAVA_HOME=/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/
bundle install

Possible alternate step if _bundle install_ command has build errors:

$ bundle config build.eventmachine --with-cppflags=-I/usr/local/opt/openssl/include
$ brew install apple-gcc42
$ brew unlink apple-gcc42
$ brew link apple-gcc42
$ export CC=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2
$ export CXX=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/g++-4.2
$ export CPP=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/cpp-4.2

Set Up the Database

Set the MySql Root Password

This step is not necessary, but it is advised to set a root mysql password.

mysqladmin -u root password

Run SQL script to scrub DB

Here is the link of Expertiza scrubbed DB (https://drive.google.com/a/ncsu.edu/file/d/0B2vDvVjH76uEMDJhNjZVOUFTWmM/view?usp=sharing) Download the file, unzip it and dump to MySQL.

mysql -uroot -p -h localhost < expertiza_scrubbed.sql
Log in to MySql
mysql -uroot -p

The following commands are executed inside mysql

Create the Expertiza User
create user expertiza@localhost;
Create the Databases
create database expertiza_development;
create database expertiza_test;
Grant Privileges to the Expertiza User
grant all on expertiza_development.* to expertiza@localhost;
grant all on expertiza_test.* to expertiza@localhost;


Build the Expertiza Database

First, you have to copy the sample database config to a real one.

cp config/database.yml.example config/database.yml

Then edit the file and put your mysql password in there so it can log into the db

vi config/database.yml

Notice: You may need to prepend the following commands with bundle exec.

rake db:migrate
rake db:test:prepare

Set up secrets file

cp config/secrets.yml.example config/secrets.yml

Setup Bower

First, install bower with npm (install npm first if not already installed)

npm install bower -g

Then run this from the expertiza directory

bower install --allow-root

Setup Redis

Please install redis on your machine and then run redis-server command. These commands will help you run redis easily: $ wget http://download.redis.io/releases/redis-4.0.1.tar.gz $ tar xzf redis-4.0.1.tar.gz $ cd redis-4.0.1 $ make $ src/redis-server

Start rails server

rails server

Then direct your browser to http://localhost:3000

You can log in using instructor6. student5000, student5001, etc. are good too. The password for any account is "password".

Import Production Data (Optional)

This step requires that you have your ssh private/public key pairs loaded in the production server under the rails user.
How to Add SSH Keys to the Expertiza Production Server
You must run the following command from your local Expertiza project directory.

cap production load_data