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

on:
workflow_call:
inputs:
artifact-name:
description: "Name of an artifact"
type: "string"
required: false
default: "package"

jobs:
build-pkg:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install dependencies
run: pip install -U build twine
- name: Build 📦 package
run: python -m build
- name: Check 📦 package
run: twine check dist/*

- uses: actions/upload-artifact@v3
with:
name: ${{ inputs.artifact-name }}
path: dist
36 changes: 36 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Deploy
on:
push:
branches:
- main

jobs:
set_version:
name: Set the version of the release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set version
id: set_version
run: |
echo version=$( sed -e 's/__version__ = "\(.*\)"/\1/g' <<< $(grep -E '__version__ = ' shellhub/__init__.py)) >> "$GITHUB_OUTPUT"
outputs:
version: ${{ steps.set_version.outputs.version }}

gh-release:
name: Create a release in GitHub
needs:
- set_version
runs-on: ubuntu-latest
if: test -z "${{ needs.set_version.outputs.version }}"
steps:
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
draft: false
prerelease: false
tag_name: v${{ needs.set_version.outputs.version }}
generate_release_notes: true
55 changes: 55 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Tests
on:
push:
branches:
- main
pull_request:
merge_group:

jobs:

build:
uses: "./.github/workflows/build_pkg.yml"
with:
artifact-name: package

test:
runs-on: ${{ matrix.os }}
name: test (Python ${{ matrix.python-version }} on ${{ matrix.os-label }})
strategy:
fail-fast: false
matrix:
# keep it sync with tox.ini [gh-actions] section
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12-dev"]
os: ["ubuntu-latest"]
os-label: ["Ubuntu"]
include:
- {python-version: "3.8", os: "windows-latest", os-label: "Windows"}
- {python-version: "3.8", os: "macos-latest", os-label: "macOS"}
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "${{ matrix.python-version }}"
- name: Install tox
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions
- name: Run tests
run: tox
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

test_success:
# this aggregates success state of all jobs listed in `needs`
# this is the only required check to pass CI
name: "Test success"
runs-on: ubuntu-latest
needs: [test]
steps:
- name: "Noop"
run: true
shell: bash
4 changes: 4 additions & 0 deletions .pep8speaks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pycodestyle: # Same as scanner.linter value. Other option is flake8
max-line-length: 120 # Default is 79 in PEP 8

no_blank_comment: True # If True, no comment is made on PR without any errors.
11 changes: 11 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,14 @@ repos:
hooks:
- id: reorder-python-imports
args: [--py3-plus]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
additional_dependencies: ['types-requests']
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-merge-conflict
- id: debug-statements
- id: check-case-conflict
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# [Shellhub Python SDK]

[![codecov](https://codecov.io/gh/Seluj78/shellhub-python/graph/badge.svg?token=FPWuNDtwdz)](https://codecov.io/gh/Seluj78/shellhub-python)

* [What is it](#what-is-it)
* [Installation](#installation)
* [Locally](#locally)
Expand Down Expand Up @@ -91,4 +93,14 @@ When contributing:

## Code owner

jules.lasne@gmail.com
jules.lasne@gmail.com

## TODO:

- [ ] Migrate tests to pytest-recording
- [ ] Add a readthedocs documentation
- [ ] Switch to an OpenAPI generated client ? see https://github.com/shellhub-io/shellhub/issues/3497#issuecomment-1917478654
- [ ] Add deployment to pypi on merge to main
- [ ] Add a changelog
- [ ] Setup coverage reporting
- [ ] Update tests to tests on multiple python versions
8 changes: 8 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
comment:
after_n_builds: 4

codecov:
disable_default_path_fixes: true # Automatic detection does not discover all files

fixes:
- "::shellhub/"
35 changes: 30 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,47 @@ authors = [
]
readme = "README.md"
dynamic = ["version"]
requires-python = ">=3.11"
requires-python = ">=3.7"
classifiers=[
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Natural Language:: English",
"Topic :: Software Development :: Libraries :: Python Modules",
"License :: Other/Proprietary License",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.9",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Software Development",
]
dependencies = [""]
dependencies = ["requests>=2.31.0"]

[tool.setuptools]
packages = ["shellhub"]

[tool.setuptools.dynamic]
version = {attr = "shellhub.__version__"}

[tool.coverage.run]
branch = true
source = ['shellhub/', 'tests/']

[tool.pytest.ini_options]
pythonpath = [
"."
]
testpaths = [
"tests",
]
addopts = [
"--strict-markers",
"-W ignore::DeprecationWarning",
"-W ignore::PendingDeprecationWarning",
]
markers = [
]
11 changes: 11 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
black
reorder-python-imports
flake8
mypy
types-requests
pre-commit
-r requirements.txt

pytest
requests-mock
pytest-cov
tox
build
setuptools
wheel
twine
16 changes: 13 additions & 3 deletions shellhub/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
# Increment versions here according to SemVer
__version__ = "0.0.1"

# Import here what you want to be able to import from this package and place it in __all__
from shellhub.models.device import ShellHubDevice, ShellHubDeviceInfo
from shellhub.models.base import ShellHub
from .models.device import ShellHubDevice, ShellHubDeviceInfo
from .models.base import ShellHub
from .exceptions import (
ShellHubApiError,
ShellHubAuthenticationError,
DeviceNotFoundError,
ShellHubBaseException,
)


__all__ = [
"ShellHub",
"ShellHubDevice",
"ShellHubDeviceInfo",
"ShellHubApiError",
"ShellHubAuthenticationError",
"DeviceNotFoundError",
"ShellHubBaseException",
]
14 changes: 14 additions & 0 deletions shellhub/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class ShellHubBaseException(Exception):
pass


class ShellHubApiError(ShellHubBaseException):
pass


class ShellHubAuthenticationError(ShellHubBaseException):
pass


class DeviceNotFoundError(ShellHubApiError):
pass
Loading