Skip to content

Commit 50d6e00

Browse files
committed
Merge branch 'release/0.7.0'
2 parents 3ee137c + b006870 commit 50d6e00

36 files changed

+1709
-538
lines changed

.codecov.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,15 @@ codecov:
22
require_ci_to_pass: true
33
comment:
44
require_changes: true
5+
coverage:
6+
status:
7+
project:
8+
default:
9+
# https://docs.codecov.com/docs/commit-status#threshold
10+
threshold: 1%
11+
patch:
12+
default:
13+
# For the changed lines only, target 90% covered, but
14+
# allow as low as 80%
15+
target: 90%
16+
threshold: 10%

.docker/content/favicon.ico

4.19 KB
Binary file not shown.

.docker/docker-compose.ci-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
version: "3"
66
services:
77
gotenberg-client-test-server:
8-
image: docker.io/gotenberg/gotenberg:8.5.1
8+
image: docker.io/gotenberg/gotenberg:8.11.0
99
hostname: gotenberg-client-test-server
1010
container_name: gotenberg-client-test-server
1111
network_mode: host

.github/workflows/ci.yml

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ jobs:
2525
-
2626
uses: actions/checkout@v4
2727
-
28-
name: Set up Python 3.10
28+
name: Set up Python 3.11
2929
uses: actions/setup-python@v5
3030
with:
31-
python-version: '3.10'
31+
python-version: '3.11'
3232
cache: 'pip'
3333
-
3434
name: Install Hatch
@@ -40,6 +40,10 @@ jobs:
4040
name: Lint project
4141
run: |
4242
hatch fmt --check
43+
-
44+
name: Check project typing
45+
run: |
46+
hatch run typing:run
4347
-
4448
name: Check files with pre-commit
4549
uses: pre-commit/[email protected]
@@ -108,6 +112,56 @@ jobs:
108112
docker compose --file ${GITHUB_WORKSPACE}/.docker/docker-compose.ci-test.yml logs
109113
docker compose --file ${GITHUB_WORKSPACE}/.docker/docker-compose.ci-test.yml down
110114
115+
test-edge:
116+
name: Test Gotenberg :edge
117+
runs-on: ubuntu-latest
118+
permissions:
119+
contents: read
120+
needs:
121+
- lint
122+
steps:
123+
-
124+
uses: actions/checkout@v4
125+
-
126+
name: Start containers
127+
run: |
128+
docker compose --file ${GITHUB_WORKSPACE}/.docker/docker-compose.ci-test-edge.yml pull --quiet
129+
docker compose --file ${GITHUB_WORKSPACE}/.docker/docker-compose.ci-test-edge.yml up --detach
130+
echo "Wait for container to be started"
131+
sleep 5
132+
docker inspect gotenberg-client-test-edge-server
133+
-
134+
name: Install poppler-utils
135+
run: |
136+
sudo apt-get update
137+
sudo apt-get install --yes --no-install-recommends poppler-utils
138+
-
139+
name: Set up Python 3.11
140+
uses: actions/setup-python@v5
141+
with:
142+
python-version: "3.11"
143+
cache: 'pip'
144+
-
145+
name: Install Hatch
146+
run: |
147+
python3 -m pip install --upgrade pip
148+
pip install --upgrade hatch
149+
-
150+
name: Show environment
151+
run: |
152+
hatch test --show --python 3.11
153+
-
154+
name: Run tests
155+
run: |
156+
hatch test --cover --python 3.11
157+
ls -ahl .
158+
-
159+
name: Stop containers
160+
if: always()
161+
run: |
162+
docker compose --file ${GITHUB_WORKSPACE}/.docker/docker-compose.ci-test-edge.yml logs
163+
docker compose --file ${GITHUB_WORKSPACE}/.docker/docker-compose.ci-test-edge.yml down
164+
111165
build:
112166
name: Build
113167
runs-on: ubuntu-latest
@@ -243,4 +297,4 @@ jobs:
243297
path: dist
244298
-
245299
name: Publish build to PyPI
246-
uses: pypa/gh-action-pypi-publish@v1.8.14
300+
uses: pypa/gh-action-pypi-publish@v1.10.2

