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
61 changes: 61 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Bug Report
description: Report a bug in comlink-python
labels: ["bug"]
body:
- type: textarea
id: description
attributes:
label: Bug Description
description: A clear description of what the bug is.
validations:
required: true

- type: textarea
id: reproduction
attributes:
label: Steps to Reproduce
description: Minimal code or steps to reproduce the issue.
placeholder: |
from swgoh_comlink import SwgohComlink
comlink = SwgohComlink()
# ...
validations:
required: true

- type: textarea
id: expected
attributes:
label: Expected Behavior
description: What you expected to happen.
validations:
required: true

- type: textarea
id: actual
attributes:
label: Actual Behavior
description: What actually happened. Include full traceback if applicable.
validations:
required: true

- type: input
id: python-version
attributes:
label: Python Version
placeholder: "3.12.0"
validations:
required: true

- type: input
id: package-version
attributes:
label: Package Version
placeholder: "1.17.0"
validations:
required: true

- type: input
id: comlink-version
attributes:
label: Comlink Service Version (if applicable)
placeholder: "0.38.1"
25 changes: 25 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Feature Request
description: Suggest a new feature or enhancement
labels: ["enhancement"]
body:
- type: textarea
id: problem
attributes:
label: Problem or Use Case
description: What are you trying to accomplish? How are you currently working around it?
validations:
required: true

- type: textarea
id: solution
attributes:
label: Proposed Solution
description: Describe the API or behavior you'd like to see.
validations:
required: true

- type: textarea
id: alternatives
attributes:
label: Alternatives Considered
description: Any alternative approaches you've considered.
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
labels:
- "dependencies"
- "ci"

- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
labels:
- "dependencies"
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4

Expand Down
59 changes: 32 additions & 27 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: comlink-python release

on:
workflow_dispatch:

# push:
# branches:
# - main

jobs:
release:
name: Semantic Release
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./scripts

concurrency:
group: ${{ github.workflow }}-release-${{ github.ref_name }}
Expand All @@ -37,38 +27,50 @@ jobs:
ref: ${{ github.ref_name }}
fetch-depth: 0

# Install dependencies
- name: Install uv
uses: astral-sh/setup-uv@v4

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

- name: Install dependencies
run: |
python -m pip install uv
uv pip install hatch
run: uv pip install --system hatch git-changelog

# Update version
- name: Update version
run: uv run hatch version minor
run: hatch version minor

# Update CHANGELOG.md
- name: Update CHANGELOG.md
run: |
uv pip install git-changelog
git-changelog -B auto -Tio CHANGELOG.md -c angular -s build,deps,fix,feat,refactor -n semver
run: git-changelog -B auto -Tio CHANGELOG.md -c angular -s build,deps,fix,feat,refactor -n semver

# Tag the release in GitHub
- name: Tag the release
# Commit version bump and changelog, then tag and push
- name: Commit and tag
run: |
VERSION=$(hatch version)
git config user.name "$(git log -n 1 --pretty=format:%an)"
git config user.email "$(git log -n 1 --pretty=format:%ae)"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add src/swgoh_comlink/version.py CHANGELOG.md
git commit -m "chore(release): bump version to $VERSION [skip ci]"
git tag -a "v$VERSION" -m "Release version $VERSION"
git push origin "v$VERSION"
git push origin ${{ github.ref_name }} --follow-tags
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Build the package using python3 -m build
# Build the package
- name: Build the package
run: uv run hatch build
run: hatch build

# Publish the package to PyPI
# Upload build artifacts for the publish job
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/

# Publish the package to PyPI
pypi-publish:
runs-on: ubuntu-latest
needs:
Expand All @@ -85,6 +87,9 @@ jobs:
steps:
- name: Retrieve release distributions
uses: actions/download-artifact@v4
with:
name: dist
path: dist/

- name: Publish release distributions to PyPI
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ __pycache__/
# C extensions
*.so

# macOS
.DS_Store

# Tool caches
.ruff_cache/
.claude/

# GitHub Test Workflows
.github/test.yml

Expand Down
23 changes: 18 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Be respectful, constructive, and patient. We're all here because we enjoy the ga
source .venv/bin/activate # Linux/macOS
# .venv\Scripts\activate # Windows

uv pip install -e ".[dev]"
uv sync
```

4. **Verify the installation**
Expand Down Expand Up @@ -106,8 +106,18 @@ This starts comlink on `http://localhost:3000`, which is the default URL the lib
```
comlink-python/
├── .github/
│ └── workflows/
│ └── release.yml # Semantic release → PyPI publish
│ ├── ISSUE_TEMPLATE/
│ │ ├── bug_report.yml # Bug report template
│ │ └── feature_request.yml # Feature request template
│ ├── workflows/
│ │ ├── ci.yml # CI pipeline (lint, type-check, test, build)
│ │ ├── commitlint.yml # Commit message validation
│ │ ├── labeler.yml # Auto-label PRs by file path
│ │ └── release.yml # Semantic release → PyPI publish
│ ├── CODEOWNERS # Code ownership
│ ├── dependabot.yml # Automated dependency updates
│ ├── labeler.yml # Label-to-path configuration
│ └── pull_request_template.md # PR checklist template
├── docs/
│ └── logging.md # Logging configuration guide
├── examples/ # Usage examples for each endpoint
Expand All @@ -122,9 +132,11 @@ comlink-python/
│ ├── swgoh_comlink.py # Main SwgohComlink client class
│ └── version.py # Package version (managed by hatch)
├── tests/ # Test suite
├── .commitlintrc.json # Commit message lint config (local + CI)
├── pyproject.toml # Project metadata, build config, tool settings
├── uv.lock # Locked dependency versions
├── CHANGELOG.md # Auto-generated from commit history
├── CONTRIBUTING.md # This file
├── LICENSE # MIT License
└── README.md
```
Expand Down Expand Up @@ -384,13 +396,14 @@ Closes #12
- [ ] Existing tests still pass
- [ ] Commit messages follow Angular convention
- [ ] Ruff linter passes (`ruff check src/ tests/`)
- [ ] Ruff formatter passes (`ruff format --check src/ tests/`)
- [ ] No unrelated changes bundled in

