diff --git a/.flake8 b/.flake8
deleted file mode 100644
index 98f2921..0000000
--- a/.flake8
+++ /dev/null
@@ -1,4 +0,0 @@
-[flake8]
-max-line-length = 120
-max-complexity = 10
-exclude = .git,__pycache__,*/migrations/*,.venv
\ No newline at end of file
diff --git a/.github/workflows/conventional-commit.yml b/.github/workflows/conventional-commit.yml
new file mode 100644
index 0000000..c85ee16
--- /dev/null
+++ b/.github/workflows/conventional-commit.yml
@@ -0,0 +1,28 @@
+name: Conventional Commit
+
+on:
+ pull_request:
+ types: [opened, synchronize, reopened, ready_for_review]
+
+jobs:
+ conventional-commit:
+ runs-on: ubuntu-latest
+ permissions:
+ pull-requests: read # for amannn/action-semantic-pull-request to read PR titles
+
+ steps:
+ - uses: amannn/action-semantic-pull-request@v5
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ types:
+ | # mirrors changelog-sections in the /release-please-config.json
+ chore
+ ci
+ deps
+ docs
+ feat
+ fix
+ perf
+ refactor
+ test
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
new file mode 100644
index 0000000..d35e0e9
--- /dev/null
+++ b/.github/workflows/publish.yml
@@ -0,0 +1,52 @@
+name: Publish to PyPI
+
+on:
+ release:
+ types: [published]
+ workflow_dispatch:
+
+env:
+ tag_name: ${{ github.event.release.tag_name || github.ref_name }}
+ artifact-name: flagsmith-common-${{ github.event.release.tag_name || github.ref_name }}
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v4
+
+ - uses: actions/setup-python@v4
+ with:
+ python-version: 3.12
+
+ - name: Install Poetry
+ run: pipx install poetry
+
+ - name: Build Package
+ run: poetry build
+
+ - uses: actions/upload-artifact@v4
+ with:
+ name: ${{ env.artifact-name }}
+ path: dist/
+
+ - uses: softprops/action-gh-release@v2
+ with:
+ tag_name: ${{ env.tag_name }}
+ files: dist/*
+
+ publish:
+ runs-on: ubuntu-latest
+ needs: build
+
+ permissions:
+ id-token: write # for pypa/gh-action-pypi-publish to authenticate with PyPI
+
+ steps:
+ - uses: actions/download-artifact@v4
+ with:
+ name: ${{ env.artifact-name }}
+ path: dist/
+
+ - uses: pypa/gh-action-pypi-publish@release/v1
diff --git a/.github/workflows/linting-and-formatting.yml b/.github/workflows/python-test.yml
similarity index 65%
rename from .github/workflows/linting-and-formatting.yml
rename to .github/workflows/python-test.yml
index 4280a56..ce72836 100644
--- a/.github/workflows/linting-and-formatting.yml
+++ b/.github/workflows/python-test.yml
@@ -1,23 +1,26 @@
-name: Python Checks and Unit Tests
+name: Python Checks and Unit Tests
on:
pull_request:
jobs:
- test:
+ lint-test:
runs-on: ubuntu-latest
- name: Python Checks and Unit Tests
- steps:
- - name: Cloning repo
- uses: actions/checkout@v3
+ strategy:
+ max-parallel: 2
+ matrix:
+ python-version: ["3.11", "3.12"]
- - name: Install poetry
- run: pipx install poetry
+ steps:
+ - uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
- python-version: 3.12
+ python-version: ${{ matrix.python-version }}
+
+ - name: Install Poetry
+ run: pipx install poetry
- name: Install Dependencies
run: poetry install --with dev
diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml
new file mode 100644
index 0000000..f12fe90
--- /dev/null
+++ b/.github/workflows/release-please.yml
@@ -0,0 +1,23 @@
+name: Release Please
+
+on:
+ push:
+ branches:
+ - main
+
+jobs:
+ release-please:
+ runs-on: ubuntu-latest
+ permissions:
+ contents: write # for googleapis/release-please-action to create release commit
+ pull-requests: write # for googleapis/release-please-action to create release PR
+
+ steps:
+ - uses: googleapis/release-please-action@v4
+ id: release
+ with:
+ token: ${{secrets.RELEASE_PLEASE_GITHUB_TOKEN}}
+
+ outputs:
+ release_created: ${{ steps.release.outputs.release_created }}
+ release_tag_name: ${{ steps.release.outputs.tag_name }}
diff --git a/.gitignore b/.gitignore
index 2beb279..0d6c567 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,4 @@
*.pyc
.coverage
common.sqlite3
+dist/
\ No newline at end of file
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index dedb107..8a12596 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -13,6 +13,12 @@ repos:
hooks:
- id: poetry-check
- id: poetry-lock
+ - repo: https://github.com/pre-commit/pre-commit-hooks
+ rev: v5.0.0
+ hooks:
+ - id: check-yaml
+ - id: check-json
+ - id: check-toml
- repo: local
hooks:
- id: python-typecheck
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..9c9256c
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,160 @@
+# Changelog
+
+
+
+## [v1.5.2](https://github.com/Flagsmith/flagsmith-common/releases/tag/v1.5.2) - 25 Mar 2025
+
+### What's Changed
+
+- fix: Liveness probe performs database queries by [@khvn26](https://github.com/khvn26) in https://github.com/Flagsmith/flagsmith-common/pull/19
+
+**Full Changelog**: https://github.com/Flagsmith/flagsmith-common/compare/v1.5.1...v1.5.2
+
+[Changes][v1.5.2]
+
+
+
+## [v1.5.1](https://github.com/Flagsmith/flagsmith-common/releases/tag/v1.5.1) - 25 Mar 2025
+
+### What's Changed
+
+- fix: Rule is asserted in `SegmentSerializer` when `segment` is not `None` by [@khvn26](https://github.com/khvn26) in https://github.com/Flagsmith/flagsmith-common/pull/18
+
+**Full Changelog**: https://github.com/Flagsmith/flagsmith-common/compare/v1.5.0...v1.5.1
+
+[Changes][v1.5.1]
+
+
+
+## [v1.5.0](https://github.com/Flagsmith/flagsmith-common/releases/tag/v1.5.0) - 25 Mar 2025
+
+### What's Changed
+
+- feat: Add `version_of` to rules and conditions serializers by [@zachaysan](https://github.com/zachaysan) in https://github.com/Flagsmith/flagsmith-common/pull/11
+- feat: Add healthcheck views + urls, typing, ruff linting, src layout by [@khvn26](https://github.com/khvn26) in https://github.com/Flagsmith/flagsmith-common/pull/13
+- feat: Prometheus support, core entrypoint, packaging improvements by [@khvn26](https://github.com/khvn26) and [@rolodato](https://github.com/rolodato) in https://github.com/Flagsmith/flagsmith-common/pull/17
+- feat: Add `MANAGE_SEGMENT_OVERRIDES` permission by [@francescolofranco](https://github.com/francescolofranco) in https://github.com/Flagsmith/flagsmith-common/pull/14
+- feat: Add Makefile for development setup and installation instructions by [@francescolofranco](https://github.com/francescolofranco) in https://github.com/Flagsmith/flagsmith-common/pull/15
+- fix: Clarify change request wording by [@zachaysan](https://github.com/zachaysan) in https://github.com/Flagsmith/flagsmith-common/pull/10
+- fix: Handle missing condition by [@zachaysan](https://github.com/zachaysan) in https://github.com/Flagsmith/flagsmith-common/pull/12
+- fix: `self_hosted_data` is cached indefinitely by [@khvn26](https://github.com/khvn26) in https://github.com/Flagsmith/flagsmith-common/pull/16
+
+### New Contributors
+
+- [@francescolofranco](https://github.com/francescolofranco) made their first contribution in https://github.com/Flagsmith/flagsmith-common/pull/15
+- [@rolodato](https://github.com/rolodato) made their first contribution in https://github.com/Flagsmith/flagsmith-common/pull/17
+
+**Full Changelog**: https://github.com/Flagsmith/flagsmith-common/compare/v1.4.2...v1.5.0
+
+[Changes][v1.5.0]
+
+
+
+## [v1.4.2](https://github.com/Flagsmith/flagsmith-common/releases/tag/v1.4.2) - 04 Dec 2024
+
+### What's Changed
+
+- fix: segment limit validation versioning by [@matthewelwell](https://github.com/matthewelwell) in https://github.com/Flagsmith/flagsmith-common/pull/9
+
+**Full Changelog**: https://github.com/Flagsmith/flagsmith-common/compare/v1.4.1...v1.4.2
+
+[Changes][v1.4.2]
+
+
+
+## [v1.4.1](https://github.com/Flagsmith/flagsmith-common/releases/tag/v1.4.1) - 04 Dec 2024
+
+### What's Changed
+
+- fix: segment limit validation versioning by [@matthewelwell](https://github.com/matthewelwell) in https://github.com/Flagsmith/flagsmith-common/pull/8
+
+**Full Changelog**: https://github.com/Flagsmith/flagsmith-common/compare/v1.4.0...v1.4.1
+
+[Changes][v1.4.1]
+
+
+
+## [v1.4.0](https://github.com/Flagsmith/flagsmith-common/releases/tag/v1.4.0) - 04 Dec 2024
+
+### What's Changed
+
+- feat(org/permissions): Add org permission constants by [@gagantrivedi](https://github.com/gagantrivedi) in https://github.com/Flagsmith/flagsmith-common/pull/7
+
+**Full Changelog**: https://github.com/Flagsmith/flagsmith-common/compare/v1.3.0...v1.4.0
+
+[Changes][v1.4.0]
+
+
+
+## [v1.3.0](https://github.com/Flagsmith/flagsmith-common/releases/tag/v1.3.0) - 03 Dec 2024
+
+### What's Changed
+
+- fix: Ensure owning segment matches to parent segment from rule or condition by [@zachaysan](https://github.com/zachaysan) in https://github.com/Flagsmith/flagsmith-common/pull/5
+
+**Full Changelog**: https://github.com/Flagsmith/flagsmith-common/compare/v1.2.0...v1.3.0
+
+[Changes][v1.3.0]
+
+
+
+## [v1.2.0](https://github.com/Flagsmith/flagsmith-common/releases/tag/v1.2.0) - 05 Nov 2024
+
+### What's Changed
+
+- feat(env/perms): add cr related perms to tag_supported_permissions by [@gagantrivedi](https://github.com/gagantrivedi) in https://github.com/Flagsmith/flagsmith-common/pull/6
+
+### New Contributors
+
+- [@gagantrivedi](https://github.com/gagantrivedi) made their first contribution in https://github.com/Flagsmith/flagsmith-common/pull/6
+
+**Full Changelog**: https://github.com/Flagsmith/flagsmith-common/compare/v1.1.0...v1.2.0
+
+[Changes][v1.2.0]
+
+
+
+## [v1.1.0](https://github.com/Flagsmith/flagsmith-common/releases/tag/v1.1.0) - 23 Oct 2024
+
+### What's Changed
+
+- chore: add configuration files by [@matthewelwell](https://github.com/matthewelwell) in https://github.com/Flagsmith/flagsmith-common/pull/2
+- deps: lock to django 4 by [@matthewelwell](https://github.com/matthewelwell) in https://github.com/Flagsmith/flagsmith-common/pull/3
+- feat: Add workflows change request concerns by [@zachaysan](https://github.com/zachaysan) in https://github.com/Flagsmith/flagsmith-common/pull/4
+
+### New Contributors
+
+- [@zachaysan](https://github.com/zachaysan) made their first contribution in https://github.com/Flagsmith/flagsmith-common/pull/4
+
+**Full Changelog**: https://github.com/Flagsmith/flagsmith-common/compare/v1.0.0...v1.1.0
+
+[Changes][v1.1.0]
+
+
+
+## [v1.0.0](https://github.com/Flagsmith/flagsmith-common/releases/tag/v1.0.0) - 18 Jul 2024
+
+### What's Changed
+
+- feat: add serializers for versioning change requests by [@matthewelwell](https://github.com/matthewelwell) in https://github.com/Flagsmith/flagsmith-common/pull/1
+
+### New Contributors
+
+- [@matthewelwell](https://github.com/matthewelwell) made their first contribution in https://github.com/Flagsmith/flagsmith-common/pull/1
+
+**Full Changelog**: https://github.com/Flagsmith/flagsmith-common/commits/v1.0.0
+
+[Changes][v1.0.0]
+
+[v1.5.2]: https://github.com/Flagsmith/flagsmith-common/compare/v1.5.1...v1.5.2
+[v1.5.1]: https://github.com/Flagsmith/flagsmith-common/compare/v1.5.0...v1.5.1
+[v1.5.0]: https://github.com/Flagsmith/flagsmith-common/compare/v1.4.2...v1.5.0
+[v1.4.2]: https://github.com/Flagsmith/flagsmith-common/compare/v1.4.1...v1.4.2
+[v1.4.1]: https://github.com/Flagsmith/flagsmith-common/compare/v1.4.0...v1.4.1
+[v1.4.0]: https://github.com/Flagsmith/flagsmith-common/compare/v1.3.0...v1.4.0
+[v1.3.0]: https://github.com/Flagsmith/flagsmith-common/compare/v1.2.0...v1.3.0
+[v1.2.0]: https://github.com/Flagsmith/flagsmith-common/compare/v1.1.0...v1.2.0
+[v1.1.0]: https://github.com/Flagsmith/flagsmith-common/compare/v1.0.0...v1.1.0
+[v1.0.0]: https://github.com/Flagsmith/flagsmith-common/tree/v1.0.0
+
+
diff --git a/release-please-config.json b/release-please-config.json
new file mode 100644
index 0000000..7349713
--- /dev/null
+++ b/release-please-config.json
@@ -0,0 +1,62 @@
+{
+ "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
+ "bootstrap-sha": "77939497c31701d6c1eb49fdbec810134254fb58",
+ "packages": {
+ ".": {
+ "bump-minor-pre-major": false,
+ "bump-patch-for-minor-pre-major": false,
+ "changelog-path": "CHANGELOG.md",
+ "draft": false,
+ "include-component-in-tag": false,
+ "prerelease": false,
+ "release-type": "python"
+ }
+ },
+ "changelog-sections": [
+ {
+ "type": "chore",
+ "hidden": false,
+ "section": "Other"
+ },
+ {
+ "type": "ci",
+ "hidden": false,
+ "section": "CI"
+ },
+ {
+ "type": "deps",
+ "hidden": false,
+ "section": "Dependency Updates"
+ },
+ {
+ "type": "docs",
+ "hidden": false,
+ "section": "Docs"
+ },
+ {
+ "type": "feat",
+ "hidden": false,
+ "section": "Features"
+ },
+ {
+ "type": "fix",
+ "hidden": false,
+ "section": "Bug Fixes"
+ },
+ {
+ "type": "perf",
+ "hidden": false,
+ "section": "Performance Improvements"
+ },
+ {
+ "type": "refactor",
+ "hidden": false,
+ "section": "Refactoring"
+ },
+ {
+ "type": "test",
+ "hidden": false,
+ "section": "Tests"
+ }
+ ]
+}