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

Zac Wood's avatar
Zac Wood committed
3
[![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) [![python version](https://img.shields.io/badge/python-3.4+-blue.svg)]() [![Django version](https://img.shields.io/badge/Django-2.2-brightgreen.svg)]()
Jean Michel Rouly's avatar
Jean Michel Rouly committed
4

5

6
#### A project of [GMU SRCT](https://srct.gmu.edu).
7

David Haynes's avatar
David Haynes committed
8 9 10
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
11

Zac Wood's avatar
Zac Wood committed
12
Go is currently a `Python 3` project written in the `Django` web framework, with
David Haynes's avatar
David Haynes committed
13
`MySQL` as our backend database.
14

David Haynes's avatar
David Haynes committed
15
# Setup instructions for local development
16

David Haynes's avatar
David Haynes committed
17 18 19 20
Go currently supports developers on Linux, macOS and Windows platforms through
both the Docker and Vagrant virtualization platforms. You may use either one
though we have included instructions for manual setup as well. Here's our walk-through
of steps we will take:
21

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

David Haynes's avatar
David Haynes committed
26
## 1) Install `git` on your system.
Zosman's avatar
Zosman committed
27

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

David Haynes's avatar
David Haynes committed
30
### On Linux Based Systems
Zosman's avatar
Zosman committed
31

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

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

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

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

David Haynes's avatar
David Haynes committed
40
Next, with:
41

David Haynes's avatar
David Haynes committed
42
    sudo apt install git
David Haynes's avatar
David Haynes committed
43

David Haynes's avatar
David Haynes committed
44
you install `git` onto your system.
45

David Haynes's avatar
David Haynes committed
46
### On macOS
Zosman's avatar
Zosman committed
47

David Haynes's avatar
David Haynes committed
48 49 50 51
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.
52

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

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

David Haynes's avatar
David Haynes committed
57 58
**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
59

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

David Haynes's avatar
David Haynes committed
62
    brew update
Zosman's avatar
Zosman committed
63

David Haynes's avatar
David Haynes committed
64 65 66
Finally we can install git with:

    brew install git
Zosman's avatar
Zosman committed
67

David Haynes's avatar
David Haynes committed
68

Zac Wood's avatar
Zac Wood committed
69
### Windows
70

Zac Wood's avatar
Zac Wood committed
71
Download Git for Windows here:
72 73 74

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

Zosman's avatar
Zosman committed
75

David Haynes's avatar
David Haynes committed
76
## 2) Clone the Go codebase.
David Haynes's avatar
David Haynes committed
77

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

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

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

David Haynes's avatar
David Haynes committed
85
**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
86

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

David Haynes's avatar
David Haynes committed
89
## 3) Get Go up and running with the method of your choice.
90

David Haynes's avatar
David Haynes committed
91 92 93 94 95 96
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!

David Haynes's avatar
David Haynes committed
97
### Docker
David Haynes's avatar
David Haynes committed
98

David Haynes's avatar
David Haynes committed
99 100 101 102 103 104 105
Docker is an emerging containerization platform written in Google's Go
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
106 107
Check out [docker.com](https://www.docker.com/what-docker) for more details.

David Haynes's avatar
David Haynes committed
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
Pros:

 - 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 than
    Vagrant or 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

Cons:
David Haynes's avatar
David Haynes committed
126

David Haynes's avatar
David Haynes committed
127 128 129
 - Challenging to debug problems
    - Cannot interact with attached images and as a result, you cannot really
    interact with the database.
David Haynes's avatar
David Haynes committed
130

David Haynes's avatar
David Haynes committed
131
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).
Zac Wood's avatar
Zac Wood committed
132 133
**NOTE**: On Windows, Docker only works if you have Windows 10 Eductaion or Pro,
as it requires HyperV.
David Haynes's avatar
David Haynes committed
134

David Haynes's avatar
David Haynes committed
135
### Manual Setup
David Haynes's avatar
David Haynes committed
136

David Haynes's avatar
David Haynes committed
137 138
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
Zac Wood's avatar
Zac Wood committed
139
doing that with Docker except those platforms automate the steps that
David Haynes's avatar
David Haynes committed
140 141 142 143 144 145 146
are laid out in this section.

Pros:
  - Experience setting up a Django project for local development

Cons:
  - Way more steps
David Haynes's avatar
David Haynes committed
147

David Haynes's avatar
David Haynes committed
148 149 150 151
Head to:

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

David Haynes's avatar
David Haynes committed
152 153 154

# Some words about contributing to Go.

155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
## Testing

You are _very strongly_ encouraged to write test cases where applicible for
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.

### 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:

#### Docker

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.


#### Manual Setup

Assuming you are within your virtualenv:

    python manage.py test

180
## CONTRIBUTING.md
David Haynes's avatar
David Haynes committed
181

182 183 184 185 186 187 188 189 190
This document goes into detail about how to contribute to the repo, plus some
opinions about using `git`.

## Opening issues

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.

## Coding style
191

192 193 194 195 196
You should adhere to the style of the repo code. Consistancy is key! PEP8 guidelines
are strongly reccomended but not enforced at the time. Please comment your code,
I will not accept commits that contain uncommented code.

## Getting Help
David Haynes's avatar
David Haynes committed
197

David Haynes's avatar
David Haynes committed
198 199
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.
David Haynes's avatar
David Haynes committed
200

David Haynes's avatar
David Haynes committed
201 202
# Some words about deploying Go.

203 204 205
Check out our admin guide:

https://git.gmu.edu/srct/go/wikis/administration-guide
206 207 208 209 210 211

In order to expire links, you need to set up a cron job to run the manage.py
expirelinks command regularly. A sample cron script is available in the
repository and is named go-cleanlinks.cron. Drop this in cron.hourly and
change the paths so that they point to the virtualenv activate script and
manage.py.
David Haynes's avatar
David Haynes committed
212

David Haynes's avatar
David Haynes committed
213 214
---
**Note:**
David Haynes's avatar
David Haynes committed
215

216
Link by Viktor Vorobyev from the Noun Project.