github.com/covergates/covergates@v0.2.2-0.20201009050117-42ef8a19fb95/CONTRIBUTING.md (about) 1 # Contribution Guidelines 2 3 Thanks for your interest in contributing **covergates**. 4 Before you start, please read this document. 5 It will help you set yourself up with a good development environment. 6 7 ## Signing the CLA 8 9 First, please read and sign the 10 [Electronic Covergates Contribution License Agreement](https://cla-assistant.io/covergates/covergates). 11 By signing a contributor license agreement, it is ensured that the community is free to use your contribution. 12 13 ## Discuss your Design 14 15 Please let everyone knows what you are working on by [creating a issue](https://github.com/covergates/covergates/issues). 16 This process prevents duplication of effort, and ensure that the idea is discussed and fits the project goal. 17 18 ## Build and Run 19 20 To get starting, it assumes a certain level of comfort with `Go`, 21 `Vue`, `typescript` and `Docker`. To get some helps, you could refer to below links: 22 23 1. [A Tour of Go](https://tour.golang.org/welcome/1) 24 2. [What is Vue.js](https://vuejs.org/v2/guide/) 25 3. [TypeScript in 5 mins](https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html) 26 4. [docker for beginners](https://docker-curriculum.com/) 27 28 The project also uses [google/wire](https://github.com/google/wire) for dependency injection. 29 You may refer to [Wire Tutorial](https://github.com/google/wire/blob/master/_tutorial/README.md) for more detail. 30 31 ### Getting the Source Code 32 33 Fork the repository so that you can make a pull request. Then clone your fork by: 34 35 ```sh 36 git clone https://github.com/<<<your-github-account>>>/covergates.git 37 cd covergates 38 ``` 39 40 Create a new branch for your change. 41 Manage any merge conflicts, commit them, and then push them to your fork. 42 It is suggested to have one feature or bug-fix per branch. 43 44 ### Setup SCM (source control management) 45 46 **Covergates** requires to connect with SCM to work. 47 Although you could connect it with GiHub, 48 it is suggested setting a self-hosted SCM for testing. 49 It's recommended to choose [Gitea](https://gitea.io/en-us/). You can refer to 50 [Installation with Docker](https://docs.gitea.io/en-us/install-with-docker/) for the detail. 51 You can also setup Gitea by running our container for testing: 52 53 ```sh 54 docker run -d -p 3000:3000 blueworrybear/gitea-docker 55 ``` 56 57 Visit [http://localhost:3000](http://localhost:3000) to see if it works. The admin user and password is `gitea` and `gitea`. 58 59 ### Run 60 61 To test your changes, run: 62 63 ```sh 64 # If using blueworrybear/gitea-docker container 65 export GATES_GITEA_CLIENT_ID="c8c6a2cc-f948-475c-8663-f420c8fc15ab" 66 export GATES_GITEA_CLIENT_SECRET="J8YYirhYOZY9a9RepaoORN-8EFcSO-sbwjSGvGo4NwE=" 67 export GATES_GITEA_SERVER="http://localhost:3000" 68 export GATES_GITEA_SKIP_VERITY="true" 69 go run ./cmd/server 70 ``` 71 72 Visit [http://localhost:8080](http://localhost:8080) for the `covergates` server. 73 74 ### Debug 75 76 If yor are using `VS code` as your IDE, you could setup the `launch.json` as blow and press `F5` to debug: 77 78 ```yml 79 { 80 "version": "0.2.0", 81 "configurations": [ 82 { 83 "name": "Launch", 84 "type": "go", 85 "request": "launch", 86 "mode": "auto", 87 "program": "${workspaceFolder}/cmd/server", 88 "env": { 89 "DEBUG": "true", 90 "DEBUG_LOGIN": "gitea", 91 "DEBUG_EMAIL": "gitea@gmail.com", 92 "DEBUG_AVATAR": "http://localhost:3000/user/avatar/gitea/-1", 93 "DEBUG_GITEA_TOKEN": "1749a6106454f05f689051c331680c13d78d81b7", 94 "DEBUG_GITEA_LOGIN": "gitea", 95 "GATES_GITEA_CLIENT_ID": "c8c6a2cc-f948-475c-8663-f420c8fc15ab", 96 "GATES_GITEA_CLIENT_SECRET": "J8YYirhYOZY9a9RepaoORN-8EFcSO-sbwjSGvGo4NwE=", 97 "GATES_GITEA_SERVER": "http://localhost:3000", 98 "GATES_GITEA_SKIP_VERITY": "true" 99 }, 100 "buildFlags": "-tags='debug'" 101 } 102 ] 103 } 104 ``` 105 106 ### Working with Frontend 107 108 If you would like to change frontend, you may need to change backend server to run on different port by: 109 110 ```sh 111 export DEBUG="true" 112 export DEBUG_LOGIN="gitea" 113 export DEBUG_EMAIL="gitea@gmail.com" 114 export DEBUG_AVATAR="http://localhost:3000/user/avatar/gitea/-1" 115 export DEBUG_GITEA_TOKEN="1749a6106454f05f689051c331680c13d78d81b7" 116 export DEBUG_GITEA_LOGIN="gitea" 117 export GATES_GITEA_CLIENT_ID="c8c6a2cc-f948-475c-8663-f420c8fc15ab" 118 export GATES_GITEA_CLIENT_SECRET="J8YYirhYOZY9a9RepaoORN-8EFcSO-sbwjSGvGo4NwE=" 119 export GATES_GITEA_SERVER="http://localhost:5900" 120 export GATES_GITEA_SKIP_VERITY="true" 121 go run ./cmd/server 122 ``` 123 124 > The **DEBUG** environment variables is required to keep you login to covergates. 125 126 127 And then run: 128 129 ```sh 130 cd web 131 npm install 132 npm run server 133 ``` 134 135 It will start a server at [http://localhost:8080](http://localhost:8080). 136 You could also modify backend proxy by editing `VUE_APP_PROXY` at `web/.env.development`. 137 138 ### Testing 139 140 To test backend, simply run: 141 142 ```sh 143 go test ./... 144 ``` 145 146 or testing with Gitea: 147 148 ``` 149 go test -tags="gitea" ./... 150 ``` 151 152 To test frontend, run: 153 154 ``` 155 cd web 156 npm run test:unit 157 ``` 158 159 ### Build 160 161 To build backend, run: 162 163 ```sh 164 go build -o covergates-server ./cmd/server 165 ``` 166 167 To build CLI, run: 168 169 ```sh 170 go build -o covergates ./cmd/cli 171 ``` 172 173 To build frontend, you require installing `togo` by running below command outside go module folder: 174 175 ```sh 176 go get github.com/bradrydzewski/togo 177 ``` 178 179 And then run: 180 181 ```sh 182 go generate ./web 183 ``` 184 185 ## Convention 186 187 ### Linting is Critical 188 189 Please make sure your code pass both `golint` and `eslint` by run: 190 191 ```sh 192 golint ./... 193 cd web 194 npm run lint 195 ``` 196 197 ## Pull Request 198 199 You have to sign your commit before we can accept a pull request from you. 200 Please refer to [Signing commits 201 ](https://docs.github.com/en/github/authenticating-to-github/signing-commits) for the detail. 202 You could also refer to [GitHub flow](https://guides.github.com/introduction/flow/) to learn 203 how to properly create a pull request. 204 205 ## Be Responding to Feedback 206 207 The project owners may recommend adjustment to your code. Don's get discourage! 208 Any suggestion means that we care about your work! We just hope your work meets 209 the project goal and could shine over decades. 210 211 *At last, thank you for contributing to the covergates open source project!*