Skip to content

Commit

Permalink
Update Makefile, add changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
bigbag committed Oct 17, 2024
1 parent d8aba52 commit 833be91
Show file tree
Hide file tree
Showing 9 changed files with 189 additions and 58 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,13 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --no-cache-dir -e .
pip install --no-cache-dir -r requirements/linters.txt
pip install --no-cache-dir -r requirements/tests.txt
make venv/install
- name: Lint
run: |
make lint
make dev/lint
- name: Test
run: |
make test
make dev/test
- name: "Upload coverage to Codecov"
uses: codecov/codecov-action@v4
with:
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,13 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --no-cache-dir -e .
pip install --no-cache-dir -r requirements/linters.txt
pip install --no-cache-dir -r requirements/tests.txt
make venv/install
- name: Lint
run: |
make lint
make dev/lint
- name: Test
run: |
make test
make dev/test
- name: "Upload coverage to Codecov"
uses: codecov/codecov-action@v4
with:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ target/
.ipynb_checkpoints
venv/*
env/*
.venv/*
.env/*

address.txt
private_keys.txt
Expand Down
75 changes: 75 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@


## 0.8.0 (2024-10-17)

* Add support for python 3.12 and 3.13 (#10) [Pavel Liashkov]
* Update github pipeline [Pavel Liashkov]
* Update version [Pavel Liashkov]


## 0.7.0 (2023-08-03)

* Update pipeline [Pavel Liashkov]
* Update version [Pavel Liashkov]


## 0.6.0 (2021-07-26)

* Relax starlette version [Pavel Liashkov]


## 0.5.0 (2021-07-23)

* Bump starlette from 0.15.0 to 0.16.0 (#8) [dependabot[bot]]
* Update version.py [Pavel Liashkov]


## 0.4.0 (2021-06-24)

* Bump starlette from 0.14.2 to 0.15.0 (#6) [dependabot[bot]]
* Update version.py [Pavel Liashkov]


## 0.3.6 (2021-02-23)

* Add codecov settings [Pavel Liashkov]


## 0.3.5 (2021-02-20)

* Update Makefile [Pavel Liashkov]
* Bump version [Pavel Liashkov]


## 0.3.4 (2021-02-12)

* Update readme (#5) [Pavel Liashkov]


## 0.3.3 (2021-02-06)

* Update readme (#4) [Pavel Liashkov]
* Fix write mistake [Pavel Liashkov]


## 0.3.2 (2021-02-04)

* Bump starlette from 0.14.1 to 0.14.2 (#3) [dependabot[bot]]
* Bump version [Pavel Liashkov]


## 0.3.1 (2021-01-23)

* Fix package format [Pavel Liashkov]
* Fix package description [Pavel Liashkov]


## 0.3.0 (2021-01-17)

* Update readme (#2) [Pavel Liashkov]


## 0.2.0 (2021-01-16)

* Add logger extra factory [pavel.liashkov]

120 changes: 102 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,46 @@
.PHONY: tag
tag:
@echo "Create tag"
@git checkout main;
@git pull origin main;
@git fetch;
@git tag -a $(name) -m "$(name)";
@git push origin $(name);
@git push origin main
.PHONY: sys/changelog
## Generating changelog file
sys/changelog:
@echo "Generating CHANGELOG.md..."
@echo "" > CHANGELOG.md;
@previous_tag=0; \
for current_tag in $$(git tag --sort=-creatordate); do \
if [ "$$previous_tag" != 0 ]; then \
tag_date=$$(git log -1 --pretty=format:'%ad' --date=short $${previous_tag}); \
printf "\n## $${previous_tag} ($${tag_date})\n\n" >> CHANGELOG.md; \
git log $${current_tag}...$${previous_tag} --pretty=format:'* %s [%an]' --reverse | grep -v Merge >> CHANGELOG.md; \
printf "\n" >> CHANGELOG.md; \
fi; \
previous_tag=$${current_tag}; \
done
@echo "CHANGELOG.md generated successfully."

.PHONY: lint
lint:
.PHONY: sys/tag
## Create and push tag
sys/tag:
@read -p "Enter tag version (e.g., 1.0.0): " TAG; \
if [[ $$TAG =~ ^[0-9]+\.[0-9]+\.[0-9]+$$ ]]; then \
git tag -a $$TAG -m $$TAG; \
git push origin $$TAG; \
echo "Tag $$TAG created and pushed successfully."; \
else \
echo "Invalid tag format. Please use X.Y.Z (e.g., 1.0.0)"; \
exit 1; \
fi

.PHONY: venv/install
## Install dev and lint dependencies
venv/install:
@echo "install virtual environment..."
@exec python -m pip install --upgrade pip
@exec pip install --no-cache-dir -e .
@exec pip install --no-cache-dir -r requirements/linters.txt
@exec pip install --no-cache-dir -r requirements/tests.txt
@exec make dev/clean

.PHONY: dev/lint
## Running all linters
dev/lint:
@echo "Run isort"
@exec isort .
@echo "Run black"
Expand All @@ -22,14 +53,16 @@ lint:
@exec mypy starlette_request_id
@exec rm -rf .mypy_cache

.PHONY: test
test:
.PHONY: dev/test
## Run all tests
dev/test:
@echo "Run tests"
PYTHONPATH=${PYTHONPATH} PYTHONASYNCIODEBUG=x py.test -svvv -rs --cov starlette_request_id --cov-report term-missing -x
@exec rm -rf .pytest_cache

.PHONY: clean
clean:
.PHONY: dev/clean
## Clear temp files
dev/clean:
@echo "Clear temp files"
@rm -rf `find . -name __pycache__`
@rm -rf `find . -type f -name '*.py[co]' `
Expand All @@ -53,8 +86,59 @@ clean:
@rm -rf .pytest_cache
@rm -rf dist

.DEFAULT_GOAL := help

# Inspired by <http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html>
# sed script explained:
# /^##/:
# * save line in hold space
# * purge line
# * Loop:
# * append newline + line to hold space
# * go to next line
# * if line starts with doc comment, strip comment character off and loop
# * remove target prerequisites
# * append hold space (+ newline) to line
# * replace newline plus comments by `---`
# * print line
# Separate expressions are necessary because labels cannot be delimited by
# semicolon; see <http://stackoverflow.com/a/11799865/1968>
.PHONY: help
help:
@echo -n "Common make targets"
@echo ":"
@cat Makefile | sed -n '/^\.PHONY: / h; /\(^\t@*echo\|^\t:\)/ {H; x; /PHONY/ s/.PHONY: \(.*\)\n.*"\(.*\)"/ make \1\t\2/p; d; x}'| sort -k2,2 |expand -t 20
@echo "$$(tput bold)Available rules:$$(tput sgr0)"
@echo
@sed -n -e "/^## / { \
h; \
s/.*//; \
:doc" \
-e "H; \
n; \
s/^## //; \
t doc" \
-e "s/:.*//; \
G; \
s/\\n## /---/; \
s/\\n/ /g; \
p; \
}" ${MAKEFILE_LIST} \
| LC_ALL='C' sort --ignore-case \
| awk -F '---' \
-v ncol=$$(tput cols) \
-v indent=19 \
-v col_on="$$(tput setaf 6)" \
-v col_off="$$(tput sgr0)" \
'{ \
printf "%s%*s%s ", col_on, -indent, $$1, col_off; \
n = split($$2, words, " "); \
line_length = ncol - indent; \
for (i = 1; i <= n; i++) { \
line_length -= length(words[i]) + 1; \
if (line_length <= 0) { \
line_length = ncol - indent - length(words[i]) - 1; \
printf "\n%*s ", -indent, " "; \
} \
printf "%s ", words[i]; \
} \
printf "\n"; \
}' \
| more $(shell test $(shell uname) = Darwin && echo '--no-init --raw-control-chars')
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

**starlette-request-id** is a helper for starlette to add request id in logger.

* [Project Changelog](CHANGELOG.md)

## Installation

starlette-request-id is available on PyPI.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
platforms=["POSIX"],
classifiers=CLASSIFIERS,
python_requires=">=3.7",
install_requires=["starlette>=0.12,<1.0"],
install_requires=["request-id-helper", "starlette>=0.12,<1.0"],
packages=find_packages(),
include_package_data=True,
zip_safe=False,
Expand Down
21 changes: 0 additions & 21 deletions starlette_request_id/context.py

This file was deleted.

7 changes: 1 addition & 6 deletions starlette_request_id/helper.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from . import context


class RequestIdCtx(context.ContextStorage):
CONTEXT_KEY_NAME = "request_id"

from request_id_helper import RequestIdCtx

request_id_ctx = RequestIdCtx()

0 comments on commit 833be91

Please sign in to comment.