Skip to content

Commit

Permalink
Switch to GitHub actions, update dependencies and pre-commit hooks ... (
Browse files Browse the repository at this point in the history
#39)

Included changes:
- Switch from Travis-CI to GitHub actions.
- Add pre-commit hook and configs for prettier, reformat files accordingly.
- Update dependencies.
- Update pre-commit hooks.
- Update links to GitHub repo due to organization rename.
- Switch to poetry-core.
- Bump version to 0.3.0.
  • Loading branch information
joakimnordling authored Aug 4, 2022
1 parent 0cd3619 commit 091e150
Show file tree
Hide file tree
Showing 9 changed files with 449 additions and 478 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build and upload to PyPI

on:
push:
tags:
- "*"

jobs:
build_and_upload:
name: Build and upload
runs-on: ubuntu-latest
steps:
- name: Checkout 🔁
uses: actions/checkout@v3

- name: Set up Python 🐍
uses: actions/setup-python@v4
with:
python-version: "3.9"

- name: Setup GCloud SDK 📦
uses: google-github-actions/[email protected]

- name: Install Firestore emulator 🚧
run: |
gcloud components install beta cloud-firestore-emulator
- name: Start Firestore emulator 🚦
run: |
gcloud --quiet beta emulators firestore start --host-port 127.0.0.1:8686 > /dev/null 2>&1 &
- name: Install Poetry and pre-commit 💈
run: pip install poetry pre-commit

- name: Install dependencies 🛠
run: poetry install

- name: Run pre-commit 🤔
run: pre-commit run --all-files

- name: Run tests 🌈
run: poetry run invoke test

- name: Publish package to PyPI 🙌
run: |
set -e
poetry config http-basic.pypi "__token__" "${PYPI_TOKEN}"
poetry publish --build
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
44 changes: 44 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Test the library

on:
pull_request:
types: [opened, synchronize, edited]

jobs:
run_tests:
name: Run tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
steps:
- name: Checkout 🔁
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }} 🐍
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Setup GCloud SDK 📦
uses: google-github-actions/[email protected]

- name: Install Firestore emulator 🚧
run: |
gcloud components install beta cloud-firestore-emulator
- name: Start Firestore emulator 🚦
run: |
gcloud --quiet beta emulators firestore start --host-port 127.0.0.1:8686 > /dev/null 2>&1 &
- name: Install Poetry and pre-commit 💈
run: pip install poetry pre-commit

- name: Install dependencies 🛠
run: poetry install

- name: Run pre-commit 🤔
run: pre-commit run --all-files

- name: Run tests 🌈
run: poetry run invoke test
18 changes: 11 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -13,12 +13,12 @@ repos:
# All non-bat files should end with LF
- id: mixed-line-ending
name: Ensure LF endings on most files
args: [ '--fix=lf' ]
args: ["--fix=lf"]
exclude: \.bat$
# Bat files should end with CRLF
- id: mixed-line-ending
name: Ensure CFLF endings on Windows files
args: [ '--fix=crlf' ]
args: ["--fix=crlf"]
files: \.bat$
- repo: local
hooks:
Expand All @@ -27,15 +27,19 @@ repos:
entry: poetry run invoke unasync
language: system
pass_filenames: false
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.5.1
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 22.6.0
hooks:
- id: black
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
rev: 4.0.1
hooks:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
hooks:
- id: prettier
18 changes: 18 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
printWidth: 88,
trailingComma: "es5",
useTabs: false,
tabWidth: 2,
semi: false,
singleQuote: false,
endOfLine: "lf",
proseWrap: "always",
overrides: [
{
files: "*.yaml",
options: {
proseWrap: "preserve",
},
},
],
}
46 changes: 0 additions & 46 deletions .travis.yml

This file was deleted.

97 changes: 57 additions & 40 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,29 @@

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.3.0] - 2022-08-04

### Changed

- Update dependencies.
- Switch from Travis CI to GitHub actions.
- Update pre-commit hooks.
- Update links to GitHub repo due to organization rename.
- Switch to poetry-core.

### Added

- Add pre-commit hook and configs for prettier.

## [0.2.8] - 2021-10-26

### Fixed

- Validate special characters in document ID and ensure `get_by_id`/`get_by_doc_id`
raises `ModelNotFoundError` in case of such issues. Especially an uneven number of
slashes could raise a ValueError. Saving a model can now raise an `InvalidDocumentID`
Expand All @@ -19,45 +33,52 @@ and this project adheres to
## [0.2.7] - 2021-10-25

### Fixed

- `get_by_id`/`get_by_doc_id` with an empty string raises a `ModelNotFoundError` instead
of leaking a `google.api_core.exceptions.InvalidArgument` exception.
of leaking a `google.api_core.exceptions.InvalidArgument` exception.

## [0.2.6] - 2021-09-20

### Added

- Support for subcollections

### Fixed

- Fixing support for `_` prefixed document ID attributes

## [0.2.5] - 2021-08-20

### Added

- Support for customizing the field used to hold the document ID. By subclassing the
`AsyncBareModel`/`BareModel` it's possible to use any field for the document ID, not
just the `id`, which is used by `AsyncModel`/`Model`.

### Changed

- Update `grpcio` to `^1.39.0` which fixes a problem with emulator support on Windows.
- Pre-commit hooks for keeping line-endings consistent.

### Fixed

- Incorrect links in CHANGELOG.md

## [0.2.4] - 2021-05-24

### Fixed

- Allow firedantic to be used with older versions of `google-cloud-firestore` that
works with the firestore emulator on Windows.
- Allow firedantic to be used with older versions of `google-cloud-firestore` that works
with the firestore emulator on Windows.

## [0.2.3] - 2021-05-21

### Added

- `firedantic.operators` with operators as constants to avoid gotchas with filters like
`not-in` and `array_contains`. Preferable way to build queries is to
`import firedantic.operators as op` and then use
`op.NOT_IN`, `op.ARRAY_CONTAINS`, `op.GTE` and so on.
`import firedantic.operators as op` and then use `op.NOT_IN`, `op.ARRAY_CONTAINS`,
`op.GTE` and so on.

### Fixed

Expand All @@ -74,15 +95,13 @@ of leaking a `google.api_core.exceptions.InvalidArgument` exception.

- Make the filter optional for `find` and `find_one`


## [0.2.1] - 2021-03-31

### Changed

- Update `google-cloud-firestore` to 2.1.0 that supports async with firestore
emulator. Using an officially released version of `google-cloud-firestore`
from PyPI will also make it possible to get this release of `firedantic`
uploaded to PyPI.
- Update `google-cloud-firestore` to 2.1.0 that supports async with firestore emulator.
Using an officially released version of `google-cloud-firestore` from PyPI will also
make it possible to get this release of `firedantic` uploaded to PyPI.

## [0.2.0] - 2021-03-29

Expand All @@ -92,23 +111,20 @@ of leaking a `google.api_core.exceptions.InvalidArgument` exception.

### Changed

