github.com/cozy/cozy-stack@v0.0.0-20240327093429-939e4a21320e/docs/CONTRIBUTING.md (about) 1 # How to contribute to the Cozy Stack? 2 3 Thank you for your interest in contributing to Cozy! There are many ways to 4 contribute, and we appreciate all of them. 5 6 ## Security Issues 7 8 If you discover a security issue, please bring it to their attention right away! 9 Please **DO NOT** file a public issue, instead send your report privately to 10 security AT cozycloud DOT cc. 11 12 Security reports are greatly appreciated and we will publicly thank you for it. 13 We currently do not offer a paid security bounty program, but are not ruling it 14 out in the future. 15 16 ## Bug Reports 17 18 While bugs are unfortunate, they're a reality in software. We can't fix what we 19 don't know about, so please report liberally. If you're not sure if something is 20 a bug or not, feel free to file a bug anyway. 21 22 Opening an issue is as easy as following 23 [this link](https://github.com/cozy/cozy-stack/issues/new) and filling out the 24 fields. Here are some things you can write about your bug: 25 26 - A short summary 27 - What did you try, step by step? 28 - What did you expect? 29 - What did happen instead? 30 - What is the version of the Cozy Stack? 31 32 You can also use the [`cozy-stack tools bug`](cli/cozy-stack_tools_bug.md) command to 33 open the form to report issue prefilled with some useful system informations. 34 35 ## Pull Requests 36 37 ### Workflow 38 39 Pull requests are the primary mechanism we use to change Cozy. GitHub itself has 40 some 41 [great documentation ](https://help.github.com/categories/collaborating-with-issues-and-pull-requests/) 42 on using the Pull Request feature. We use the 'fork and pull' model described 43 there. 44 45 #### Step 1: Fork 46 47 Fork the project on GitHub and check out your copy locally: 48 49 ``` 50 $ git clone https://github.com/cozy/cozy-stack.git 51 $ cd cozy-stack 52 $ git remote add fork git://github.com/username/cozy-stack.git 53 ``` 54 55 #### Step 2: Branch 56 57 Create a branch and start hacking: 58 59 ``` 60 $ git checkout -b my-branch -t origin/master 61 ``` 62 63 #### Step 3: Code 64 65 66 Well, I think you know how to do that. Just be sure to follow the coding 67 guidelines from the Go community (gofmt, 68 [Effective Go](https://golang.org/doc/effective_go.html), comment the code, 69 etc.). 70 71 We are using [goimports](https://godoc.org/golang.org/x/tools/cmd/goimports) to 72 format code, and [golangci-lint](https://github.com/golangci/golangci-lint) to 73 detect code smells. 74 75 ``` 76 $ make lint 77 ``` 78 79 We are using [eslint](https://eslint.org/) to lint JavaScript code. The linting 80 rules are based on 81 [cozy-app](https://github.com/cozy/cozy-libs/tree/master/packages/eslint-config-cozy-app) 82 83 ``` 84 $ make jslint 85 ``` 86 87 #### Step 4: Test 88 89 Don't forget to add tests and be sure they are green. You need CouchDB 90 installed, with an account, and configuring the stack to use this account: 91 92 ``` 93 $ export COZY_COUCHDB_URL=http://admin:password@localhost:5984 94 $ make unit-tests 95 ``` 96 97 If you want to play with the modified cozy-stack (for example, testing it with a 98 webapp), you can build it locally and start it with this command: 99 100 ``` 101 $ make run 102 ``` 103 104 #### Step 5: Commit 105 106 Writing 107 [good commit messages](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) 108 is important. A commit message should describe what changed and why. 109 110 #### Step 6: Rebase 111 112 Use `git pull --rebase`, or `git rebase` (but not `git merge`), to sync your 113 work from time to time: 114 115 ``` 116 $ git pull origin master --rebase 117 ``` 118 119 #### Step 7: Push 120 121 ``` 122 $ git push fork my-branch 123 ``` 124 125 Go to https://github.com/username/cozy-stack and select your branch. Click the 126 'Pull Request' button and fill out the form. 127 128 Pull requests are usually reviewed within a few days. If there are comments to 129 address, apply your changes in a separate commit and push that to your branch. 130 131 ## Code organization 132 133 The codebase of cozy-stack contains several packages, and it is quite easy to 134 have circular import issues in go. To limit the risk, we have split the 135 packages in several directories with some rules for the imports. In short, 136 a package in this list should import other packages that are on the same line 137 or below: 138 139 - `main` and `cmd` are the top level packages 140 - `web` is where we have the routers and handlers for web requests 141 - `worker` is where we define the workers for our job system 142 - `model` is for high-level internal packages (in general one package is used 143 for one doctype) 144 - `client` is a small number of packages used for writing clients for the stack 145 - `pkg` is the low-level packages (most of those packages are just a couple of 146 structs and functions). 147 148 Note that `tests/testutils` can be used safely in `web` and `worker` packages. 149 In `model`, it can be used but it is recommended to use a fake package for the 150 tests if it is the case. For example, `model/oauth/client_test.go` is declared 151 as `package oauth_test`. 152 153 ## External assets 154 155 The cozy-stack serve some assets for the client application. In particular, 156 cozy-client-js and cozy-bar assets are listed in `assets/.externals`. To update 157 them, you can open a pull request for this file. When a maintainer will accept 158 this pull request, he will also run `make assets` to transform them in go code 159 (to make the repository go gettable). 160 161 ## Useful commands 162 163 There are some useful commands to know in order to develop with the go code of 164 cozy-stack: 165 166 ```bash 167 cd cozy-stack 168 make help # Show the commands that can be launched via make 169 go build # Build the stack, also takes care of updating dependencies through gomodules 170 go install # Installs the `cozy-stack` binary 171 go test -v ./... # To launch the tests 172 go run main.go serve # To start the API server 173 godoc -http=:6060 # To start the documentation server 174 # Open http://127.0.0.1:6060/pkg/github.com/cozy/cozy-stack/ 175 ``` 176 177 ## Writing documentation 178 179 Documentation improvements are very welcome. We try to keep a good documentation 180 in the `docs/` folder. But, you know, we are developers, we can forget to 181 document important stuff that look obvious to us. And documentation can always 182 be improved. 183 184 ## Translations 185 186 The Cozy Stack is translated on a platform called 187 [Transifex](https://www.transifex.com/cozy/). 188 [This tutorial](https://docs.transifex.com/getting-started-1/translators) can help 189 you to learn how to make your first steps here. If you have any question, don't 190 hesitate to ask us! 191 192 The translations are kept synchronized with transifex via their github integration. 193 194 ## Community 195 196 You can help us by making our community even more vibrant. For example, you can 197 write a blog post, take some videos, answer the questions on 198 [the forum](https://forum.cozycloud.cc), organize new meetups, and speak about 199 what you like in Cozy!