Update Developer Guide authored by Barkin Simsek's avatar Barkin Simsek
......@@ -42,3 +42,25 @@ The HTML data received to the web browser and a dump of the [HAR](https://www.ke
# Stopping the system
1. You should use `make down`, otherwise you might leave some of the containers behind or maybe even corrupt data:
![Screen_Shot_2021-05-20_at_16.13.56](uploads/6acc9787459e88f303e678ec15d7e4ec/Screen_Shot_2021-05-20_at_16.13.56.png)
# Writing new code
## Docstrings
It is crucial to add [docstrings](https://www.programiz.com/python-programming/docstrings) to your code. You can check the existing code for the docstring style. Here is an example:
![Screen_Shot_2021-05-20_at_16.44.48](uploads/7d1fc1937cafd5330fd8af4a61bf8070/Screen_Shot_2021-05-20_at_16.44.48.png)
## Running your code
Since the system is highly dependent on multiple containers, it is best to write your code using Docker as well. To do that, you can start the whole system and leave it running in the background. Later, you can make the required changes to the code and only restart the `captchamonitor` container using `docker-compose restart captchamonitor` command. This will apply the changes you made and restart the code. I also like having `sudo watch -n 1 make logs` command run on a window and get the logs updated automatically.
## Formatting and checking your code with linter
After you are done adding a feature, make sure to run the `make check` command. This will adjust the format of the code and check for stylistic issues:
![Screen_Shot_2021-05-20_at_16.28.59](uploads/b1b12851d4619a4e764cec905d4e1848/Screen_Shot_2021-05-20_at_16.28.59.png)
Let's say you imported a library and never used it, in that case, the linter will complain:
![Screen_Shot_2021-05-20_at_16.29.38](uploads/3f6ee4e4d535e7c54975ff6964c222d1/Screen_Shot_2021-05-20_at_16.29.38.png)
You *have* to make sure that `make check` command doesn't return any errors because GitLab also runs that command once you push the code and we will not be merging any code until the green checkmark shows up next to your commit.
## Testing your code
It is important to add unit tests for the code you wrote. At the moment, it is not the first priority but please write tests whenever you can. Once you have the test, you can run them with `make test` command:
![Screen_Shot_2021-05-20_at_16.28.35](uploads/bd7e19c38aac4e512d11500f00620f5a/Screen_Shot_2021-05-20_at_16.28.35.png)
# Pull Requests
Pull requests should be ideally small and shouldn't contain hundreds of lines of code change. Here is a good article that explains more: https://opensource.com/article/18/6/anatomy-perfect-pull-request
\ No newline at end of file