- Refactor file structure; `models.py` no longer exists, so make sure to import
`Model` directly from firedantic: `from firedantic import Model`
- Update `google-cloud-firestore`. The 2.0.2 version has an [issue
with running in async mode against the emulator](https://github.com/googleapis/python-firestore/issues/286),
that has been fixed in the git `master`, but not included in any official
release yet. Using the latest master (pinned to the commit hash). In case you
are using poetry to install `firedantic`, please be aware that poetry has an
[issue with updating from a pypi package to a git
commit](https://github.com/python-poetry/poetry/issues/3803).
- Refactor file structure; `models.py` no longer exists, so make sure to import `Model`
directly from firedantic: `from firedantic import Model`
- Update `google-cloud-firestore`. The 2.0.2 version has an
[issue with running in async mode against the emulator](https://github.com/googleapis/python-firestore/issues/286),
that has been fixed in the git `master`, but not included in any official release yet.
Using the latest master (pinned to the commit hash). In case you are using poetry to
install `firedantic`, please be aware that poetry has an
[issue with updating from a pypi package to a git commit](https://github.com/python-poetry/poetry/issues/3803).
The simplest work-around is to after updating `firedantic` (and thus also
`google-cloud-firestore`) delete the virtualenv and then run `poetry install`
again
`google-cloud-firestore`) delete the virtualenv and then run `poetry install` again
- Update `pydantic` to 1.8.1 and `grpcio` to 1.36.1
- Fixes for Mypy errors and warnings
- Updated examples in README


## [0.1.4] - 2020-12-08

### Added
Expand Down Expand Up @@ -161,18 +177,19 @@ of leaking a `google.api_core.exceptions.InvalidArgument` exception.
- Update README.md
- Update .gitignore

[Unreleased]: https://github.com/digitalliving/firedantic/compare/0.2.8...HEAD
[0.2.8]: https://github.com/digitalliving/firedantic/compare/0.2.7...0.2.8
[0.2.7]: https://github.com/digitalliving/firedantic/compare/0.2.6...0.2.7
[0.2.6]: https://github.com/digitalliving/firedantic/compare/0.2.5...0.2.6
[0.2.5]: https://github.com/digitalliving/firedantic/compare/0.2.4...0.2.5
[0.2.4]: https://github.com/digitalliving/firedantic/compare/0.2.3...0.2.4
[0.2.3]: https://github.com/digitalliving/firedantic/compare/0.2.2...0.2.3
[0.2.2]: https://github.com/digitalliving/firedantic/compare/0.2.1...0.2.2
[0.2.1]: https://github.com/digitalliving/firedantic/compare/0.2.0...0.2.1
[0.2.0]: https://github.com/digitalliving/firedantic/compare/0.1.4...0.2.0
[0.1.4]: https://github.com/digitalliving/firedantic/compare/0.1.3...0.1.4
[0.1.3]: https://github.com/digitalliving/firedantic/compare/0.1.2...0.1.3
[0.1.2]: https://github.com/digitalliving/firedantic/compare/0.1.1...0.1.2
[0.1.1]: https://github.com/digitalliving/firedantic/compare/0.1.0...0.1.1
[0.1.0]: https://github.com/digitalliving/firedantic/releases/tag/0.1.0
[unreleased]: https://github.com/ioxiocom/firedantic/compare/0.3.0...HEAD
[0.3.0]: https://github.com/ioxiocom/firedantic/compare/0.2.8...0.3.0
[0.2.8]: https://github.com/ioxiocom/firedantic/compare/0.2.7...0.2.8
[0.2.7]: https://github.com/ioxiocom/firedantic/compare/0.2.6...0.2.7
[0.2.6]: https://github.com/ioxiocom/firedantic/compare/0.2.5...0.2.6
[0.2.5]: https://github.com/ioxiocom/firedantic/compare/0.2.4...0.2.5
[0.2.4]: https://github.com/ioxiocom/firedantic/compare/0.2.3...0.2.4
[0.2.3]: https://github.com/ioxiocom/firedantic/compare/0.2.2...0.2.3
[0.2.2]: https://github.com/ioxiocom/firedantic/compare/0.2.1...0.2.2
[0.2.1]: https://github.com/ioxiocom/firedantic/compare/0.2.0...0.2.1
[0.2.0]: https://github.com/ioxiocom/firedantic/compare/0.1.4...0.2.0
[0.1.4]: https://github.com/ioxiocom/firedantic/compare/0.1.3...0.1.4
[0.1.3]: https://github.com/ioxiocom/firedantic/compare/0.1.2...0.1.3
[0.1.2]: https://github.com/ioxiocom/firedantic/compare/0.1.1...0.1.2
[0.1.1]: https://github.com/ioxiocom/firedantic/compare/0.1.0...0.1.1
[0.1.0]: https://github.com/ioxiocom/firedantic/releases/tag/0.1.0
Loading

0 comments on commit 091e150

Please sign in to comment.