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
26 changes: 26 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# BerAPI Configuration
# Copy this file to .env and modify as needed

# Base configuration
BERAPI_BASE_URL=https://api.example.com
BERAPI_TIMEOUT=30.0
BERAPI_MAX_RESPONSE_TIME=10.0
BERAPI_VERIFY_SSL=true

# Logging configuration
BERAPI_LOG_LEVEL=INFO
BERAPI_LOG_FORMAT=json
BERAPI_LOG_REQUEST_BODY=true
BERAPI_LOG_RESPONSE_BODY=true
BERAPI_LOG_HEADERS=true
BERAPI_LOG_CURL=true

# Retry configuration
BERAPI_RETRY_ENABLED=true
BERAPI_MAX_RETRIES=3
BERAPI_BACKOFF_FACTOR=0.5
BERAPI_BACKOFF_MAX=60.0
BERAPI_RETRY_JITTER=true

# OpenAPI validation (optional)
# BERAPI_OPENAPI_SPEC=/path/to/openapi.yaml
105 changes: 105 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Publish to PyPI

on:
release:
types: [published]
workflow_dispatch:
inputs:
test_pypi:
description: 'Publish to Test PyPI instead'
required: false
default: false
type: boolean

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

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

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true

- name: Install dependencies
run: poetry install --no-interaction

- name: Run tests
run: poetry run pytest tests/ -v --tb=short

build:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

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

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest

- name: Build package
run: poetry build

- name: Store distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish-pypi:
name: Publish to PyPI
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && !inputs.test_pypi)
needs: build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/berapi
permissions:
id-token: write # Required for trusted publishing

steps:
- name: Download distribution packages
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

publish-test-pypi:
name: Publish to Test PyPI
if: github.event_name == 'workflow_dispatch' && inputs.test_pypi
needs: build
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/p/berapi
permissions:
id-token: write # Required for trusted publishing

steps:
- name: Download distribution packages
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/

- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
55 changes: 55 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Tests

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

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.12"]

steps:
- uses: actions/checkout@v4

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

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

- name: Install project
run: poetry install --no-interaction

- name: Run tests
run: poetry run pytest tests/ -v --tb=short

- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results-${{ matrix.python-version }}
path: reports/
retention-days: 30
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ reports/
builds/
dist/
**/*.html
**/.DS_Store
**/.DS_Store
.claude/
Loading