Skip to content

Commit 0d8520e

Browse files
authored
docs: TT-196 update readme (#272)
1 parent 9929129 commit 0d8520e

File tree

1 file changed

+67
-38
lines changed

1 file changed

+67
-38
lines changed

README.md

Lines changed: 67 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ automatically [pip](https://pip.pypa.io/en/stable/) as well.
2020

2121
### Setup
2222
- Create and activate the environment,
23-
23+
2424
In Windows:
25-
26-
```
25+
26+
```
2727
python -m venv .venv
2828
.venv\Scripts\activate.bat
2929
```
30-
31-
In Unix based operative systems:
30+
31+
In Unix based operative systems:
3232
```
3333
virtualenv .venv
3434
source .venv/bin/activate
@@ -42,26 +42,44 @@ Type in the terminal the following command to install the required dependency to
4242
```sh
4343
sudo apt-get install unixodbc-dev
4444
```
45-
45+
4646
- Install the requirements:
4747
```
4848
python3 -m pip install -r requirements/<app>/<stage>.txt
4949
```
50-
50+
5151
Where `<app>` is one of the executable app namespace, e.g. `time_tracker_api` or `time_tracker_events`.
52-
The `stage` can be
53-
52+
The `stage` can be
53+
5454
* `dev`: Used for working locally
5555
* `prod`: For anything deployed
56-
57-
56+
57+
5858
Remember to do it with Python 3.
59-
60-
Bear in mind that the requirements for `time_tracker_events`, must be located on its local requirements.txt, by
59+
60+
Bear in mind that the requirements for `time_tracker_events`, must be located on its local requirements.txt, by
6161
[convention](https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-python#folder-structure).
6262
6363
- Run `pre-commit install -t pre-commit -t commit-msg`. For more details, see section Development > Git hooks.
6464
65+
66+
### Set environment variables
67+
Set environment variables with the content pinned in our slack channel #time-tracker-developer:
68+
69+
```
70+
export MS_AUTHORITY=XXX
71+
export MS_CLIENT_ID=XXX
72+
export MS_SCOPE=XXX
73+
export MS_SECRET=XXX
74+
export MS_ENDPOINT=XXX
75+
export DATABASE_ACCOUNT_URI=XXX
76+
export DATABASE_MASTER_KEY=XXX
77+
export DATABASE_NAME=XXX
78+
export FLASK_APP=XXX
79+
export AZURE_APP_CONFIGURATION_CONNECTION_STRING=XXX
80+
export FLASK_DEBUG=True
81+
```
82+
6583
### How to use it
6684
- Set the env var `FLASK_APP` to `time_tracker_api` and start the app:
6785
@@ -70,13 +88,13 @@ Bear in mind that the requirements for `time_tracker_events`, must be located on
7088
set FLASK_APP=time_tracker_api
7189
flask run
7290
```
73-
In Unix based operative systems:
91+
In Unix based operative systems:
7492
```
7593
export FLASK_APP=time_tracker_api
7694
flask run
7795
```
7896
79-
- Open `http://127.0.0.1:5000/` in a browser. You will find in the presented UI
97+
- Open `http://127.0.0.1:5000/` in a browser. You will find in the presented UI
8098
a link to the swagger.json with the definition of the api.
8199
82100
#### Handling Cosmos DB triggers for creating events with time_tracker_events
@@ -114,24 +132,24 @@ generated by the console app you ran before. For instance, this is the log gener
114132
```
115133

116134
### Security
117-
In this API we are requiring authenticated users using JWT. To do so, we are using the library
118-
[PyJWT](https://pypi.org/project/PyJWT/), so in every request to the API we expect a header `Authorization` with a format
135+
In this API we are requiring authenticated users using JWT. To do so, we are using the library
136+
[PyJWT](https://pypi.org/project/PyJWT/), so in every request to the API we expect a header `Authorization` with a format
119137
like:
120138

121139
>Bearer <JWT>
122140
123141
In the Swagger UI, you will now see a new button called "Authorize":
124142
![image](https://user-images.githubusercontent.com/6514740/80011459-841f7580-8491-11ea-9c23-5bfb8822afe6.png)
125143

126-
when you click it then you will be notified that you must enter the content of the Authorization header, as mentioned
144+
when you click it then you will be notified that you must enter the content of the Authorization header, as mentioned
127145
before:
128146
![image](https://user-images.githubusercontent.com/6514740/80011702-d95b8700-8491-11ea-973a-8aaf3cdadb00.png)
129147

130-
Click "Authorize" and then close that dialog. From that moment forward you will not have to do it anymore because the
148+
Click "Authorize" and then close that dialog. From that moment forward you will not have to do it anymore because the
131149
Swagger UI will use that JWT in every call, e.g.
132150
![image](https://user-images.githubusercontent.com/6514740/80011852-0e67d980-8492-11ea-9dd3-2b1efeaa57d8.png)
133151

134-
If you want to check out the data (claims) that your JWT contains, you can also use the CLI of
152+
If you want to check out the data (claims) that your JWT contains, you can also use the CLI of
135153
[PyJWT](https://pypi.org/project/PyJWT/):
136154
```
137155
pyjwt decode --no-verify "<JWT>"
@@ -143,7 +161,7 @@ Bear in mind that this API is not in charge of verifying the authenticity of the
143161
Due to the used technology and particularities on the implementation of this API, it is important that you respect the
144162
following notes regarding to the manipulation of the data from and towards the API:
145163

146-
- The [recommended](https://docs.microsoft.com/en-us/azure/cosmos-db/working-with-dates#storing-datetimes) format for
164+
- The [recommended](https://docs.microsoft.com/en-us/azure/cosmos-db/working-with-dates#storing-datetimes) format for
147165
DateTime strings in Azure Cosmos DB is `YYYY-MM-DDThh:mm:ss.fffffffZ` which follows the ISO 8601 **UTC standard**.
148166

149167
The Azure function project `time_tracker_events` also have some constraints to have into account. It is recommended that
@@ -164,7 +182,7 @@ We use [pre-commit](https://github.com/pre-commit/pre-commit) library to manage
164182
```
165183
pre-commit install -t pre-commit -t commit-msg
166184
```
167-
With this command the library will take configuration from `.pre-commit-config.yaml` and will set up the hooks by us.
185+
With this command the library will take configuration from `.pre-commit-config.yaml` and will set up the hooks by us.
168186

169187

170188
### Commit message style
@@ -176,27 +194,35 @@ Use the following commit message style. e.g:
176194
```
177195
The value `TT-###` refers to the Jira issue that is being solved. Use TT-00 if the commit does not refer to any issue.
178196

197+
### Branch names format
198+
For example if your task in Jira is **TT-48 implement semantic versioning** your branch name is:
199+
```
200+
TT-48-implement-semantic-versioning
201+
```
202+
179203
### Test
180-
We are using [Pytest](https://docs.pytest.org/en/latest/index.html) for tests. The tests are located in the package
204+
We are using [Pytest](https://docs.pytest.org/en/latest/index.html) for tests. The tests are located in the package
181205
`tests` and use the [conventions for python test discovery](https://docs.pytest.org/en/latest/goodpractices.html#test-discovery).
182206

183207
#### Integration tests
184208
The [integrations tests](https://en.wikipedia.org/wiki/Integration_testing) verifies that all the components of the app
185209
are working well together. These are the default tests we should run:
186210

211+
This command run all tests:
187212
```dotenv
188213
python3 -m pytest -v --ignore=tests/commons/data_access_layer/azure/sql_repository_test.py
189214
```
190215

191-
```to run a sigle test
216+
To run a sigle test:
217+
```
192218
pytest -v -k name-test
193219
```
194220

195221
As you may have noticed we are ignoring the tests related with the repository.
196222

197223

198224
#### System tests
199-
In addition to the integration testing we might include tests to the data access layer in order to verify that the
225+
In addition to the integration testing we might include tests to the data access layer in order to verify that the
200226
persisted data is being managed the right way, i.e. it actually works. We may classify the execution of all the existing
201227
tests as [system testing](https://en.wikipedia.org/wiki/System_testing):
202228

@@ -205,12 +231,12 @@ python3 -m pytest -v
205231
```
206232

207233
The database tests will be done in the table `tests` of the database specified by the variable `SQL_DATABASE_URI`. If this
208-
variable is not specified it will automatically connect to SQLite database in-memory. This will do, because we are using
209-
[SQL Alchemy](https://www.sqlalchemy.org/features.html) to be able connect to any SQL database maintaining the same
234+
variable is not specified it will automatically connect to SQLite database in-memory. This will do, because we are using
235+
[SQL Alchemy](https://www.sqlalchemy.org/features.html) to be able connect to any SQL database maintaining the same
210236
codebase.
211237

212238

213-
The option `-v` shows which tests failed or succeeded. Have into account that you can also debug each test
239+
The option `-v` shows which tests failed or succeeded. Have into account that you can also debug each test
214240
(test_* files) with the help of an IDE like PyCharm.
215241

216242
#### Coverage
@@ -220,7 +246,7 @@ To check the coverage of the tests execute
220246
coverage run -m pytest -v
221247
```
222248

223-
To get a report table
249+
To get a report table
224250

225251
```bash
226252
coverage report
@@ -258,16 +284,16 @@ python cli.py gen_swagger_json -f ~/Downloads/swagger.json
258284
## Semantic versioning
259285

260286
### Style
261-
We use [angular commit message style](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#commits) as the
287+
We use [angular commit message style](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#commits) as the
262288
standard commit message style.
263289

264290
### Release
265-
1. The release is automatically done by the [TimeTracker CI](https://dev.azure.com/IOET-DevOps/TimeTracker-API/_build?definitionId=1&_a=summary)
266-
although can also be done manually. The variable `GH_TOKEN` is required to post releases to Github. The `GH_TOKEN` can
291+
1. The release is automatically done by the [TimeTracker CI](https://dev.azure.com/IOET-DevOps/TimeTracker-API/_build?definitionId=1&_a=summary)
292+
although can also be done manually. The variable `GH_TOKEN` is required to post releases to Github. The `GH_TOKEN` can
267293
be generated following [these steps](https://help.github.com/es/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line).
268294

269295
2. We use the command `semantic-release publish` after a successful PR to make a release. Check the library
270-
[python-semantic-release](https://python-semantic-release.readthedocs.io/en/latest/commands.html#publish) for details of
296+
[python-semantic-release](https://python-semantic-release.readthedocs.io/en/latest/commands.html#publish) for details of
271297
underlying operations.
272298

273299
## Run as docker container
@@ -294,14 +320,14 @@ pip install -r requirements/<app>/prod.txt
294320
pip install -r requirements/migrations.txt
295321
```
296322

297-
All the migrations will be handled and created in the python package `migrations`. In order to create a migration we
298-
must do it manually (for now) and prefixed by a number, e.g. `migrations/01-initialize-db.py` in order to guarantee the
323+
All the migrations will be handled and created in the python package `migrations`. In order to create a migration we
324+
must do it manually (for now) and prefixed by a number, e.g. `migrations/01-initialize-db.py` in order to guarantee the
299325
order of execution alphabetically.
300326
Inside every migration there is an `up` and `down` method. The `down` method is executed from the persisted migration in
301-
the database. When a `down` logic that used external dependencies was tested, it failed; whilst, I put that same logic in
327+
the database. When a `down` logic that used external dependencies was tested, it failed; whilst, I put that same logic in
302328
the `up` method, it run correctly. In general, the library seems to present [design issues](https://github.com/Lieturd/migrate-anything/issues/3).
303329
Therefore, it is recommended to apply changes just in one direction: `up`.
304-
For more information, please check out [some examples](https://github.com/Lieturd/migrate-anything/tree/master/examples)
330+
For more information, please check out [some examples](https://github.com/Lieturd/migrate-anything/tree/master/examples)
305331
that illustrate the usage of this migration tool.
306332

307333
Basically, for running the migrations you must execute:
@@ -314,7 +340,7 @@ They will be automatically run during the Continuous Deployment process.
314340

315341

316342
## Built with
317-
- [Python version 3](https://www.python.org/download/releases/3.0/) as backend programming language. Strong typing for
343+
- [Python version 3](https://www.python.org/download/releases/3.0/) as backend programming language. Strong typing for
318344
the win.
319345
- [Flask](http://flask.pocoo.org/) as the micro framework of choice.
320346
- [Flask RestPlus](https://flask-restplus.readthedocs.io/en/stable/) for building Restful APIs with Swagger.
@@ -331,6 +357,9 @@ for making `time_tracker_events` to handle the triggers [generated by our Cosmos
331357
Shared file with all the Feature Toggles we create, so we can have a history of them
332358
[Feature Toggles dictionary](https://github.com/ioet/time-tracker-ui/wiki/Feature-Toggles-dictionary)
333359

360+
## More information about the project
361+
[Starting in Time Tracker](https://github.com/ioet/time-tracker-ui/wiki/Time-tracker)
362+
334363
## License
335364

336365
Copyright 2020 ioet Inc. All Rights Reserved.

0 commit comments

Comments
 (0)