This is a rails application that allows for course management in conjunction with GitHub and GitHub organizations. It pairs classes with GitHub organizations and invites students to the GitHub organization when the students join the course.
React Storybooks: https://brownfield-team.github.io/anacapa-github-linker
Select GitHub as the deployment method and then specify the forked repo, then hit deploy at the bottom.
Using the machine user visit Developer Settings under the user's Settings.
https://insert-your-heroku-app-link-here/users/auth/github/callback
rake db:migrate
.Instructors can create courses and only manage their own courses.
TAs cannot delete a student, promote other students to TAs, or modify the course itself in any way.
NOTE:Remember to go to "Member Privileges" and change "Repository Permission" for Organization Members to "None"
Dear Student: We will be using github.com in this course. We have created an organization called (insert org name here on github.com where you can create repositories (repos) for your assignments in this course. The advantage of creating private repos under that organization is that the course staff (your instructors, TAs and mentors) will be able to see your code and provide you with help, without you having to do anything special.
To join this organization, you need to do three things.
You will need:
Ruby installed; I suggest installing rvm
from https://rvm.io
rvm
is usually installing gpg2
.
sudo apt install gnupg2
rvm
may take a while (10-20 minutes)Postgres (an SQL database) needs to be installed:
For WSL:
sudo apt install postgresql
sudo service postgresql start
sudo su - postgres
createuser --superuser $USER # where $USER is your username
psql
Then:
\password $USER
is typed into the `psql console to set up your account\q
to exit psql
exit
to exit the postgres
user shell and go back to a regular user shellrvm install ruby-2.6.3
(note that this Ruby version might be different by the time you read this)
gem install bundler
Clone the repo, and run bundle install
Make sure that Postgres is running locally
createuser -s -r postgres
per this StackOverflow postbundle exec rake db:create
bundle exec rake db:migrate
Do cp dotenv.example .env
.env
is a file in the .gitignore
because you will configure it with secrets.env
is a hidden file, so you'll need ls -a
to see it in your directory.Edit .env
with the appropriate values. For advice on "appropriate values", see the section ".env values" below. Note that these are NOT shell environment variables, but rather variables
that are read into the Rails environment by the dotenv-rails gem.
Finally, run rails s
and the application should come up.
.env
valuesThe dotenv.example
file contains example values and some information on the values
you shoudl put into your .env
. Here is a bit more information.
The following two values can typically be left as is. Originally, we had intended that the code would work for different strategies and different git providers. For the time being it is only known to work with these values. However, these values to have to be provided.
GIT_PROVIDER_URL=github.com
OMNIAUTH_STRATEGY=github
The next two values require you to set up a Github OAuth application.
To configure an OAuth App for Github:
This link should take you directly to the page to create a new OAuth App: https://github.com/settings/applications/new
Or you can navigate to it this way:
OAuth Apps
New OAuth App
You now have a form to fill in.
Application name: Fill in something like anacapa-github-linker on localhost
Homepage URL: Enter
http://localhost:3000
orApplication Description is optional. If you fill it in, users will see it when they are asked to authorize access to their GitHub account.
Authorization callback URL:
Once you enter this information, you'll get a client id and a client secret.
OMNIAUTH_PROVIDER_KEY
OMNIAUTH_PROVIDER_SECRET
Next we have the machine user name.
For the machine user name, for testing purposes, use your own github userid.
MACHINE_USER_NAME=<your machine user's name>
For the machine user key, go to your settings, under developer settings, under personal access tokens, i.e. https://github.com/settings/tokens
Create a personal access token with the following scopes:
admin:org, admin:org_hook, notifications, repo
Put the access token value in for the machine users key. Note that you should treat that value VERY carefully, as it is equivalent to a password to your github account.
Revoke it when you are finished testing the application.
The final value can be any string that you type. It is used a cryptographic "salt", so it just needs to be arbitrary.
DEVISE_SECRET_KEY=<a random alphunmeric string used by devise to salt its sessions>
To create a full backup of the current database:
heroku pg:backups:capture --app ucsb-cs-github-linker
heroku pg:backups:download --app ucsb-cs-github-linker
This creates latest.dump
in the current directory. Then you need to have postgres installed locally so that you can use the pg_restore
command to convert this to a text .sql
file like this:
pg_restore -f latest.sql latest.dump
To have staging pull in data from production, run the following command (with heroku cli configured):
heroku pg:backups:restore `heroku pg:backups:url --app ucsb-cs-github-linker` DATABASE_URL --app anacapa-github-linker-test --confirm anacapa-github-linker-test
For end2end testing, see: DOCS/playwright/README.md
Frontend tests should be placed under the test/javascript directory. For frontend testing of React components run: