You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -6,17 +6,60 @@ This is the mono-repository for the backend services and their common codebase
6
6
7
7
## Getting started
8
8
9
-
Follow the following instructions to get the project ready to use ASAP.
9
+
Follow the next instructions to get the project ready to use ASAP.
10
10
11
-
### Requirements
11
+
Currently, there are two ways to run the project, the production mode using a virtual environment and installing all the necessary libraries
12
+
there and the other way is using the development mode with Docker and docker-compose. It is recommended to use the development mode and in special cases the production mode.
12
13
13
-
Be sure you have installed in your system:
14
+
## Requirements:
15
+
16
+
For both modes it is necessary to have the following requirements installed:
14
17
15
18
-[Python version 3](https://www.python.org/download/releases/3.0/) (recommended 3.8 or less) in your path. It will install
16
19
automatically [pip](https://pip.pypa.io/en/stable/) as well.
17
20
- A virtual environment, namely [.venv](https://docs.python.org/3/library/venv.html).
Before proceeding to the configuration for each of the modes,
26
+
it is important to perform the following step regardless of the mode to be used.
27
+
28
+
### Create a virtual environment
29
+
30
+
Execute the next command at the root of the project:
31
+
32
+
```shell
33
+
python -m venv .venv
34
+
```
35
+
36
+
> **Note:** We can replace python for python3 or python3.8 according to the version you have installed,
37
+
> but do not forget the initial requirements.
38
+
39
+
**Activate the environment**
40
+
41
+
Windows:
42
+
```shell
43
+
.venv\Scripts\activate.bat
44
+
```
45
+
46
+
In Unix based operative systems:
47
+
48
+
```shell
49
+
source .venv/bin/activate
50
+
```
51
+
52
+
### Setup for each mode
53
+
54
+
The configuration required for each of the modes is as follows:
55
+
56
+
<details>
57
+
<summary><b>Development Mode</b></summary>
58
+
59
+
### Requirements:
60
+
61
+
In addition to the initial requirements, it is necessary to have the following requirements installed:
62
+
20
63
- Docker
21
64
22
65
You can follow the instructions below to install on each of the following operating systems:
@@ -28,7 +71,7 @@ Be sure you have installed in your system:
28
71
29
72
To install Docker Compose, please choose the operating system you use and follow the steps [here](https://docs.docker.com/compose/install/).
30
73
31
-
### Setup
74
+
### Setup
32
75
33
76
Once installed Docker and Docker Compose we must create a `.env` file in the root of our project where we will put the following environment variables.
34
77
@@ -56,7 +99,7 @@ Once all the project configuration is done, we are going to execute the followin
56
99
docker-compose up --build
57
100
```
58
101
59
-
This command will build all images with the necessary configurations for each one, aslo
102
+
This command will build all images with the necessary configurations for each one, also
60
103
raises the cosmos emulator in combination with the backend, now you can open in the browser:
61
104
62
105
-`http://127.0.0.1:5000/` open backend API.
@@ -66,126 +109,259 @@ raises the cosmos emulator in combination with the backend, now you can open in
66
109
> it is not necessary to execute it again, instead it should be executed like this:
67
110
> `docker-compose up`
68
111
69
-
> It is also important to clarify that if packages or any extra configuration is added to the images construction,
112
+
> It is also important to clarify that if packages or any extra configuration is added to the image's construction,
70
113
> you need to run again `docker-compose up --build`, you can see more information about this flag [here](https://docs.docker.com/compose/reference/up/)
71
114
72
-
## Development
115
+
###Development
73
116
74
-
### Generate Fake Data
117
+
####Generate Fake Data
75
118
76
119
In order to generate fake data to test functionalities or correct errors,
77
120
we have built a CLI, called 'Time Tracker CLI', which is in charge of generating
78
121
the fake information inside the Cosmos emulator.
79
122
80
123
To learn how this CLI works, you can see the instructions [here](https://github.com/ioet/time-tracker-backend/tree/master/cosmosdb_emulator)
81
124
82
-
### Git hooks
125
+
> It is important to clarify that Time Tracker CLI only works in development mode.
83
126
84
-
We use [pre-commit](https://github.com/pre-commit/pre-commit) library to manage local git hooks,
85
-
as developers we just need to run in our virtual environment.
127
+
### Test
86
128
87
-
This library allows you to execute code right before the commit, for example:
88
-
- Check if the commit contains the correct formatting.
89
-
- Format modified files based on a Style Guide such as PEP 8, etc.
129
+
We are using [Pytest](https://docs.pytest.org/en/latest/index.html) for tests. The tests are located in the package
130
+
`tests` and use the [conventions for python test discovery](https://docs.pytest.org/en/latest/goodpractices.html#test-discovery).
90
131
91
-
To install and use `pre-commit`we have to perform the following steps:
132
+
> Remember to run any available test command we have to have the containers up (`docker-compose up`).
92
133
93
-
**Create the environment**
134
+
This command run all tests:
94
135
95
-
Execute the next command at the root of the project:
136
+
```shell
137
+
./time-tracker.sh pytest -v
138
+
```
139
+
140
+
Run a single test:
96
141
97
142
```shell
98
-
python -m venv .venv
143
+
./time-tracker.sh pytest -v -k name-test
99
144
```
100
145
101
-
> **Note:** We can replace python for python3 or python3.8 according to the version you have installed,
102
-
> but do not forget the initial requirements.
146
+
#### Coverage
103
147
104
-
**Activate the environment**
148
+
To check the coverage of the tests execute:
105
149
106
-
Windows:
107
150
```shell
108
-
.venv\Scripts\activate.bat
151
+
./time-tracker.sh coverage run -m pytest -v
109
152
```
110
153
111
-
In Unix based operative systems:
154
+
To get a report table:
112
155
113
156
```shell
114
-
source .venv/bin/activate
157
+
./time-tracker.sh coverage report
115
158
```
116
159
117
-
Once the environment has been created and activated we have to run:
160
+
To get a full report in html:
161
+
118
162
```shell
119
-
python3 -m pip install pre-commit
163
+
./time-tracker.sh coverage html
120
164
```
165
+
Then check in the [htmlcov/index.html](./htmlcov/index.html) to see it.
121
166
122
-
Once `pre-commit` library is installed, we are going to execute the following command:
167
+
If you want that previously collected coverage data is erased, you can execute:
123
168
124
169
```shell
125
-
pre-commit install -t pre-commit -t commit-msg
170
+
./time-tracker.sh coverage erase
126
171
```
127
-
For more details, see section Development > Git hooks.
128
172
129
-
With this command the library will take configuration from `.pre-commit-config.yaml` and will set up the hooks by us.
173
+
</details>
130
174
131
-
### Commit message style
175
+
<hr>
132
176
133
-
Use the following commit message style. e.g:
177
+
<details>
178
+
<summary><b>Production Mode</b></summary>
134
179
135
-
```shell
136
-
'feat: TT-123 Applying some changes'
137
-
'fix: TT-321 Fixing something broken'
138
-
'feat(config): TT-00 Fix something in config files'
For example if your task in Jira is **TT-48 implement semantic versioning** your branch name is:
194
+
Where `<app>` is one of the executable app namespace, e.g. `time_tracker_api` or `time_tracker_events` (**Note:** Currently, only `time_tracker_api` is used.). The `stage` can be
195
+
196
+
-`dev`: Used for working locally
197
+
-`prod`: For anything deployed
198
+
199
+
Bear in mind that the requirements for `time_tracker_events`, must be located on its local requirements.txt, by
0 commit comments