Skip to content

Commit d4da1e0

Browse files
committed
ci: replace deptry with ty for type checking and remove deptry dependency
1 parent 55a3226 commit d4da1e0

30 files changed

Lines changed: 2685 additions & 23 deletions

.github/actions/setup-python-env/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ runs:
2323
with:
2424
version: ${{ inputs.uv-version }}
2525
enable-cache: "true"
26-
cache-suffix: ${{ matrix.python-version }}
26+
cache-suffix: ${{ inputs.python-version }}
2727

2828
- name: Install Python dependencies
2929
run: uv sync --frozen

.github/workflows/main.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ jobs:
2424
- name: Run pre-commit
2525
run: uv run pre-commit run -a --show-diff-on-failure
2626

27-
- name: Inspect dependencies
28-
run: uv run deptry .
29-
3027
- name: Check lock file consistency
3128
run: uv sync --locked
3229

@@ -52,7 +49,7 @@ jobs:
5249
run: uv run python -m pytest tests --cov --cov-config=pyproject.toml --cov-report=xml
5350

5451
- name: Check typing
55-
run: uv run mypy
52+
run: uv run ty check
5653

5754
- name: Upload coverage reports to Codecov with GitHub Action on Python 3.11 for Ubuntu
5855
uses: codecov/codecov-action@v3

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
example-project
2-
cookiecutter-uv-example
2+
create-bindu-agent-example
33

44
# From https://raw.githubusercontent.com/github/gitignore/main/Python.gitignore
55

@@ -143,7 +143,7 @@ cython_debug/
143143
# Exclude .DS_Store files from being added
144144
.DS_Store
145145
example-project
146-
cookiecutter-uv-example
146+
create-bindu-agent-example
147147

148148
# From https://raw.githubusercontent.com/github/gitignore/main/Python.gitignore
149149

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ repos:
2323
args: [--exit-non-zero-on-fix]
2424
exclude: ^\{\{cookiecutter\.project_name\}\}/
2525
- id: ruff-format
26-
exclude: ^\{\{cookiecutter\.project_name\}\}/
26+
exclude: ^\{\{cookiecutter\.project_name\}\}/

Makefile

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
.PHONY: bake
2+
bake: ## bake without inputs and overwrite if exists.
3+
@uv run cookiecutter --no-input . --overwrite-if-exists
4+
5+
.PHONY: bake-with-inputs
6+
bake-with-inputs: ## bake with inputs and overwrite if exists.
7+
@uv run cookiecutter . --overwrite-if-exists
8+
9+
.PHONY: bake-and-test-deploy
10+
bake-and-test-deploy: ## For quick publishing to create-bindu-agent-example to test GH Actions
11+
@rm -rf create-bindu-agent-example || true
12+
@uv run cookiecutter --no-input . --overwrite-if-exists \
13+
author="Raahul Dutta" \
14+
email="dutta.raahul@gmail.com" \
15+
author_github_handle=raahulmona \
16+
project_name=create-bindu-agent-example
17+
@cd create-bindu-agent-example; uv sync && \
18+
git init -b main && \
19+
git add . && \
20+
uv run pre-commit install && \
21+
uv run pre-commit run -a || true && \
22+
git add . && \
23+
uv run pre-commit run -a || true && \
24+
git add . && \
25+
git commit -m "init commit" && \
26+
git remote add origin git@github.com:raahulmona/create-bindu-agent-example.git && \
27+
git push -f origin main
28+
29+
30+
.PHONY: install
31+
install: ## Install the virtual environment
32+
@echo "🚀 Creating virtual environment"
33+
@uv sync
34+
35+
.PHONY: check
36+
check: ## Run code quality tools.
37+
@echo "🚀 Checking lock file consistency with 'pyproject.toml'"
38+
@uv lock --locked
39+
@echo "🚀 Linting code: Running pre-commit"
40+
@uv run pre-commit run -a
41+
@echo "🚀 Static type checking: Running ty"
42+
@uv run ty check --exclude '\{\{cookiecutter.project_name\}\}/' --exclude 'create-bindu-agent-example/'
43+
44+
.PHONY: test
45+
test: ## Test the code with pytest.
46+
@echo "🚀 Testing code: Running pytest"
47+
@uv run python -m pytest --cov --cov-config=pyproject.toml --cov-report=xml tests
48+
49+
.PHONY: build
50+
build: clean-build ## Build wheel file
51+
@echo "🚀 Creating wheel file"
52+
@uvx --from build pyproject-build --installer uv
53+
54+
.PHONY: clean-build
55+
clean-build: ## Clean build artifacts
56+
@echo "🚀 Removing build artifacts"
57+
@uv run python -c "import shutil; import os; shutil.rmtree('dist') if os.path.exists('dist') else None"
58+
59+
.PHONY: publish
60+
publish: ## Publish a release to PyPI.
61+
@echo "🚀 Publishing: Dry run."
62+
@uvx --from build pyproject-build --installer uv
63+
@echo "🚀 Publishing."
64+
@uvx twine upload --repository-url https://upload.pypi.org/legacy/ dist/*
65+
66+
.PHONY: build-and-publish
67+
build-and-publish: build publish ## Build and publish.
68+
69+
.PHONY: docs-test
70+
docs-test: ## Test if documentation can be built without warnings or errors
71+
@uv run mkdocs build -s
72+
73+
.PHONY: docs
74+
docs: ## Build and serve the documentation
75+
@uv run mkdocs serve
76+
77+
.PHONY: help
78+
help:
79+
@uv run python -c "import re; \
80+
[[print(f'\033[36m{m[0]:<20}\033[0m {m[1]}') for m in re.findall(r'^([a-zA-Z_-]+):.*?## (.*)$$', open(makefile).read(), re.M)] for makefile in ('$(MAKEFILE_LIST)').strip().split()]"
81+
82+
.DEFAULT_GOAL := help

