Skip to content

Commit 4f07baf

Browse files
authored
Merge pull request #18 from sean2077/dev
feat: modernize project with CI/CD, update function, and multiple bug fixes
2 parents 3a3e3b7 + 8f42183 commit 4f07baf

File tree

22 files changed

+4259
-2903
lines changed

22 files changed

+4259
-2903
lines changed

.editorconfig

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# EditorConfig for a Python project
2+
# Adjust as needed for your team's conventions.
3+
4+
root = true
5+
6+
[*]
7+
charset = utf-8
8+
end_of_line = lf
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
indent_style = space
12+
indent_size = 4
13+
14+
# Python source files
15+
[*.{py,pyi,pyx,pxd}]
16+
indent_style = space
17+
indent_size = 4
18+
# Common hint matching Black's default line length
19+
max_line_length = 120
20+
21+
# Config and data files
22+
[*.{json,jsonc,toml,yml,yaml}]
23+
indent_style = space
24+
indent_size = 2
25+
26+
# Markdown: keep trailing spaces (they can mean a line break)
27+
[*.md]
28+
trim_trailing_whitespace = false
29+
30+
# Makefile requires tabs
31+
[Makefile]
32+
indent_style = tab
33+
34+
# Shell scripts
35+
[*.{sh,bash,zsh}]
36+
indent_style = space
37+
indent_size = 2
38+
39+
# This file itself
40+
[*.editorconfig]
41+
indent_style = space
42+
indent_size = 2

.github/workflows/ci.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, dev]
6+
pull_request:
7+
branches: [main, dev]
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v6
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v6
18+
with:
19+
python-version: "3.12"
20+
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v7
23+
with:
24+
version: "latest"
25+
26+
- name: Install dependencies
27+
run: uv sync --extra dev
28+
29+
- name: Run ruff format check
30+
run: uv run ruff format --check .
31+
32+
- name: Run ruff lint
33+
run: uv run ruff check .
34+
35+
test:
36+
runs-on: ubuntu-latest
37+
strategy:
38+
matrix:
39+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
40+
steps:
41+
- name: Checkout code
42+
uses: actions/checkout@v6
43+
44+
- name: Set up Python ${{ matrix.python-version }}
45+
uses: actions/setup-python@v6
46+
with:
47+
python-version: ${{ matrix.python-version }}
48+
49+
- name: Install uv
50+
uses: astral-sh/setup-uv@v7
51+
with:
52+
version: "latest"
53+
54+
- name: Install dependencies
55+
run: uv sync --extra dev
56+
57+
- name: Run tests
58+
run: uv run pytest -v --cov=jsonpath --cov-report=xml
59+
60+
- name: Upload coverage
61+
if: matrix.python-version == '3.12'
62+
uses: codecov/codecov-action@v5
63+
with:
64+
file: ./coverage.xml
65+
flags: unittests
66+
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/release.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Release
2+
3+
on:
4+
workflow_run:
5+
workflows: ["CI"]
6+
types:
7+
- completed
8+
branches:
9+
- main
10+
- dev
11+
12+
permissions:
13+
contents: write
14+
issues: write
15+
pull-requests: write
16+
id-token: write
17+
18+
jobs:
19+
release:
20+
runs-on: ubuntu-latest
21+
if: github.event.workflow_run.conclusion == 'success'
22+
environment:
23+
name: pypi
24+
url: https://pypi.org/project/jsonpath-python/
25+
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v6
29+
with:
30+
fetch-depth: 0
31+
persist-credentials: false
32+
33+
- name: Set up Python
34+
uses: actions/setup-python@v6
35+
with:
36+
python-version: "3.12"
37+
38+
- name: Set up Node.js
39+
uses: actions/setup-node@v6
40+
with:
41+
node-version: "lts/*"
42+
43+
- name: Install semantic-release
44+
run: |
45+
npm install -g semantic-release@latest
46+
npm install -g @semantic-release/changelog@latest
47+
npm install -g @semantic-release/exec@latest
48+
npm install -g @semantic-release/git@latest
49+
npm install -g @semantic-release/github@latest
50+
npm install -g conventional-changelog-conventionalcommits@latest
51+
52+
- name: Install uv
53+
uses: astral-sh/setup-uv@v7
54+
with:
55+
version: "latest"
56+
57+
- name: Release
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
GIT_AUTHOR_NAME: github-actions[bot]
61+
GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com
62+
GIT_COMMITTER_NAME: github-actions[bot]
63+
GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com
64+
run: npx semantic-release
65+
66+
- name: Publish to PyPI
67+
if: success() && hashFiles('dist/*') != ''
68+
uses: pypa/gh-action-pypi-publish@release/v1

.gitignore

Lines changed: 80 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
.vscode/
2-
.idea/
3-
tmp.py
4-
### Python template
1+
/.ref/
2+
/AGENTS.md
3+
/.serena/
4+
/cohn_credentials.json
5+
56
# Byte-compiled / optimized / DLL files
67
__pycache__/
7-
*.py[cod]
8+
*.py[codz]
89
*$py.class
910

1011
# C extensions
@@ -50,7 +51,7 @@ htmlcov/
5051
nosetests.xml
5152
coverage.xml
5253
*.cover
53-
*.py,cover
54+
*.py.cover
5455
.hypothesis/
5556
.pytest_cache/
5657
cover/
@@ -75,6 +76,9 @@ instance/
7576
# Sphinx documentation
7677
docs/_build/
7778

