Skip to content

Commit f092397

Browse files
author
Dev Bear
committed
chore(ci): add ci and pypi
1 parent a224ac8 commit f092397

5 files changed

Lines changed: 141 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Python CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Set up Python 3.13
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: '3.13'
19+
20+
- name: Install uv
21+
run: |
22+
curl -LsSf https://astral.sh/uv/install.sh | sh
23+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
24+
25+
- name: Install dependencies
26+
run: |
27+
uv venv
28+
source .venv/bin/activate # Activate venv for subsequent uv commands in the same step
29+
uv pip install .[dev]
30+
31+
- name: Check formatting with Ruff
32+
run: |
33+
source .venv/bin/activate
34+
uv run ruff format --check .
35+
36+
- name: Lint with Ruff
37+
run: |
38+
source .venv/bin/activate
39+
uv run ruff check .

.github/workflows/publish.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Publish Python Package to PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*' # Trigger on tags like v0.1.0, v1.2.3
7+
8+
jobs:
9+
build-and-publish:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
id-token: write # Required for trusted publishing
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: '3.13'
22+
23+
- name: Install uv
24+
run: |
25+
curl -LsSf https://astral.sh/uv/install.sh | sh
26+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
27+
28+
- name: Install build dependencies
29+
run: uv pip install build --system # Install build globally in the runner
30+
31+
- name: Build package
32+
run: uv run python -m build
33+
34+
- name: Publish package to PyPI
35+
uses: pypa/gh-action-pypi-publish@release/v1
36+
# No need for with: password: ${{ secrets.PYPI_API_TOKEN }} if using trusted publishing
37+
# Ensure you have configured trusted publishing for this repository on PyPI.
38+
# If not using trusted publishing, uncomment the line above and add a PYPI_API_TOKEN secret.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ wheels/
88

99
# Virtual environments
1010
.venv
11+
.ruff_cache

README.md

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ if __name__ == '__main__':
108108
print(f"API request error: {re}")
109109
except Exception as e:
110110
print(f"An unexpected error occurred: {e}")
111-
```
111+
112+
### How to Run the Example Script
112113
113114
To run the example script (e.g., if it's `src/examples/basic.py`), ensure your virtual environment is activated and you are in the project root directory:
114115

@@ -121,6 +122,59 @@ python src/examples/basic.py
121122
For more details on the API endpoints and responses, refer to the unofficial Gist:
122123
[https://gist.github.com/asianviking/b87cad7b9e0b0519f1ae8bdb8121398b](https://gist.github.com/asianviking/b87cad7b9e0b0519f1ae8bdb8121398b)
123124

125+
## Development
126+
127+
This section outlines tools and practices for developing `furthermore-py`.
128+
129+
### Linting and Formatting
130+
131+
This project uses [Ruff](https://github.com/astral-sh/ruff) for linting and code formatting to ensure code quality and consistency.
132+
133+
**Installation:**
134+
135+
Ruff is included as a development dependency in `pyproject.toml`. If you followed the main installation steps using `uv pip install .` or `uv sync`, and it included development dependencies (e.g., via an extras group like `dev` if configured, or by default if not specified otherwise), Ruff should already be installed.
136+
137+
To ensure you have all development dependencies, you can explicitly install them. If your `pyproject.toml` defines a `dev` extras group like this:
138+
139+
```toml
140+
[project.optional-dependencies]
141+
dev = [
142+
"ruff>=0.11.8",
143+
# ... other dev tools
144+
]
145+
```
146+
147+
Then install with:
148+
```bash
149+
uv pip install .[dev]
150+
```
151+
152+
If development dependencies are listed directly under `[project.dependencies]` or there isn't a specific `dev` group for them, the standard `uv pip install .` or `uv sync` should suffice.
153+
154+
**Configuration:**
155+
156+
Ruff is configured in the `pyproject.toml` file under the `[tool.ruff]` section. This includes settings for line length, selected rules, and formatting preferences.
157+
158+
**Usage:**
159+
160+
Make sure your virtual environment is activated (`source .venv/bin/activate`).
161+
162+
- **To check for linting issues:**
163+
```bash
164+
uv run ruff check .
165+
```
166+
167+
- **To automatically fix linting issues (where possible) and format the code:**
168+
First, apply formatting:
169+
```bash
170+
uv run ruff format .
171+
```
172+
Then, apply lint fixes:
173+
```bash
174+
uv run ruff check . --fix
175+
```
176+
Ruff's formatter will handle most style issues, and `check --fix` will address other auto-fixable linting errors.
177+
124178
## Contributing
125179

126180
(Details on how to contribute to this project, if applicable.)

src/client/client.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,17 @@ def get_sources(self, vault_limit_for_scan: int = 100) -> dict[str, set[str]]:
203203

204204
# Check metadata.protocol.name as per API response structure
205205
protocol_info = metadata.get("protocol")
206-
if isinstance(protocol_info, dict) and protocol_info.get("name"):
206+
if isinstance(protocol_info, dict) and protocol_info.get(
207+
"name"
208+
):
207209
protocols.add(protocol_info["name"])
208210

209211
incentivizer_info = metadata.get("incentivizer")
210-
if isinstance(incentivizer_info, dict) and incentivizer_info.get("name") and incentivizer_info["name"].strip():
212+
if (
213+
isinstance(incentivizer_info, dict)
214+
and incentivizer_info.get("name")
215+
and incentivizer_info["name"].strip()
216+
):
211217
incentivizers.add(incentivizer_info["name"].strip())
212218

213219
self.logger.info(

0 commit comments

Comments
 (0)