Skip to content

Commit

Permalink
Initial commit for development of this API client
Browse files Browse the repository at this point in the history
  • Loading branch information
stumpylog committed Oct 10, 2023
1 parent b9f602f commit 2615219
Show file tree
Hide file tree
Showing 11 changed files with 552 additions and 2 deletions.
12 changes: 12 additions & 0 deletions .docker/docker-compose.ci-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# docker-compose file for running testing with gotenberg container
# Can be used locally or by the CI to start the nessecary container with the
# correct networking for the tests

version: "3"
services:
gotenberg:
image: docker.io/gotenberg/gotenberg:7.9.2
hostname: gotenberg
container_name: gotenberg
network_mode: host
restart: unless-stopped
37 changes: 37 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# EditorConfig: http://EditorConfig.org

root = true

[*]
indent_style = tab
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
end_of_line = lf
charset = utf-8
max_line_length = 88

[{*.html,*.css,*.js}]
max_line_length = off

[*.py]
indent_size = 4
indent_style = space

[*.{yml,yaml}]
indent_style = space

[*.rst]
indent_style = space

[*.md]
indent_style = space

# Tests don't get a line width restriction. It's still a good idea to follow
# the 79 character rule, but in the interests of clarity, tests often need to
# violate it.
[**/test_*.py]
max_line_length = off

[*.toml*]
indent_style = space
25 changes: 25 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates#package-ecosystem

version: 2
updates:

# Enable version updates for Python
- package-ecosystem: "pip"
target-branch: "develop"
# Look for a `Pipfile` in the `root` directory
directory: "/"
# Check for updates once a week
schedule:
interval: "weekly"
labels:
- "dependencies"

# Enable updates for Github Actions
- package-ecosystem: "github-actions"
target-branch: "develop"
directory: "/"
schedule:
# Check for updates to GitHub Actions every month
interval: "monthly"
labels:
- "dependencies"
176 changes: 176 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
name: test

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

concurrency:
group: test-${{ github.head_ref }}
cancel-in-progress: true

env:
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
permissions:
contents: read
steps:
-
uses: actions/checkout@v3
-
name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
-
name: Install Hatch
run: |
pip3 --quiet install --upgrade hatch
-
name: Lint project
run: |
hatch run lint:all
-
name: Check files with pre-commit
uses: pre-commit/[email protected]
test:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
permissions:
contents: read
needs:
- lint
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', 'pypy3.8', 'pypy3.9']

steps:
-
uses: actions/checkout@v3
-
name: Start containers
run: |
docker compose --file ${GITHUB_WORKSPACE}/.docker/docker-compose.ci-test.yml pull --quiet
docker compose --file ${GITHUB_WORKSPACE}/.docker/docker-compose.ci-test.yml up --detach
echo "Wait for container to be started"
sleep 5
-
name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
-
name: Install Hatch
run: pip install --upgrade hatch
-
name: Run tests
run: hatch run cov
-
name: Upload coverage to Codecov
if: matrix.python-version == '3.10'
uses: codecov/codecov-action@v3
with:
# not required for public repos, but intermittently fails otherwise
token: ${{ secrets.CODECOV_TOKEN }}
-
name: Stop containers
if: always()
run: |
docker compose --file ${GITHUB_WORKSPACE}/.docker/docker-compose.ci-test.yml logs
docker compose --file ${GITHUB_WORKSPACE}/.docker/docker-compose.ci-test.yml down
build:
name: Build
runs-on: ubuntu-latest
permissions:
contents: read
needs:
- lint
steps:
-
uses: actions/checkout@v3
-
name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
-
name: Install Hatch
run: |
pip3 --quiet install --upgrade hatch
-
name: Build
run: |
hatch build --clean
-
uses: actions/upload-artifact@v3
with:
name: artifacts
path: dist/*
if-no-files-found: error
retention-days: 7

create-release:
name: Release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
needs:
- build
- test
steps:
-
uses: actions/checkout@v3
-
uses: actions/download-artifact@v3
with:
name: artifacts
path: dist
-
name: Get latest release info
id: query-release-info
uses: release-flow/keep-a-changelog-action@v2
with:
command: query
version: ${{ github.ref_name }}
-
name: Display release info
run: |
echo "Version: ${{ steps.query-release-info.outputs.version }}"
echo "Date: ${{ steps.query-release-info.outputs.release-date }}"
echo "${{ steps.query-release-info.outputs.release-notes }}"
-
uses: ncipollo/release-action@v1
with:
artifacts: "dist/*.tar.gz,dist/*.whl"
body: ${{ steps.query-release-info.outputs.release-notes }}

pypi-publish:
name: Publish
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
needs:
- build
- test
steps:
-
uses: actions/download-artifact@v3
with:
name: artifacts
path: dist
-
name: Publish build to PyPI
uses: pypa/[email protected]
46 changes: 46 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This file configures pre-commit hooks.
# See https://pre-commit.com/ for general information
# See https://pre-commit.com/hooks.html for a listing of possible hooks

repos:
# General hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-docstring-first
- id: check-json
exclude: "tsconfig.*json"
- id: check-yaml
- id: check-toml
- id: check-executables-have-shebangs
- id: end-of-file-fixer
exclude_types:
- svg
- pofile
exclude: "(^LICENSE$)"
- id: mixed-line-ending
args:
- "--fix=lf"
- id: trailing-whitespace
exclude_types:
- svg
- id: check-case-conflict
- id: detect-private-key
- repo: https://github.com/pre-commit/mirrors-prettier
rev: 'v3.0.3'
hooks:
- id: prettier
types_or:
- javascript
- ts
- markdown
exclude: "(^Pipfile\\.lock$)"
# Python hooks
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.0.292'
hooks:
- id: ruff
- repo: https://github.com/psf/black
rev: 23.9.1
hooks:
- id: black
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- TBD
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,21 @@
# gotenberg-client
A Python client for interfacing with the Gotenberg API
# Gotenberg API Client

[![PyPI - Version](https://img.shields.io/pypi/v/-.svg)](https://pypi.org/project/gotenberg-client)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/gotenberg-client.svg)](https://pypi.org/project/gotenberg-client)

---

## Table of Contents

- [Installation](#installation)
- [License](#license)

## Installation

```console
pip install gotenberg-client
```

## License

`gotenberg-client` is distributed under the terms of the [MPL 2.0](https://spdx.org/licenses/MPL-2.0.html) license.
Loading

0 comments on commit 2615219

Please sign in to comment.