.pre-commit-config.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
repos:
66
# General hooks
77
- repo: https://github.com/pre-commit/pre-commit-hooks
8-
rev: v4.6.0
8+
rev: v5.0.0
99
hooks:
1010
- id: check-docstring-first
1111
- id: check-json
@@ -28,8 +28,9 @@ repos:
2828
- svg
2929
- id: check-case-conflict
3030
- id: detect-private-key
31-
- repo: https://github.com/pre-commit/mirrors-prettier
32-
rev: 'v3.1.0'
31+
# See https://github.com/prettier/prettier/issues/15742 for the fork reason
32+
- repo: https://github.com/rbubley/mirrors-prettier
33+
rev: "v3.3.3"
3334
hooks:
3435
- id: prettier
3536
types_or:
@@ -44,9 +45,13 @@ repos:
4445
- id: codespell
4546
# Python hooks
4647
- repo: https://github.com/astral-sh/ruff-pre-commit
47-
rev: 'v0.4.6'
48+
rev: 'v0.6.9'
4849
hooks:
4950
# Run the linter.
5051
- id: ruff
5152
# Run the formatter.
5253
- id: ruff-format
54+
- repo: https://github.com/tox-dev/pyproject-fmt
55+
rev: "2.2.4"
56+
hooks:
57+
- id: pyproject-fmt

CHANGELOG.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,29 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [Unreleased]
8+
## [0.7.0] - 2024-10-08
99

1010
### Fixed
1111

