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
86 changes: 86 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: CI

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

# Cancel in-progress runs for the same branch when a new push arrives.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
test:
name: pytest (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true

- name: Install Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: Sync dependencies
run: uv sync --python ${{ matrix.python-version }}

- name: Run unit tests
run: uv run --python ${{ matrix.python-version }} pytest

lint:
name: ruff + mypy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true

- name: Sync dependencies
run: uv sync

- name: Ruff
run: uv run ruff check src/ tests/ examples/

- name: Mypy
run: uv run mypy src/

integration:
# Only run live API tests on the canonical repository, on push to main.
# Forks won't have the secret and would fail otherwise.
name: live API tests
runs-on: ubuntu-latest
needs: [test, lint]
if: github.repository == 'bytesview/python-client' && github.event_name == 'push'
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v6

- name: Sync dependencies
run: uv sync

- name: Run integration tests
env:
PYTEST_TOKEN: ${{ secrets.PYTEST_NEWSDATA_API }}
run: |
if [ -z "${PYTEST_TOKEN}" ]; then
echo "PYTEST_NEWSDATA_API secret not set; skipping integration tests."
exit 0
fi
uv run pytest -m integration
56 changes: 56 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Publish to PyPI

on:
release:
types: [published]

permissions:
contents: read

jobs:
build:
name: Build distributions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v6

- name: Sync dependencies
run: uv sync

- name: Run unit tests
run: uv run pytest

- name: Build sdist + wheel
run: uv build

- name: Upload distributions
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/

publish:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: build
# OIDC trusted publishing — no API token required.
# One-time setup at:
# https://pypi.org/manage/project/newsdataapi/settings/publishing/
# Workflow filename = "publish.yml", environment = "pypi".
permissions:
id-token: write
environment:
name: pypi
url: https://pypi.org/p/newsdataapi
steps:
- name: Download distributions
uses: actions/download-artifact@v4
with:
name: dist
path: dist/

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
33 changes: 0 additions & 33 deletions .github/workflows/python-publish.yml

This file was deleted.

149 changes: 15 additions & 134 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,145 +1,26 @@
# Created by https://www.toptal.com/developers/gitignore/api/python
# Edit at https://www.toptal.com/developers/gitignore?templates=python

### Python ###
# Byte-compiled / optimized / DLL files
project_env
my_test.py
.vscode/
# Python bytecode
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so
# Virtual env (uv)
.venv/

# Distribution / packaging
.Python
build/
develop-eggs/
# Build artifacts (uv build / hatchling)
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
build/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
# Tool caches
.pytest_cache/
pytestdebug.log

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/
doc/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

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

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
pythonenv*

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json
.ruff_cache/
.coverage

# Pyre type checker
.pyre/
# Project scratch
temp.py

# pytype static type analyzer
.pytype/
# Claude Code
CLAUDE.md
.claude/

# profiling data
.prof
# IDE
.vscode/
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) [year] [fullname]
Copyright (c) 2023-2026 NewsData.io

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 0 additions & 4 deletions MANIFEST.in

This file was deleted.

Loading
Loading