7. **After submitting:**

CI checks (lint, tests, commit message validation, build) will run automatically.
Address any failures before requesting review — the maintainer will be notified
via CODEOWNERS once all checks are green.
Address any failures before requesting review — the maintainer is automatically
assigned via CODEOWNERS when a PR is opened.

If you need to update your PR after feedback, push additional commits to the same
branch on your fork. The PR updates automatically:
Expand Down
56 changes: 45 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
# comlink-python

[![CI](https://github.com/swgoh-utils/comlink-python/actions/workflows/ci.yml/badge.svg)](https://github.com/swgoh-utils/comlink-python/actions/workflows/ci.yml)
[![PyPI version](https://badge.fury.io/py/swgoh-comlink.svg)](https://pypi.org/project/swgoh-comlink/)
[![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

## Description

A python wrapper for the [swgoh-comlink](https://github.com/swgoh-utils/swgoh-comlink) tool.

**Requires Python 3.10 or higher.**

## Installation

Install from [PyPi package repository](https://pypi.org/project/swgoh-comlink/) using the following shell command.

```buildoutcfg
```bash
uv pip install swgoh_comlink
```

Expand Down Expand Up @@ -50,27 +58,53 @@ player_roster = player_data['rosterUnit']
roster_with_stats = comlink.get_unit_stats(player_roster)
```

Usage example with MHAC enabled:
Usage example with HMAC enabled:

```python
from swgoh_comlink import SwgohComlink

comlink = SwgohComlink(
url='http://localhost:3000',
access_key='public_key',
url='http://localhost:3000',
access_key='public_key',
secret_key='this_string_should_be_secret'
)
player_data = comlink.get_player(allycode=245866537)
player_name = player_data['name']
```

# Parameters

- **_url_**: the URL where the swgoh-comlink service is running. Defaults to `http://localhost:3000`
- **_access_key_**: The "public" portion of the shared key used in HMAC request signing. Defaults to `None` which disables HMAC signing of requests. Can also be read from the ACCESS_KEY environment variable.
- **_secret_key_**: The "private" portion of the key used in HMAC request signing. Defaults to `None` which disables HMAC signing of requests. Can also be read from the SECRET_KEY environment variable.

# Logging
## Parameters

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `url` | `str` | `http://localhost:3000` | URL where swgoh-comlink is running |
| `stats_url` | `str` | `http://localhost:3223` | URL where swgoh-stats service is running |
| `access_key` | `str` | `None` | HMAC public key. Also reads from `ACCESS_KEY` env var |
| `secret_key` | `str` | `None` | HMAC private key. Also reads from `SECRET_KEY` env var |
| `host` | `str` | `None` | Server hostname (overrides `url` and `stats_url`) |
| `port` | `int` | `3000` | Comlink TCP port (used with `host`) |
| `stats_port` | `int` | `3223` | Stats service TCP port (used with `host`) |
| `verify_ssl` | `bool` | `True` | Enable TLS certificate verification |

## Available Methods

| Method | Description |
|--------|-------------|
| `get_player(allycode, player_id, enums)` | Get player data by allycode or player ID |
| `get_player_arena(allycode, player_id, player_details_only, enums)` | Get player arena profile |
| `get_guild(guild_id, include_recent_guild_activity_info, enums)` | Get guild data by guild ID |
| `get_guilds_by_name(name, start_index, count, enums)` | Search guilds by name |
| `get_guilds_by_criteria(search_criteria, start_index, count, enums)` | Search guilds by criteria |
| `get_game_data(version, include_pve_units, request_segment, enums)` | Get game data collections |
| `get_game_metadata(client_specs, enums)` | Get current game and localization versions |
| `get_localization(localization_id, locale, unzip, enums)` | Get localization bundles |
| `get_enums()` | Get game data enums |
| `get_events(enums)` | Get current game events |
| `get_leaderboard(leaderboard_type, league, division, ...)` | Get GAC leaderboard data |
| `get_guild_leaderboard(leaderboard_id, count, enums)` | Get guild leaderboard data |
| `get_unit_stats(request_payload, flags, language)` | Calculate unit stats via swgoh-stats |
| `get_latest_game_data_version()` | Get latest game data and language versions |

## Logging

Logging is handled by the [python logging module](https://docs.python.org/3/library/logging.html). For details on the
logging implementation for this package, go [here](docs/logging.md).
Expand Down
Loading
Loading