github.com/datreeio/datree@v1.9.22-rc/DEVELOPER_GUIDE.md (about) 1 # Developer Guide 2 3 This guide explains how to set up your environment for developing on Datree. 4 This guide was written for macOS and Linux machines. 5 6 ## Prerequisites 7 8 - Go version 1.19 9 - Git 10 11 ## Building Datree 12 13 We use [Make](https://www.gnu.org/software/make/) to build our programs. The simplest way to get started is: 14 15 ``` 16 $ make build 17 ``` 18 19 This will build the executable file and place it in the project root. 20 21 One way to run datree locally is to use the newly created executable file: 22 23 ``` 24 $ ./datree test ./internal/fixtures/kube/k8s-demo.yaml 25 ``` 26 27 ## Running tests 28 29 To run all the tests: 30 31 ``` 32 $ make test 33 ``` 34 35 ## Contribution Guidelines 36 37 Make sure you have read and understood the 38 main [CONTRIBUTING](https://github.com/datreeio/datree/blob/main/CONTRIBUTING.md) guide: 39 40 ### Structure of the Code 41 42 #### cobra 43 44 We use [cobra](https://github.com/spf13/cobra) as our Command Line Interface framework. 45 The available commands can be found under the `cmd` directory; each folder represents a datree command. To add a 46 command, add a folder with the cobra command, and use it in the `cmd/root.go` file. 47 48 #### api endpoints 49 50 Datree requires an internet connection to connect to our backend API. 51 While developing locally, API requests will reach our staging environment and be visible on 52 the [Staging Dashboard](https://app.staging.datree.io). 53 All available API requests can be found under `pkg/cliClient` 54 55 #### manual testing 56 57 It's best to use fixtures for manual testing, which are found under `internal/fixtures` 58 59 #### test coverage 60 61 To add a test for a given file, add a file with a `_test` suffix. 62 For example: for the file `./reader.go` add a test file `./reader_test.go` 63 64 - For bug fixes: add a test that covers the bug fixed 65 - For features: add tests for the feature 66 67 ### Git Conventions 68 69 The main branch is the home of the current development candidate. 70 We accept changes to the code via GitHub Pull Requests (PRs). One workflow for doing this is as follows: 71 72 1. Fork the repository and clone it locally. 73 2. Create a new working branch `git checkout -b "ISSUE#195_some_short_description"` 74 3. When you are ready for us to review your changes, push your branch to GitHub, and then open a new pull request to 75 the `main` branch. 76 77 For Git commit messages, please follow 78 our [Commit Message Format](https://github.com/datreeio/datree/blob/main/CONTRIBUTING.md#-commit-message-format). 79 For example: `git commit -m "feat: add windows support"` 80 81 ### Go Conventions 82 83 We follow the [standard go formatting](https://golang.org/doc/effective_go#formatting) - simply use your IDE's 84 auto-formatter to make your code beautiful.