Skip to content

Commit 76ace84

Browse files
authored
Standardize signature parity testing, add Docker for testing (#73)
* Test in docker, simplify sig parity * Add optional end-to-end upload test harness * Run Ruby e2e upload test in CI * Fail e2e CI job when secrets missing * Fix e2e CI secret check expression * Disable VCR for live e2e upload test * Enable Ruby e2e test by default in Docker harness * Restore URI dependency for request loader * Release 3.1.1 * Stabilize to_json test by freezing time * Document contributing workflow and add release helper
1 parent 28060df commit 76ace84

File tree

20 files changed

+550
-144
lines changed

20 files changed

+550
-144
lines changed

.dockerignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.git
2+
.gitignore
3+
.docker-cache
4+
.bundle
5+
coverage
6+
pkg
7+
node_modules
8+
vendor/bundle
9+
.env

.gitattributes

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

.github/workflows/ci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,28 @@ jobs:
4343
token: ${{ secrets.CODECOV_TOKEN }}
4444
files: ./coverage/coverage.json
4545
fail_ci_if_error: true
46+
e2e:
47+
needs: ci
48+
if: >
49+
github.event_name != 'pull_request' ||
50+
github.event.pull_request.head.repo.full_name == github.repository
51+
runs-on: ubuntu-latest
52+
env:
53+
TRANSLOADIT_KEY: ${{ secrets.TRANSLOADIT_KEY }}
54+
TRANSLOADIT_SECRET: ${{ secrets.TRANSLOADIT_SECRET }}
55+
steps:
56+
- uses: actions/checkout@v3
57+
- uses: ruby/setup-ruby@v1
58+
with:
59+
ruby-version: 3.3
60+
bundler-cache: true
61+
- name: Ensure e2e credentials are configured
62+
if: ${{ env.TRANSLOADIT_KEY == '' || env.TRANSLOADIT_SECRET == '' }}
63+
run: |
64+
echo "TRANSLOADIT_KEY and TRANSLOADIT_SECRET must be configured in repository secrets to run the e2e job." >&2
65+
exit 1
66+
- name: Run end-to-end upload test
67+
env:
68+
RUBY_SDK_E2E: 1
69+
if: ${{ env.TRANSLOADIT_KEY != '' && env.TRANSLOADIT_SECRET != '' }}
70+
run: bundle exec ruby -Itest test/integration/test_e2e_upload.rb

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ transloadit-*.gem
1515
env.sh
1616
.env
1717
vendor/bundle/
18+
.docker-cache/
19+
.cache/rubocop_cache/04e06e0faf5ad652d8bcbcfd85bac5f6c32e711e/3031a80880d8a984708138f0d003f77c4bad2648

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
### 3.1.1 / 2025-10-28
2+
3+
- Add optional live end-to-end upload harness and CI job for parity verification, defaulted in Docker tests (kvz)
4+
- Restore missing `require "uri"` to prevent `NameError` when loading `Transloadit::Request` (kvz)
5+
16
### 3.1.0 / 2024-11-24
27

38
- Add Smart CDN signature support via `signed_smart_cdn_url` method (kvz)

CONTRIBUTING.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Contributing
2+
3+
Thanks for helping improve the Transloadit Ruby SDK! This guide covers local development, testing, and publishing new releases.
4+
5+
## Local Development
6+
7+
After cloning the repository, install dependencies and run the test suite:
8+
9+
```bash
10+
bundle install
11+
bundle exec rake test
12+
```
13+
14+
To exercise the signature parity suite against the Node.js CLI, make sure `npx transloadit` is available and run:
15+
16+
```bash
17+
TEST_NODE_PARITY=1 bundle exec rake test
18+
```
19+
20+
You can warm the CLI cache ahead of time:
21+
22+
```bash
23+
TRANSLOADIT_KEY=... TRANSLOADIT_SECRET=... \
24+
npx --yes transloadit smart_sig --help
25+
TRANSLOADIT_KEY=... TRANSLOADIT_SECRET=... \
26+
npx --yes transloadit sig --algorithm sha384 --help
27+
```
28+
29+
Set `COVERAGE=0` to skip coverage instrumentation if desired:
30+
31+
```bash
32+
COVERAGE=0 bundle exec rake test
33+
```
34+
35+
## Docker Workflow
36+
37+
The repository ships with a helper that runs tests inside a reproducible Docker image:
38+
39+
```bash
40+
./scripts/test-in-docker.sh
41+
```
42+
43+
Pass a custom command to run alternatives (Bundler still installs first):
44+
45+
```bash
46+
./scripts/test-in-docker.sh bundle exec ruby -Itest test/unit/transloadit/test_request.rb
47+
```
48+
49+
The script forwards environment variables such as `TEST_NODE_PARITY` and credentials from `.env`, so you can combine parity checks and integration tests. End-to-end uploads are enabled by default; unset them by running:
50+
51+
```bash
52+
RUBY_SDK_E2E=0 ./scripts/test-in-docker.sh
53+
```
54+
55+
## Live End-to-End Test
56+
57+
To exercise the optional live upload:
58+
59+
```bash
60+
RUBY_SDK_E2E=1 TRANSLOADIT_KEY=... TRANSLOADIT_SECRET=... \
61+
./scripts/test-in-docker.sh bundle exec ruby -Itest test/integration/test_e2e_upload.rb
62+
```
63+
64+
The test uploads `chameleon.jpg`, resizes it, and asserts on a real assembly response.
65+
66+
## Releasing to RubyGems
67+
68+
1. Update the version and changelog:
69+
- Bump `lib/transloadit/version.rb`.
70+
- Add a corresponding entry to `CHANGELOG.md`.
71+
2. Run the full test suite (including Docker, parity, and e2e checks as needed).
72+
3. Commit the release changes and tag:
73+
```bash
74+
git commit -am "Release X.Y.Z"
75+
git tag -a vX.Y.Z -m "Release X.Y.Z"
76+
```
77+
4. Push the commit and tag:
78+
```bash
79+
git push origin main
80+
git push origin vX.Y.Z
81+
```
82+
5. Publish the gem using the helper script:
83+
```bash
84+
GEM_HOST_API_KEY=... ./scripts/notify-registry.sh
85+
```
86+
6. Draft a GitHub release from the new tag and publish the generated notes.
87+
88+
### RubyGems Credentials
89+
90+
- You must belong to the `transloadit` organization on RubyGems with permission to push the `transloadit` gem.
91+
- Generate an API key with **Push Rubygems** permissions at <https://rubygems.org/profile/edit>. Copy the token and keep it secure.
92+
- Export the token as `GEM_HOST_API_KEY` in your environment before running `./scripts/notify-registry.sh`. The script refuses to run if the variable is missing.
93+
94+
That’s it! Thank you for contributing.
95+

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# syntax=docker/dockerfile:1
2+
3+
FROM ruby:3.3 AS base
4+
5+
RUN apt-get update \
6+
&& apt-get install -y --no-install-recommends \
7+
build-essential \
8+
git \
9+
curl \
10+
ca-certificates \
11+
&& rm -rf /var/lib/apt/lists/*
12+
13+
# Install Node.js for parity checks
14+
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
15+
&& apt-get install -y --no-install-recommends nodejs \
16+
&& npm install -g npm@latest \
17+
&& rm -rf /var/lib/apt/lists/*
18+
19+
WORKDIR /workspace

README.md

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -467,34 +467,4 @@ If you still need support for Ruby 2.x, 2.0.1 is the last version that supports
467467

468468
## Contributing
469469

470-
Contributions are welcome!
471-
472-
### Running tests
473-
474-
```bash
475-
bundle install
476-
bundle exec rake test
477-
```
478-
479-
To also test parity against the Node.js reference implementation, run:
480-
481-
```bash
482-
TEST_NODE_PARITY=1 bundle exec rake test
483-
```
484-
485-
To disable coverage reporting, run:
486-
487-
```bash
488-
COVERAGE=0 bundle exec rake test
489-
```
490-
491-
### Releasing on RubyGems
492-
493-
Let's say you wanted to release version `3.1.0`, here are the steps:
494-
495-
1. Update the version number in the version file `version.rb` and `CHANGELOG.md`
496-
2. Commit: `git add CHANGELOG.md lib/transloadit/version.rb && git commit -m "Release 3.1.0"`
497-
3. Create a git tag: `git tag -a v3.1.0 -m "Release 3.1.0"`
498-
4. Push the git tag: `git push origin v3.1.0`
499-
5. Release on RubyGems: `gem build transloadit.gemspec && gem push transloadit-3.1.0.gem`
500-
6. Draft a release [here](https://github.com/transloadit/ruby-sdk/releases). Click the `v3.1.0` tag and click `Generate release notes`. Inspect and Publish.
470+
See [CONTRIBUTING.md](CONTRIBUTING.md) for local development, testing, and release instructions.

chameleon.jpg

8.88 MB
Loading

lib/transloadit.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
require "date"
33
require "json"
44
require "openssl"
5-
require "uri"
65
require "cgi"
6+
require "uri"
77

88
#
99
# Implements the Transloadit REST API in Ruby. Check the {file:README.md README}

0 commit comments

Comments
 (0)