README.md 7 KB
Newer Older
1
# Go 3
Jean Michel Rouly's avatar
Jean Michel Rouly committed
2

3 4
[![build status](https://git.gmu.edu/srct/go/badges/master/build.svg)](https://git.gmu.edu/srct/go/commits/master)
[![coverage report](https://git.gmu.edu/srct/go/badges/master/coverage.svg)](https://git.gmu.edu/srct/go/commits/master)
5 6
[![python version](https://img.shields.io/badge/python-3.6-blue.svg)]()
[![Django version](https://img.shields.io/badge/Django-2.0-brightgreen.svg)]()
Jean Michel Rouly's avatar
Jean Michel Rouly committed
7

8
A project of [GMU SRCT](https://srct.gmu.edu).
9

10 11 12
Go is a drop-in URL shortening service. This project aims to provide an easy to
use URL branding service for institutions that wish to widely disseminate
information without unnecessarily outsourcing branding.
David Haynes's avatar
David Haynes committed
13

14 15
Go is currently a `Python 3` project written in the `Django` web framework,
with `MySQL` as our backend database.
16

17
## Setup instructions for local development
18

David Haynes's avatar
David Haynes committed
19
Go currently supports developers on Linux, macOS and Windows platforms through
20 21
the Docker container platform. We have included instructions for manual setup
as well. Here's our walk-through of steps we will take:
22

23 24 25
1.  Install `git` on your system.
1.  Clone the Go codebase.
1.  Get Go up and running with the method of your choice.
Zosman's avatar
Zosman committed
26

27
### 1) Install `git` on your system
Zosman's avatar
Zosman committed
28

David Haynes's avatar
David Haynes committed
29
`git` is the version control system used for SRCT projects.
Zosman's avatar
Zosman committed
30

31
#### On Linux Based Systems
Zosman's avatar
Zosman committed
32

David Haynes's avatar
David Haynes committed
33 34
**with apt:**

David Haynes's avatar
David Haynes committed
35
Open a terminal and run the following command:
mdsecurity's avatar
mdsecurity committed
36

David Haynes's avatar
David Haynes committed
37
    sudo apt update
Robert Hitt's avatar
Robert Hitt committed
38

39 40
This retrieves links to the most up-to-date and secure versions of your
packages.
Robert Hitt's avatar
Robert Hitt committed
41

David Haynes's avatar
David Haynes committed
42
Next, with:
43

David Haynes's avatar
David Haynes committed
44
    sudo apt install git
David Haynes's avatar
David Haynes committed
45

David Haynes's avatar
David Haynes committed
46
you install `git` onto your system.
47

48
#### On macOS
Zosman's avatar
Zosman committed
49

David Haynes's avatar
David Haynes committed
50 51 52 53
We recommend that you use the third party Homebrew package manager for macOS,
which allows you to install packages from your terminal just as easily as you
could on a Linux based system. You could use another package manager (or not
use one at all), but Homebrew is highly reccomended.
54

David Haynes's avatar
David Haynes committed
55
To get homebrew, run the following command in a terminal:
David Haynes's avatar
David Haynes committed
56

David Haynes's avatar
David Haynes committed
57
    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)
58

David Haynes's avatar
David Haynes committed
59 60
**Note**: You do NOT need to use `sudo` when running any Homebrew commands, and
it likely won't work if you do.
David Haynes's avatar
David Haynes committed
61

David Haynes's avatar
David Haynes committed
62
Next, to make sure Homebrew is up to date, run:
63

David Haynes's avatar
David Haynes committed
64
    brew update
Zosman's avatar
Zosman committed
65

David Haynes's avatar
David Haynes committed
66 67 68
Finally we can install git with:

    brew install git
Zosman's avatar
Zosman committed
69

70
#### On Windows
David Haynes's avatar
David Haynes committed
71

72 73
We recommend that if you are on Windows 10 to make use of the Windows Subsystem
for Linux (WSL). The following link should get you up and running:
74 75 76 77 78

[https://msdn.microsoft.com/en-us/commandline/wsl/install_guide](https://msdn.microsoft.com/en-us/commandline/wsl/install_guide)

#### Contributing with Windows

79 80
After that is setup, you should be able to follow the Linux instructions for
_manual setup_ to contribute to the project.
81

82 83
If you are not on Windows 10 or would rather prefer to not use the WSL you may
download Git for Windows here:
84 85 86

[https://git-scm.com/download/win](https://git-scm.com/download/win)

David Haynes's avatar
David Haynes committed
87
I have successfully ran the project with Docker, though you need access to
David Haynes's avatar
David Haynes committed
88
Hyper-V which is only available on "Professional" versions of Windows.
Zosman's avatar
Zosman committed
89

90
### 2) Clone the Go codebase
David Haynes's avatar
David Haynes committed
91

92 93
Now, we're going to clone down a copy of the Go codebase from
[git.gmu.edu](https://git.gmu.edu/srct/go), the SRCT code respository with SSH.
David Haynes's avatar
David Haynes committed
94 95

**a)** Configure your ssh keys by following the directions at:
96

97
[git.gmu.edu/help/ssh/README](https://git.gmu.edu/help/ssh/README).
David Haynes's avatar
David Haynes committed
98

99 100
**b)** Now, on your computer, navigate to the directory in which you want to
download the project (ie. perhaps one called `development/SRCT`), and run
David Haynes's avatar
David Haynes committed
101

David Haynes's avatar
David Haynes committed
102
    git clone git@git.gmu.edu:srct/go.git
David Haynes's avatar
David Haynes committed
103

104
### 3) Get Go up and running with the method of your choice
105

David Haynes's avatar
David Haynes committed
106 107 108 109 110 111
Now that we have `git` setup and cloned down the code you can

    cd go/

and get to working on setting up a development environment!

112
#### Docker
David Haynes's avatar
David Haynes committed
113

David Haynes's avatar
David Haynes committed
114
Docker is an emerging containerization platform written in Google's Go
115 116 117
language. Instead of running a full VM that runs Go, we package up all the
various bits that make up Go and run that as a container (two containers: one
for Go and the other for mysql) that act as normal processes to the OS.
David Haynes's avatar
David Haynes committed
118

David Haynes's avatar
David Haynes committed
119 120
Check out [docker.com](https://www.docker.com/what-docker) for more details.

David Haynes's avatar
David Haynes committed
121 122
Pros:

123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
* Lightweight
  * Can be run on most machines without needing significant resources.
    * SRCT members report minimal battery impact on laptops.
* Fast
  * Compared to other methods, Docker is comparatively faster to setup than
    manual setup.
* Minimal setup
  * You run one command. Really easy to get up and running once you install
    Docker.
* Good cross platform support
  * Runs smoothly on macOS, Linux, and Windows
  * Great docs to help if you get stuck.
* Can easily destroy and rebuild the docker images
* Loads in changes to code on the fly

There are instructions on how to setup/develop with Docker at the
[docker-configuration page in the Go project wiki](https://git.gmu.edu/srct/go/wikis/docker-configuration).
David Haynes's avatar
David Haynes committed
140

141
#### Manual Setup
David Haynes's avatar
David Haynes committed
142

143 144 145 146
Manual setup (or: the old fashioned way) is where you install all dependecies
on your system and run Go as a local server with Django. Granted you are
technically doing that with Docker except it automates the steps that are laid
out in this section.
David Haynes's avatar
David Haynes committed
147 148

Pros:
149

150
* Experience setting up a Django project for local development
David Haynes's avatar
David Haynes committed
151 152

Cons:
153

154 155
* Greater potential for things to go wrong
* Way more steps
David Haynes's avatar
David Haynes committed
156

David Haynes's avatar
David Haynes committed
157 158 159 160
Head to:

https://git.gmu.edu/srct/go/wikis/manual-setup

161
## Some words about contributing to Go
David Haynes's avatar
David Haynes committed
162

163
### Testing
164 165

You are _very strongly_ encouraged to write test cases where applicible for
166 167 168 169
code that you contribute to the repo. This is not a rule at the moment but
rather a strong suggestion. It's good practice for corporate land and will also
ensure your code works. Additionally, there are quite a few example ones to
look at in the repo and on Google.
170 171 172 173 174 175

### Running Unit Tests

Unit tests are run on every commit sent to gitlab though that can be a pain to
rely on. Here's how to run them locally:

176
### Docker
177 178 179 180

Docker is not supported currently for running unit tests. If you're able to get
it set up, open a merge request and I'll merge it in.

181
### Manual Setup
182 183 184 185 186

Assuming you are within your virtualenv:

    python manage.py test

187
### CONTRIBUTING.md
David Haynes's avatar
David Haynes committed
188

189 190 191
This document goes into detail about how to contribute to the repo, plus some
opinions about using `git`.

192
### Opening issues
193

194 195
There is a template for issue descriptions located on the new issue page. I
will close issues with poor descriptions or who do not follow the standard.
196

197
### Authentication
David Haynes's avatar
David Haynes committed
198 199

The authentication service used for Go is CAS. In local development however we
200 201
utilize a test server. You can log in with just your CAS username to simulate
logging in. By default, the Django superuser is set to `dhaynes3`.
David Haynes's avatar
David Haynes committed
202

203 204 205 206 207
In order to approve yourself to be an 'approved user' you must navigate to
127.0.0.1:8000/admin and log in. Once in the admin page go to "registered
users", and create a new registered user in the top right. Be sure to use the
same username and Full Name as your main account and select "approved" in the
bottom row.
208

209
### Coding style
210

211
TODO
212

213
### Getting Help
David Haynes's avatar
David Haynes committed
214

215 216 217 218
I encourage you to join the
[#go channel](https://srct.slack.com/messages/go/details/) in SRCT's
[Slack Group](https://srct.slack.com) if you have any questions on setup or
would like to contribute.