cookiecutter-uv-example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 575d8d2982ccbd36c479f51c3d88c21ace4430c5

cookiecutter.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,6 @@
7474
"ty",
7575
"none"
7676
],
77-
"deptry": [
78-
"y",
79-
"n"
80-
],
8177
"storage_type": [
8278
"memory",
8379
"postgres(not implemented)"

docs/assets/light.svg

Lines changed: 18 additions & 0 deletions
Loading

docs/features/cicd.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# CI/CD with Github actions
2+
3+
when `include_github_actions` is set to `"y"`, a `.github` directory is
4+
added with the following structure:
5+
6+
.github
7+
├── workflows
8+
├─── run-checks
9+
│ └── action.yml
10+
├─── setup-python-env
11+
│ └── action.yml
12+
├── on-merge-to-main.yml
13+
├── on-pull-request.yml
14+
└── on-release-main.yml
15+
16+
`on-merge-to-main.yml` and `on-pull-request.yml` are identical except
17+
for their trigger conditions; the first is run whenever a new commit is
18+
made to `main` (which should
19+
[only](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/about-protected-branches)
20+
happen through merge requests, hence the name), and the latter is run
21+
whenever a pull request is opened or updated. They call the `action.yml`
22+
files to set-up the environment, run the tests, and check the code
23+
formatting.
24+
25+
`on-release-main.yml` does all of the former whenever a new release is
26+
made on the `main` branch. In addition, `on-release-main.yml` also
27+
publishes the project to PyPI if `publish_to_pypi` is set to
28+
`"y"`, and it builds and deploys the documentation
29+
if `mkdocs` is set to `"y"`. To learn more about these features,
30+
see [Publishing to PyPI](./publishing.md) and [Documentation with MkDocs](./mkdocs.md)
31+
32+
Additionally, all workflows check for compatibility with multiple Python
33+
versions if `tox` is set to `"y"`.
34+
35+
## How to trigger a release?
36+
37+
To trigger a new release, navigate to your repository on GitHub, click `Releases` on the right, and then select `Draft
38+
a new release`. If you fail to find the button, you could also directly visit
39+
`https://github.com/<username>/<repository-name>/releases/new`.
40+
41+
Give your release a title, and add a new tag in the form `*.*.*` where the
42+
`*`'s are alphanumeric. To finish, press `Publish release`.

docs/features/codecov.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Test coverage with codecov
2+
3+
If `codecov` is set to `"y"`, `pytest-cov` is added as a development dependency,
4+
and `make test` will run the tests and output a coverage report as `coverage.xml`.
5+
If `include_github_actions` is set to `"y"`, coverage tests with [codecov](https://about.codecov.io/) are added to the CI/CD pipeline. To enable this, sign up at [codecov.io](https://about.codecov.io/) with your GitHub account.
6+
If codecov is configured to require token authentication for the upload, then follow the [instructions](https://docs.codecov.com/docs/codecov-tokens#types-of-tokens) for token generation and how to add it on your GitHub repository.
7+
Additionally, a `codecov.yaml` file is created, with the following defaults:
8+
9+
```yaml
10+
# Badge color changes from red to green between 70% and 100%
11+
# PR pipeline fails if codecov falls with 1%
12+
13+
coverage:
14+
range: 70..100
15+
round: down
16+
precision: 1
17+
status:
18+
project:
19+
default:
20+
target: auto
21+
threshold: 1%
22+
23+
# Ignoring Paths
24+
# --------------
25+
# which folders/files to ignore
26+
ignore:
27+
- "foo/bar.py"
28+
```
29+
30+
If `codecov` is set to `"n"`, `pytest-cov` is not added to the development dependencies and the github actions won't produce a coverage report.

0 commit comments

Comments
 (0)