Skip to content

Commit 5d66f6f

Browse files
authored
Add Docker-based test harness with Transloadit CLI signature parity (#44)
* Add Docker-based test harness with Transloadit CLI parity * Add optional end-to-end upload test harness * Run E2E upload test in CI and improve diagnostics * Use standard key secrets for CI E2E job * Remove host/region overrides from E2E flow * Skip E2E job for forked pull requests * Skip coverage when running E2E job * Prepare 1.0.3 release * move RELEASE.md -> CONTRIBUTING.md * typo * Document streamlined release flow and add registry script * Simplify release script to only target PyPI
1 parent 8c4d9f1 commit 5d66f6f

File tree

17 files changed

+673
-159
lines changed

17 files changed

+673
-159
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.jpg binary

.github/workflows/ci.yml

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ jobs:
2020
- uses: actions/setup-node@v4
2121
with:
2222
node-version: '20'
23-
- name: Install tsx
24-
run: npm install -g tsx
23+
- name: Install Transloadit CLI
24+
run: npm install -g transloadit
2525

2626
- name: Set up Python
2727
uses: actions/setup-python@v4
@@ -89,3 +89,46 @@ jobs:
8989
path: |
9090
coverage.json
9191
htmlcov/
92+
93+
python-e2e:
94+
runs-on: ubuntu-latest
95+
needs: python
96+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
97+
env:
98+
PYTHON_SDK_E2E: "1"
99+
TRANSLOADIT_KEY: ${{ secrets.TRANSLOADIT_KEY }}
100+
TRANSLOADIT_SECRET: ${{ secrets.TRANSLOADIT_SECRET }}
101+
steps:
102+
- uses: actions/checkout@v4
103+
104+
- uses: actions/setup-node@v4
105+
with:
106+
node-version: '20'
107+
- name: Install Transloadit CLI
108+
run: npm install -g transloadit
109+
110+
- name: Set up Python
111+
uses: actions/setup-python@v4
112+
with:
113+
python-version: '3.12'
114+
architecture: x64
115+
cache: 'pip'
116+
117+
- name: Install Poetry
118+
run: pip install --upgrade poetry
119+
120+
- name: Install dependencies
121+
run: poetry install
122+
123+
- name: Ensure credentials present
124+
run: |
125+
if [ -z "$TRANSLOADIT_KEY" ] || [ -z "$TRANSLOADIT_SECRET" ]; then
126+
echo "TRANSLOADIT_KEY and TRANSLOADIT_SECRET secrets must be configured for the E2E job" >&2
127+
exit 1
128+
fi
129+
130+
- name: Run E2E upload test
131+
env:
132+
TEST_NODE_PARITY: 0
133+
run: |
134+
poetry run pytest tests/test_e2e_upload.py -q --maxfail=1 --no-cov

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ htmlcov/
4343
.cache
4444
nosetests.xml
4545
coverage.xml
46+
coverage.json
4647
*.cover
4748
.hypothesis/
4849

@@ -98,6 +99,9 @@ ENV/
9899
# mkdocs documentation
99100
/site
100101

102+
# Docker/local build helpers
103+
.docker-cache/
104+
101105
# mypy
102106
.mypy_cache/
103107

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
### 1.0.3/ 2025-28-10 ###
2+
* Added a Docker-based test harness (`scripts/test-in-docker.sh`) that mirrors our GitHub Actions matrix locally, including optional Smart CDN parity checks via the official Transloadit CLI.
3+
* Introduced an opt-in end-to-end image resize test (`tests/test_e2e_upload.py`) plus supporting `chameleon.jpg` fixture; enable by setting `PYTHON_SDK_E2E=1` along with `TRANSLOADIT_KEY`/`TRANSLOADIT_SECRET`.
4+
* Updated CI to run the E2E upload on Python 3.12 with guarded secrets and to skip coverage for that targeted job.
5+
* Documented the new workflows and ensured the Transloadit CLI integration replaces the legacy TypeScript helper.
6+
17
### 1.0.2/ 2024-03-12 ###
28
* Add support for Python 3.13
39

CONTRIBUTING.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Contributing
2+
3+
## Release Checklist
4+
5+
Use this checklist whenever you cut a new version of the Python SDK.
6+
7+
### Prerequisites
8+
9+
- Docker installed (our helper scripts build and run inside the project Docker image).
10+
- Writable Transloadit GitHub repository access.
11+
- A PyPI API token with upload rights to `pytransloadit` (`PYPI_TOKEN`). Store it in your shell or `.env`.
12+
- Optionally, a TestPyPI token (`PYPI_TEST_TOKEN`) if you want to dry‑run the release before pushing to the real registry.
13+
14+
### 1. Prepare the Release Commit
15+
16+
1. Update the version in all synced files:
17+
- `pyproject.toml`
18+
- `transloadit/__init__.py`
19+
- `tests/test_request.py` (the `Transloadit-Client` header)
20+
2. Add a matching entry to `CHANGELOG.md`.
21+
3. Run the test matrix (add `PYTHON_SDK_E2E=1` if you want to exercise the live upload):
22+
```bash
23+
./scripts/test-in-docker.sh --python 3.12
24+
```
25+
4. Commit the changes with a message such as `Prepare 1.0.3 release`.
26+
27+
### 2. Tag the Release
28+
29+
After landing the release commit on `main` (or the branch you will tag), create and push an annotated tag:
30+
31+
```bash
32+
git tag -a v1.0.3 -m "v1.0.3"
33+
git push origin main --tags
34+
```
35+
36+
### 3. Publish to PyPI
37+
38+
The `scripts/notify-registry.sh` helper publishes from inside our Docker image and performs the usual safety checks (clean git tree, version consistency, changelog entry). It looks for tokens in the environment or `.env`.
39+
40+
Publish to the real registry:
41+
42+
```bash
43+
PYPI_TOKEN=... scripts/notify-registry.sh
44+
```
45+
46+
### 4. Announce the Release
47+
48+
1. Draft a GitHub release for the new tag and paste the changelog entry.
49+
2. Confirm that the [Read the Docs build](https://transloadit.readthedocs.io/en/latest/) completes (it is triggered when you publish the GitHub release).
50+
51+
That’s it—PyPI and the documentation are now up to date. For additional background see the internal guide: <https://github.com/transloadit/team-internals/blob/HEAD/_howtos/2020-12-14-maintain-python-sdk.md>.

Dockerfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# syntax=docker/dockerfile:1
2+
3+
ARG PYTHON_VERSION=3.12
4+
FROM python:${PYTHON_VERSION}-slim AS base
5+
6+
ENV DEBIAN_FRONTEND=noninteractive \
7+
PIP_DISABLE_PIP_VERSION_CHECK=1 \
8+
PYTHONDONTWRITEBYTECODE=1 \
9+
POETRY_VIRTUALENVS_IN_PROJECT=true
10+
11+
RUN apt-get update \
12+
&& apt-get install -y --no-install-recommends \
13+
curl \
14+
gnupg \
15+
ca-certificates \
16+
build-essential \
17+
git \
18+
&& rm -rf /var/lib/apt/lists/*
19+
20+
# Install Node.js 20 (for Smart CDN parity tests) and supporting CLI tooling
21+
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
22+
&& apt-get update \
23+
&& apt-get install -y --no-install-recommends nodejs \
24+
&& npm install -g transloadit \
25+
&& rm -rf /var/lib/apt/lists/*
26+
27+
# Install Poetry so we match the GitHub Actions toolchain
28+
RUN pip install --no-cache-dir --upgrade pip \
29+
&& pip install --no-cache-dir poetry
30+
31+
WORKDIR /workspace

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,30 @@ See [readthedocs](https://transloadit.readthedocs.io) for full API documentation
4848

4949
### Running tests
5050

51+
You can mirror our GitHub Actions setup locally by running the test matrix inside Docker:
52+
53+
```bash
54+
scripts/test-in-docker.sh
55+
```
56+
57+
This script will:
58+
59+
- build images for the Python versions we test in CI (3.9–3.13)
60+
- install Poetry, Node.js 20, and the Transloadit CLI
61+
- pass credentials from `.env` (if present) so end-to-end tests can run against real Transloadit accounts
62+
63+
Signature parity tests use `npx transloadit smart_sig` under the hood, matching the reference implementation used by our other SDKs. Our GitHub Actions workflow also runs the E2E upload against Python 3.12 on every push/PR using a dedicated Transloadit test account (wired through the `TRANSLOADIT_KEY` and `TRANSLOADIT_SECRET` secrets).
64+
65+
Pass `--python 3.12` (or set `PYTHON_VERSIONS`) to restrict the matrix, or append a custom command after `--`, for example `scripts/test-in-docker.sh -- pytest -k smartcdn`.
66+
67+
To exercise the optional end-to-end upload against a real Transloadit account, provide `TRANSLOADIT_KEY` and `TRANSLOADIT_SECRET` (via environment variables or `.env`) and set `PYTHON_SDK_E2E=1`:
68+
69+
```bash
70+
PYTHON_SDK_E2E=1 scripts/test-in-docker.sh --python 3.12 -- pytest tests/test_e2e_upload.py
71+
```
72+
73+
The test uploads `chameleon.jpg`, resizes it, and asserts on the live assembly results.
74+
5175
If you have a global installation of `poetry`, you can run the tests with:
5276

5377
```bash
@@ -72,4 +96,8 @@ Generate a coverage report with:
7296
poetry run pytest --cov=transloadit --cov-report=html tests
7397
```
7498

75-
Then view the coverage report locally by opening `htmlcov/index.html` in your browser.
99+
Then view the coverage report locally by opening `htmlcov/index.html` in your browser.
100+
101+
## Contributing
102+
103+
See [CONTRIBUTING.md](CONTRIBUTING.md) for local development, testing, and release instructions.

RELEASE.md

Lines changed: 0 additions & 52 deletions
This file was deleted.

chameleon.jpg

8.88 MB
Loading

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "pytransloadit"
3-
version = "1.0.2"
3+
version = "1.0.3"
44
description = "A Python Integration for Transloadit's file uploading and encoding service."
55
authors = ["Ifedapo Olarewaju"]
66
maintainers = ["Florian Kuenzig", "Arnaud Limbourg"]
@@ -48,6 +48,9 @@ build-backend = "poetry.core.masonry.api"
4848
[tool.pytest.ini_options]
4949
addopts = "--cov=transloadit --cov-report=term-missing"
5050
testpaths = ["tests"]
51+
markers = [
52+
"e2e: marks tests that hit the live Transloadit API"
53+
]
5154

5255
[tool.coverage.run]
5356
source = ["transloadit"]

0 commit comments

Comments
 (0)