79+
# MkDocs
80+
site/
81+
7882
# PyBuilder
7983
.pybuilder/
8084
target/
@@ -98,7 +102,37 @@ ipython_config.py
98102
# install all needed dependencies.
99103
#Pipfile.lock
100104

101-
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
105+
# UV
106+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
107+
# This is especially recommended for binary packages to ensure reproducibility, and is more
108+
# commonly ignored for libraries.
109+
#uv.lock
110+
111+
# poetry
112+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
113+
# This is especially recommended for binary packages to ensure reproducibility, and is more
114+
# commonly ignored for libraries.
115+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
116+
#poetry.lock
117+
#poetry.toml
118+
119+
# pdm
120+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
121+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
122+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
123+
#pdm.lock
124+
#pdm.toml
125+
.pdm-python
126+
.pdm-build/
127+
128+
# pixi
129+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
130+
#pixi.lock
131+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
132+
# in the .venv directory. It is recommended not to include this directory in version control.
133+
.pixi
134+
135+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
102136
__pypackages__/
103137

104138
# Celery stuff
@@ -110,6 +144,7 @@ celerybeat.pid
110144

111145
# Environments
112146
.env
147+
.envrc
113148
.venv
114149
env/
115150
venv/
@@ -140,3 +175,41 @@ dmypy.json
140175

141176
# Cython debug symbols
142177
cython_debug/
178+
179+
# PyCharm
180+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
181+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
182+
# and can be added to the global gitignore or merged into this file. For a more nuclear
183+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
184+
#.idea/
185+
186+
# Abstra
187+
# Abstra is an AI-powered process automation framework.
188+
# Ignore directories containing user credentials, local state, and settings.
189+
# Learn more at https://abstra.io/docs
190+
.abstra/
191+
192+
# Visual Studio Code
193+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
194+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
195+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
196+
# you could uncomment the following to ignore the entire vscode folder
197+
# .vscode/
198+
199+
# Ruff stuff:
200+
.ruff_cache/
201+
202+
# PyPI configuration file
203+
.pypirc
204+
205+
# Cursor
206+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
207+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
208+
# refer to https://docs.cursor.com/context/ignore-files
209+
.cursorignore
210+
.cursorindexingignore
211+
212+
# Marimo
213+
marimo/_static/
214+
marimo/_lsp/
215+
__marimo__/

.pre-commit-config.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
exclude: (^vendor/)
2+
3+
repos:
4+
# Basic file checks
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: v6.0.0
7+
hooks:
8+
# Remove trailing whitespace
9+
- id: trailing-whitespace
10+
# Ensure files end with newline
11+
- id: end-of-file-fixer
12+
# Check for merge conflict markers
13+
# - id: check-merge-conflict
14+
# Check for large files being added
15+
- id: check-added-large-files
16+
args: ["--maxkb=200000"]
17+
18+
# Ruff - Python linting and formatting
19+
- repo: https://github.com/astral-sh/ruff-pre-commit
20+
rev: v0.14.6
21+
hooks:
22+
# Run ruff linter
23+
- id: ruff-check
24+
args: ["--fix"]
25+
types_or: [python, pyi]
26+
exclude: ^(vendor/|scripts/)
27+
# Run ruff formatter
28+
- id: ruff-format
29+
types_or: [python, pyi]
30+
31+
# shfmt - Shell script formatting
32+
- repo: https://github.com/scop/pre-commit-shfmt
33+
rev: v3.12.0-2
34+
hooks:
35+
- id: shfmt
36+
args: ["-i", "2", "-w"]
37+
types_or: [shell]
38+
39+
# Prettier (local) - JSON/YAML/TOML formatting
40+
- repo: local
41+
hooks:
42+
- id: prettier-local
43+
name: prettier (local)
44+
alias: prettier
45+
entry: npx --yes prettier
46+
language: system
47+
types_or:
48+
- json
49+
- yaml
50+
args:
51+
- "-w"
52+
- "--tab-width=2"

.releaserc.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
branches:
2+
- main
3+
- name: dev
4+
channel: dev
5+
prerelease: dev
6+
tagFormat: ${version}
7+
preset: conventionalcommits
8+
plugins:
9+
- "@semantic-release/commit-analyzer"
10+
- - "@semantic-release/release-notes-generator"
11+
- presetConfig:
12+
types:
13+
- type: "fix"
14+
section: "Fixes"
15+
- type: "feat"
16+
section: "Features"
17+
- type: "perf"
18+
section: "Performance Improvements"
19+
- - "@semantic-release/changelog"
20+
- changelogFile: CHANGELOG.md
21+
- - "@semantic-release/exec"
22+
- prepareCmd: |
23+
sed -i 's/__version__ = ".*"/__version__ = "${nextRelease.version}"/' jsonpath/__init__.py
24+
uv version "${nextRelease.version}"
25+
publishCmd: uv build
26+
- - "@semantic-release/git"
27+
- assets:
28+
- CHANGELOG.md
29+
- jsonpath/__init__.py
30+
- pyproject.toml
31+
- uv.lock
32+
message: |-
33+
chore(release): ${nextRelease.version} [skip ci]
34+
35+
${nextRelease.notes}
36+
- "@semantic-release/github"

0 commit comments

Comments
 (0)