Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/github_actions/actions/deploy-p…
Browse files Browse the repository at this point in the history
…ages-4
  • Loading branch information
yuval9313 authored Nov 12, 2024
2 parents 56680b9 + 1c2cbcd commit 16073fc
Show file tree
Hide file tree
Showing 22 changed files with 1,642 additions and 1,182 deletions.
14 changes: 9 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{
"name": "fastapi-37",
"image": "mcr.microsoft.com/devcontainers/python:3.12",
"name": "fastapi-38",
"image": "mcr.microsoft.com/devcontainers/python:1-3.8-bookworm",
"features": {
"ghcr.io/devcontainers/features/node:1": { "version": "latest" }
"ghcr.io/devcontainers/features/node:1": {
"version": "latest"
}
},
"postCreateCommand": "pipx install poetry && poetry install",
"forwardPorts": [2222]
}
"forwardPorts": [
2222
]
}
22 changes: 22 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
changelog:
exclude:
labels:
- ignore-for-release
categories:
- title: Breaking Changes 🛠
labels:
- Semver-Major
- breaking-change
- title: Exciting New Features 🎉
labels:
- Semver-Minor
- enhancement
- title: Other Changes
labels:
- "*"
exclude:
labels:
- dependencies
- title: 👒 Dependencies
labels:
- dependencies
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
max-parallel: 3
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v4
Expand All @@ -23,10 +23,10 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Init python poetry action
uses: abatilo/actions-poetry@v2.3.0
uses: abatilo/actions-poetry@v3.0.0
with:
poetry-version: 1.5.1
- uses: actions/cache@v3
- uses: actions/cache@v4
id: cache-deps
with:
path: ~/.cache/pip
Expand All @@ -37,11 +37,11 @@ jobs:
- name: Install dependencies
run: poetry install -E session

- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: .mypy_cache
key: mypy-${{ matrix.python-version }}
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: .pytest_cache
key: pytest-${{ matrix.python-version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
python-version: ${{ matrix.python-version }}
# Avoid caching to be 100% confident things are working properly
- name: Init python poetry action
uses: abatilo/actions-poetry@v2.3.0
uses: abatilo/actions-poetry@v3.0.0
with:
poetry-version: 1.5.1

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
python-version: ${{ matrix.python-version }}
# Avoid caching to be 100% confident things are working properly
- name: Init python poetry action
uses: abatilo/actions-poetry@v2.3.0
uses: abatilo/actions-poetry@v3.0.0
with:
poetry-version: 1.5.1

Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: build-pull-request
name: tests-pull-request

on:
pull_request:
Expand All @@ -11,7 +11,7 @@ jobs:
strategy:
max-parallel: 3
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v4
Expand All @@ -21,10 +21,10 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Init Python Poetry Action
uses: abatilo/actions-poetry@v2.3.0
uses: abatilo/actions-poetry@v3.0.0
with:
poetry-version: 1.5.1
- uses: actions/cache@v3
- uses: actions/cache@v4
id: cache-deps
with:
path: ~/.cache/pip
Expand All @@ -34,11 +34,11 @@ jobs:
- name: Install dependencies
run: poetry install -E session
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: .mypy_cache
key: mypy-${{ matrix.python-version }}
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: .pytest_cache
key: pytest-${{ matrix.python-version }}
Expand Down
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ venv/
.venv/
env3*/

# Repo files that copied into docs
docs/index.md
docs/release-notes.md
docs/contributing.md

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Latest changes

* Fix: tasks.repeat_every() and related tests [#305](https://github.com/dmontagu/fastapi-utils/issues/305)
* Fix typo [#306](https://github.com/dmontagu/fastapi-utils/issues/306)
* Merge with [fastapi-utils](https://github.com/dmontagu/fastapi-utils)

## 0.6.0
Expand Down
9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ test:
format:
black $(all_src)
black -l 82 $(docs_src)
ruff --fix $(all_src)
ruff check --fix $(all_src)

.PHONY: lint
lint:
ruff $(all_src)
ruff check $(all_src)
black --check --diff $(all_src)
black -l 82 $(docs_src) --check --diff

Expand All @@ -47,11 +47,10 @@ testcov:
fi

.PHONY: ci-v1 ## Run all CI validation steps without making any changes to code in pydantic v1

ci-v1: install-v1 lint test


.PHONY: ci-v1 ## Run all CI validation steps without making any changes to code in pydantic v2
.PHONY: ci-v2 ## Run all CI validation steps without making any changes to code in pydantic v2
ci-v2: install-v2 lint mypy test


Expand Down Expand Up @@ -108,7 +107,7 @@ docs-build:

.PHONY: docs-format ## Format the python code that is part of the docs
docs-format:
ruff $(docs_src)
ruff check $(docs_src)
autoflake -r --remove-all-unused-imports --ignore-init-module-imports $(docs_src) -i
black -l 82 $(docs_src)

Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
</p>
<p align="center">
<a href="https://github.com/dmontagu/fastapi-utils" target="_blank">
<img src="https://img.shields.io/github/last-commit/dmontagu/fastapi-utils.svg">
<img src="https://github.com/dmontagu/fastapi-utils/workflows/build/badge.svg" alt="Build CI">
<img src="https://img.shields.io/github/last-commit/dmontagu/fastapi-utils.svg">
<img src="https://github.com/dmontagu/fastapi-utils/workflows/build/badge.svg" alt="Build CI">
</a>
<a href="https://codecov.io/gh/dmontagu/fastapi-utils" target="_blank">
<img src="https://codecov.io/gh/dmontagu/fastapi-utils/branch/master/graph/badge.svg" alt="Coverage">
Expand All @@ -20,13 +20,13 @@
</p>

---
**Documentation**: <a href="https://fastapi-utils.davidmontague.xyz" target="_blank">https://fastapi-utils.davidmontague.xyz</a>
**Documentation**: <a href="https://fastapiutils.github.io/fastapi-utils/" target="_blank">https://fastapiutils.github.io/fastapi-utils/</a>

**Source Code**: <a href="https://github.com/dmontagu/fastapi-utils" target="_blank">https://github.com/dmontagu/fastapi-utils</a>

---

<a href="https://fastapi.tiangolo.com">FastAPI</a> is a modern, fast web framework for building APIs with Python 3.7+.
<a href="https://fastapi.tiangolo.com">FastAPI</a> is a modern, fast web framework for building APIs with Python 3.8+.

But if you're here, you probably already knew that!

Expand All @@ -53,20 +53,20 @@ It also adds a variety of more basic utilities that are useful across a wide var
* **CamelCase Conversions**: Convenience functions for converting strings from `snake_case` to `camelCase` or `PascalCase` and back
* **GUID Type**: The provided GUID type makes it easy to use UUIDs as the primary keys for your database tables

See the [docs](https://https://fastapi-utils.davidmontague.xyz/) for more details and examples.
See the [docs](https://fastapiutils.github.io/fastapi-utils//) for more details and examples.

## Requirements

This package is intended for use with any recent version of FastAPI (depending on `pydantic>=1.0`), and Python 3.7+.
This package is intended for use with any recent version of FastAPI (depending on `pydantic>=1.0`), and Python 3.8+.

## Installation

```bash
pip install fastapi-restful # For basic slim package :)
pip install fastapi-utils # For basic slim package :)

pip install fastapi-restful[session] # To add sqlalchemy session maker
pip install fastapi-utils[session] # To add sqlalchemy session maker

pip install fastapi-restful[all] # For all the packages
pip install fastapi-utils[all] # For all the packages
```

## License
Expand Down
135 changes: 135 additions & 0 deletions docs/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
First, you might want to see the basic ways to [help and get help](help-fastapi-utils.md){.internal-link target=_blank}.

## Developing

Once you've cloned the repository, here are some guidelines to set up your environment:

### Set up the development evironment

After cloning the repository, you can use `poetry` to create a virtual environment:

```console
$ make develop
```

Behind the scenes, this checks that you have python3 and poetry installed,
then creates a virtual environment and installs the dependencies. At the end, it will print out
the path to the executable in case you want to add it to your IDE.


### Activate the environment

Once the virtual environment is created, you can activate it with:

```console
$ poetry shell
```

To check if this worked, try running:

```console
$ which python

some/directory/fastapi-utils-SOMETHING-py3.X/bin/python
```

If the output of this command shows the `python` binary in a path containing `fastapi-utils` somewhere in the name
(as above), then it worked! 🎉

!!! tip
Every time you install a new package with `pip` under that environment, activate the environment again.

This makes sure that if you use a terminal program installed by that package (like `mypy`),
you use the one from your local environment and not any other that could be installed globally.

### Static Code Checks

This project makes use of `black`, `autoflake8`, and `isort` for formatting,
`flake8` for linting, and `mypy` for static type checking.


To auto-format your code, just run:

```console
$ make format
```

It will also auto-sort all your imports, and attempt to remove any unused imports.

You can run flake8 with:

```console
$ make lint
```

and you can run mypy with:

```console
$ make mypy
```

There are a number of other useful makefile recipes; you can see basic documentation of these by calling plain `make`:

```console
$ make
```


## Docs

The documentation uses <a href="https://www.mkdocs.org/" class="external-link" target="_blank">MkDocs</a>.

All the documentation is in Markdown format in the directory `./docs`.

Many of the sections in the User Guide have blocks of code.

In fact, those blocks of code are not written inside the Markdown, they are Python files in the `./docs/src/` directory.

And those Python files are included/injected in the documentation when generating the site.

### Docs for tests

Most of the tests actually run against the example source files in the documentation.

This helps making sure that:

* The documentation is up to date.
* The documentation examples can be run as is.
* Most of the features are covered by the documentation, ensured by test coverage.

During local development, there is a script that builds the site and checks for any changes, live-reloading:

```console
$ bash scripts/docs-live.sh
```

It will serve the documentation on `http://0.0.0.0:8008`.

That way, you can edit the documentation/source files and see the changes live.

## Tests

You can run all tests via:

```console
$ make test
```

You can also generate a coverage report with:

```console
make testcov
```

On MacOS, if the tests all pass, the coverage report will be opened directly in a browser; on other operating systems
a link will be printed to the local HTML containing the coverage report.

### Tests in your editor

If you want to use the integrated tests in your editor add `./docs/src` to your `PYTHONPATH` variable.

For example, in VS Code you can create a file `.env` with:

```env
PYTHONPATH=./docs/src
```
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ You can connect with the maintainer on

## Create issues

You can <a href="https://github.com/dmontagu/fastapis-utils/issues/new/choose" class="external-link" target="_blank">create a new issue</a> in the GitHub repository, for example to:
You can <a href="https://github.com/dmontagu/fastapi-utils/issues/new/choose" class="external-link" target="_blank">create a new issue</a> in the GitHub repository, for example to:

* Report a bug/issue.
* Suggest a new feature.
Expand Down
Loading

0 comments on commit 16073fc

Please sign in to comment.