Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# EditorConfig for a Python project
# Adjust as needed for your team's conventions.

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4

# Python source files
[*.{py,pyi,pyx,pxd}]
indent_style = space
indent_size = 4
# Common hint matching Black's default line length
max_line_length = 120

# Config and data files
[*.{json,jsonc,toml,yml,yaml}]
indent_style = space
indent_size = 2

# Markdown: keep trailing spaces (they can mean a line break)
[*.md]
trim_trailing_whitespace = false

# Makefile requires tabs
[Makefile]
indent_style = tab

# Shell scripts
[*.{sh,bash,zsh}]
indent_style = space
indent_size = 2

# This file itself
[*.editorconfig]
indent_style = space
indent_size = 2
66 changes: 66 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: CI

on:
push:
branches: [main, dev]
pull_request:
branches: [main, dev]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "latest"

- name: Install dependencies
run: uv sync --extra dev

- name: Run ruff format check
run: uv run ruff format --check .

- name: Run ruff lint
run: uv run ruff check .

test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- name: Checkout code
uses: actions/checkout@v6

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

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "latest"

- name: Install dependencies
run: uv sync --extra dev

- name: Run tests
run: uv run pytest -v --cov=jsonpath --cov-report=xml

- name: Upload coverage
if: matrix.python-version == '3.12'
uses: codecov/codecov-action@v5
with:
file: ./coverage.xml
flags: unittests
token: ${{ secrets.CODECOV_TOKEN }}
68 changes: 68 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Release

on:
workflow_run:
workflows: ["CI"]
types:
- completed
branches:
- main
- dev

permissions:
contents: write
issues: write
pull-requests: write
id-token: write

jobs:
release:
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'
environment:
name: pypi
url: https://pypi.org/project/jsonpath-python/

steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"

- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: "lts/*"

- name: Install semantic-release
run: |
npm install -g semantic-release@latest
npm install -g @semantic-release/changelog@latest
npm install -g @semantic-release/exec@latest
npm install -g @semantic-release/git@latest
npm install -g @semantic-release/github@latest
npm install -g conventional-changelog-conventionalcommits@latest

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "latest"

- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_AUTHOR_NAME: github-actions[bot]
GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com
GIT_COMMITTER_NAME: github-actions[bot]
GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com
run: npx semantic-release

- name: Publish to PyPI
if: success() && hashFiles('dist/*') != ''
uses: pypa/gh-action-pypi-publish@release/v1
87 changes: 80 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
.vscode/
.idea/
tmp.py
### Python template
/.ref/
/AGENTS.md
/.serena/
/cohn_credentials.json

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*.py[codz]
*$py.class

# C extensions
Expand Down Expand Up @@ -50,7 +51,7 @@ htmlcov/
nosetests.xml
coverage.xml
*.cover
*.py,cover
*.py.cover
.hypothesis/
.pytest_cache/
cover/
Expand All @@ -75,6 +76,9 @@ instance/
# Sphinx documentation
docs/_build/

# MkDocs
site/

# PyBuilder
.pybuilder/
target/
Expand All @@ -98,7 +102,37 @@ ipython_config.py
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
# UV
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
#uv.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
#poetry.toml

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
#pdm.lock
#pdm.toml
.pdm-python
.pdm-build/

# pixi
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
#pixi.lock
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
# in the .venv directory. It is recommended not to include this directory in version control.
.pixi

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
Expand All @@ -110,6 +144,7 @@ celerybeat.pid

# Environments
.env
.envrc
.venv
env/
venv/
Expand Down Expand Up @@ -140,3 +175,41 @@ dmypy.json

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# Abstra
# Abstra is an AI-powered process automation framework.
# Ignore directories containing user credentials, local state, and settings.
# Learn more at https://abstra.io/docs
.abstra/

# Visual Studio Code
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
# and can be added to the global gitignore or merged into this file. However, if you prefer,
# you could uncomment the following to ignore the entire vscode folder
# .vscode/

# Ruff stuff:
.ruff_cache/

# PyPI configuration file
.pypirc

# Cursor
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
# refer to https://docs.cursor.com/context/ignore-files
.cursorignore
.cursorindexingignore

# Marimo
marimo/_static/
marimo/_lsp/
__marimo__/
52 changes: 52 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
exclude: (^vendor/)

repos:
# Basic file checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
# Remove trailing whitespace
- id: trailing-whitespace
# Ensure files end with newline
- id: end-of-file-fixer
# Check for merge conflict markers
# - id: check-merge-conflict
# Check for large files being added
- id: check-added-large-files
args: ["--maxkb=200000"]

# Ruff - Python linting and formatting
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.6
hooks:
# Run ruff linter
- id: ruff-check
args: ["--fix"]
types_or: [python, pyi]
exclude: ^(vendor/|scripts/)
# Run ruff formatter
- id: ruff-format
types_or: [python, pyi]

# shfmt - Shell script formatting
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.12.0-2
hooks:
- id: shfmt
args: ["-i", "2", "-w"]
types_or: [shell]

# Prettier (local) - JSON/YAML/TOML formatting
- repo: local
hooks:
- id: prettier-local
name: prettier (local)
alias: prettier
entry: npx --yes prettier
language: system
types_or:
- json
- yaml
args:
- "-w"
- "--tab-width=2"
36 changes: 36 additions & 0 deletions .releaserc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
branches:
- main
- name: dev
channel: dev
prerelease: dev
tagFormat: ${version}
preset: conventionalcommits
plugins:
- "@semantic-release/commit-analyzer"
- - "@semantic-release/release-notes-generator"
- presetConfig:
types:
- type: "fix"
section: "Fixes"
- type: "feat"
section: "Features"
- type: "perf"
section: "Performance Improvements"
- - "@semantic-release/changelog"
- changelogFile: CHANGELOG.md
- - "@semantic-release/exec"
- prepareCmd: |
sed -i 's/__version__ = ".*"/__version__ = "${nextRelease.version}"/' jsonpath/__init__.py
uv version "${nextRelease.version}"
publishCmd: uv build
- - "@semantic-release/git"
- assets:
- CHANGELOG.md
- jsonpath/__init__.py
- pyproject.toml
- uv.lock
message: |-
chore(release): ${nextRelease.version} [skip ci]

${nextRelease.notes}
- "@semantic-release/github"
Loading
Loading