12-
- Wrong paper size preset for A4 ([#24](https://github.com/stumpylog/gotenberg-client/pull/24))
12+
- `mike` deployment mis-ordered the version and alias, this has been corrected
13+
- `mypy` wasn't running correctly in CI
14+
- Wrong paper size preset for A4 by [@mannerydhe](https://github.com/mannerydhe) ([#24](https://github.com/stumpylog/gotenberg-client/pull/24))
15+
16+
### Added
17+
18+
- All routes now return a stronger typed response than just an `httpx.Response` ([#23](https://github.com/stumpylog/gotenberg-client/pull/23))
19+
- All public methods now include docstrings ([#33](https://github.com/stumpylog/gotenberg-client/pull/33))
20+
- The Chromium based HTML and Markdown to PDF routes can now accept accept a `str`, containing either HTML text, Markdown or other text based resources for conversion ([#30](https://github.com/stumpylog/gotenberg-client/pull/30))
21+
- See `string_index`, `string_resource` and `string_resources` for those routes
22+
23+
### Changed
24+
25+
- Bump pypa/gh-action-pypi-publish from 1.8.14 to 1.9.0 by @dependabot ([#25](https://github.com/stumpylog/gotenberg-client/pull/25))
26+
- Bump pypa/gh-action-pypi-publish from 1.9.0 to 1.10.2 by @dependabot ([#31](https://github.com/stumpylog/gotenberg-client/pull/31))
27+
- CI testing now runs against Gotenberg 8.11 ([#32](https://github.com/stumpylog/gotenberg-client/pull/32))
28+
- Development tool updates in `pyproject.toml` and pre-commit hook updates
29+
- Properly use `pytest` fixtures in all testing ([#34](https://github.com/stumpylog/gotenberg-client/pull/34))
30+
- Upgrade `pre-commit` to 4.0.1 ([#35](https://github.com/stumpylog/gotenberg-client/pull/35))
1331

1432
## [0.6.0] - 2024-06-13
1533

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ endpoint. All the routes use the same format and general idea.
5252
- Files will be PDF or ZIP, depending on what endpoint and its configuration. Endpoints which handle
5353
multiple files, but don't merge them, return a ZIP archive of the resulting PDFs
5454

55-
For more detailed examples, check the [documentation](https://stumpylog.github.io/gotenberg-client/)
55+
For more detailed examples, check the [documentation](https://stumpylog.github.io/gotenberg-client/latest/)
5656

5757
### Examples
5858

@@ -64,7 +64,7 @@ from gotenberg_client import GotenbergClient
6464
with GotenbergClient("http://localhost:3000") as client:
6565
with client.chromium.html_to_pdf() as route:
6666
response = route.index("my-index.html").run()
67-
Path("my-index.pdf").write_bytes(response.content)
67+
response.to_file(Path("my-index.pdf"))
6868
```
6969

7070
Converting an HTML file with additional resources into a PDF:
@@ -75,7 +75,7 @@ from gotenberg_client import GotenbergClient
7575
with GotenbergClient("http://localhost:3000") as client:
7676
with client.chromium.html_to_pdf() as route:
7777
response = route.index("my-index.html").resource("image.png").resource("style.css").run()
78-
Path("my-index.pdf").write_bytes(response.content)
78+
response.to_file(Path("my-index.pdf"))
7979
```
8080

8181
Converting an HTML file with additional resources into a PDF/A1a format:
@@ -87,7 +87,7 @@ from gotenberg_client.options import PdfAFormat
8787
with GotenbergClient("http://localhost:3000") as client:
8888
with client.chromium.html_to_pdf() as route:
8989
response = route.index("my-index.html").resources(["image.png", "style.css"]).pdf_format(PdfAFormat.A2b).run()
90-
Path("my-index.pdf").write_bytes(response.content)
90+
response.to_file(Path("my-index.pdf"))
9191
```
9292

9393
Converting a URL into PDF, in landscape format
@@ -99,7 +99,7 @@ from gotenberg_client.options import PageOrientation
9999
with GotenbergClient("http://localhost:3000") as client:
100100
with client.chromium.url_to_pdf() as route:
101101
response = route.url("https://hello.world").orient(PageOrientation.Landscape).run()
102-
Path("my-world.pdf").write_bytes(response.content)
102+
response.to_file(Path("my-world.pdf"))
103103
```
104104

105105
To ensure the proper clean up of all used resources, both the client and the route(s) should be
@@ -119,6 +119,13 @@ finally:
119119
client.close()
120120
```
121121

122+
The response from any `.run()` or `.run_with_retry()` will be either a `SingleFileResponse` or `ZipFileResponse`.
123+
There provide a slimmed down set of fields from an `httpx.Response`, including the headers, the status code and
124+
the response content. They also provide two convenience methods:
125+
126+
- `to_file` - Accepts a path and writes the content of the response to it
127+
- `extract_to` - Only on a `ZipFileResponse`, extracts the zip into the given directory (which must exist)
128+
122129
## License
123130

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

docs/index.md

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ from gotenberg_client import GotenbergClient
2222
with GotenbergClient("http://localhost:3000") as client:
2323
with client.chromium.html_to_pdf() as route:
2424
response = route.index("my-index.html").run()
25-
Path("my-index.pdf").write_bytes(response.content)
25+
response.to_file(Path("my-index.pdf"))
2626
```
2727

2828
Converting an HTML file with additional resources into a PDF:
@@ -33,7 +33,7 @@ from gotenberg_client import GotenbergClient
3333
with GotenbergClient("http://localhost:3000") as client:
3434
with client.chromium.html_to_pdf() as route:
3535
response = route.index("my-index.html").resource("image.png").resource("style.css").run()
36-
Path("my-index.pdf").write_bytes(response.content)
36+
response.to_file(Path("my-index.pdf"))
3737
```
3838

3939
Converting an HTML file with additional resources into a PDF/A1a format:
@@ -45,7 +45,7 @@ from gotenberg_client.options import PdfAFormat
4545
with GotenbergClient("http://localhost:3000") as client:
4646
with client.chromium.html_to_pdf() as route:
4747
response = route.index("my-index.html").resources(["image.png", "style.css"]).pdf_format(PdfAFormat.A2b).run()
48-
Path("my-index.pdf").write_bytes(response.content)
48+
response.to_file(Path("my-index.pdf"))
4949
```
5050

5151
Converting a URL into PDF, in landscape format
@@ -57,7 +57,7 @@ from gotenberg_client.options import PageOrientation
5757
with GotenbergClient("http://localhost:3000") as client:
5858
with client.chromium.html_to_pdf() as route:
5959
response = route.url("https://hello.world").orient(PageOrientation.Landscape).run()
60-
Path("my-world.pdf").write_bytes(response.content)
60+
response.to_file(Path("my-world.pdf"))
6161
```
6262

6363
To ensure the proper clean up of all used resources, both the client and the route(s) should be
@@ -76,3 +76,21 @@ try:
7676
finally:
7777
client.close()
7878
```
79+
80+
## API Responses
81+
82+
The response from any `.run()` or `.run_with_retry()` will be either a `SingleFileResponse` or `ZipFileResponse`.
83+
There provide a slimmed down set of fields from an `httpx.Response`, including the headers, the status code and
84+
the response content. They also provide two convenience methods:
85+
86+
- `to_file` - Accepts a path and writes the content of the response to it
87+
- `extract_to` - Only on a `ZipFileResponse`, extracts the zip into the given directory (which must exist)
88+
89+
Determining which response is a little complicated, as Gotenberg can produce a single PDF from multiple files or
90+
a zip file containing multiple PDFs, depending on how the route is configured and how many files were provided.
91+
92+
For example, the LibreOffice convert route may:
93+
94+
- Produce a single PDF when a single office document is provided
95+
- Produce a zipped response when multiple office documents are provided
96+
- Produce a single PDF when multiple office documents are provided AND the route is asked to merge the result

docs/maybe-logo.webp

101 KB
Loading

0 commit comments

Comments
 (0)