Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
b728dbc
refactor!: rewrite the client for 2.0
mantas Nov 18, 2026
b5d40eb
feat: ship a test kit for code that calls this client
mantas Nov 18, 2026
30e8086
feat: add RBS signatures and check them with Steep
mantas Nov 18, 2026
75b98da
ci: drive a live Zammad end to end and publish by tag
mantas Nov 18, 2026
5522667
docs: document 2.0 and the way up from 1.x
mantas Nov 18, 2026
9c4526e
fix: refuse a record where a record id belongs
mantas Nov 18, 2026
a90353e
fix: refuse one attribute given under two spellings
mantas Nov 18, 2026
884660f
fix: keep credentials out of a record's inspect
mantas Nov 18, 2026
551865d
fix: have the test kit retry a read as the client does
mantas Nov 18, 2026
6a0909d
fix: read an index that does not page in one request
mantas Nov 18, 2026
b6a68f7
refactor!: remove the names 1.x had for readers and add_article
mantas Nov 18, 2026
b80c682
fix: redact a URL that has no host where the host belongs
mantas Nov 19, 2026
acbf2e6
fix: log a request body as it is sent
mantas Nov 19, 2026
3f366da
fix: redact a path query that is separated by semicolons
mantas Nov 19, 2026
2285f61
fix: refuse what is not a Hash in assign_attributes
mantas Nov 19, 2026
e3fe024
fix: read strong parameters as the Hash they convert to
mantas Nov 19, 2026
ece9c67
fix: refuse arguments given to an attribute reader
mantas Nov 19, 2026
fc3ee15
fix: answer any? and none? with the request empty? makes
mantas Nov 19, 2026
56e3746
fix: keep an adapter the middleware callable sets
mantas Nov 19, 2026
cfc2243
test: read resources by their plural names in the live specs
mantas Nov 19, 2026
5a7744a
fix: find a line break beside bytes invalid in the encoding
mantas Nov 19, 2026
2f167b1
fix: redact the credentials Zammad filters from its own log
mantas Nov 19, 2026
e0f5bf1
fix: carry a derived config in the test kit's transport
mantas Nov 19, 2026
a45d093
fix: refuse a request path that opens with a scheme
mantas Nov 19, 2026
cb2958c
fix: refuse a query value or a scope that is no value
mantas Nov 19, 2026
69f35f9
fix: drop a constant the library no longer has from the sigs
mantas Nov 19, 2026
565c96f
fix: refuse a body value that JSON has no type for
mantas Nov 20, 2026
ce585e7
fix: keep credentials out of to_json under ActiveSupport
mantas Nov 20, 2026
5a5593a
fix: refuse a raw request header name that is not one
mantas Nov 20, 2026
2c3c870
fix: serve a stub declared after an earlier one answered
mantas Nov 20, 2026
8eacd3a
fix: raise for a response body cut short of its length
mantas Nov 20, 2026
37560b7
fix: refuse a query value that is no Integer or Float
mantas Nov 20, 2026
c7302ca
fix: leave deep_dup and presence to ActiveSupport
mantas Nov 20, 2026
11da1e3
fix: refuse a logger whose debug requires an argument
mantas Nov 20, 2026
d603719
fix: download an attachment uncompressed to check its length
mantas Nov 20, 2026
a6f387a
fix: raise ConfigurationError for a url that was left out
mantas Nov 20, 2026
8380390
test: load the test kit in the client spec that uses it
mantas Nov 20, 2026
c235b5d
fix: read Retry-After in base ten
mantas Nov 20, 2026
07d3276
fix: declare the dependency on logger
mantas Nov 20, 2026
404d043
docs: drop the 1.x collection methods that never existed
mantas Nov 20, 2026
5847691
docs: match an expanded group by its name in the README
mantas Nov 20, 2026
ad97a44
fix: read a Content-Length a middleware left as an Integer
mantas Nov 20, 2026
434f9f7
fix: settle a record whose 2xx answer was cut short
mantas Nov 20, 2026
abc4957
fix: strip a line break from the end of a header value
mantas Nov 20, 2026
aad0953
fix: read only: and except: in a record's as_json
mantas Nov 20, 2026
260e485
fix: blank a fragment where a request path is printed
mantas Nov 20, 2026
5c88100
chore: name irb in the bundle for bin/console
mantas Nov 20, 2026
4d7e340
docs: say a retry wait can exceed timeout by the jitter
mantas Nov 20, 2026
90dba55
docs: run the examples through Bundler from a checkout
mantas Nov 20, 2026
a139200
ci: call the zammad_ref input a branch or a tag
mantas Nov 20, 2026
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
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,18 @@ updates:
directory: "/"
schedule:
interval: "weekly"
groups:
actions:
patterns: ["*"]
- package-ecosystem: "bundler"
directory: "/"
schedule:
interval: "weekly"
groups:
# Lint and type tooling churns often and never affects the shipped gem.
development:
dependency-type: "development"
patterns: ["*"]
runtime:
dependency-type: "production"
patterns: ["*"]
174 changes: 152 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,187 @@
name: CI

on:
push:
branches: [master]
pull_request:
schedule:
# Run every on Friday to ensure everything works as expected.
- cron: '0 6 * * 5'
# Weekly, to catch breakage from new Ruby or Zammad releases.
- cron: '0 6 * * 5'
workflow_dispatch:
inputs:
zammad_ref:
description: 'Zammad branch or tag to run the integration specs against (not a commit SHA)'
default: 'develop'
type: string

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

permissions:
contents: read

jobs:
lint:
name: RuboCop
runs-on: ubuntu-latest
container:
image: zammad/zammad-ci:latest
steps:
- uses: actions/checkout@v7
- name: Run lint actions
shell: bash
run: |
source /etc/profile.d/rvm.sh # ensure RVM is loaded
bundle update --bundler
bundle install -j $(nproc)
bundle exec rubocop
test:
- uses: ruby/setup-ruby@v1
with:
ruby-version: '4.0'
bundler-cache: true
- run: bundle exec rubocop --format github

types:
name: Steep
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: ruby/setup-ruby@v1
with:
ruby-version: '4.0'
bundler-cache: true
- run: bundle exec steep check
# sig/vendor is always on the load path here but never in the gem, so
# the published set is checked on its own as well.
- run: bundle exec rake rbs_published

unit:
name: Unit specs (Ruby ${{ matrix.ruby }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Stable releases only, from required_ruby_version up to the current
# stable line. There is no 3.5: that line was abandoned after
# 3.5.0-preview1 and became 4.0.
#
# 'head' is absent. It could not install while the lockfile said
# `BUNDLED WITH 2.6.9`: bundler self-downgraded from head's 4.1.0.dev
# and died with NameError on the removed Pathname::SEPARATOR_PAT, and
# without the lockfile a fresh resolution pulled steep -> listen ->
# rb-inotify -> ffi, whose native gems require Ruby < 4.1.dev. The
# lockfile now names Bundler 4.0.20, which does not use that constant,
# so the first of those may be gone; head has not been retried since.
ruby: ['3.4', '4.0']
env:
# The unit specs do not need the type-checking toolchain, and skipping it
# keeps this job fast. The `types` job installs it separately.
BUNDLE_WITHOUT: development
steps:
- uses: actions/checkout@v7
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run unit specs
run: bundle exec rake spec:unit
env:
COVERAGE: 'true'

integration:
name: Integration specs (live Zammad)
runs-on: ubuntu-latest
# Booting Zammad costs far more runner time than the unit suite, so there
# is no point paying for it when the unit specs are already failing.
needs: unit
# A full Zammad boot takes many minutes; without a cap a hung boot would
# occupy a runner until the six hour default expires.
timeout-minutes: 45
container:
image: zammad/zammad-ci:latest
services:
postgresql:
image: postgres:17
image: postgres:18
env:
POSTGRES_USER: zammad
POSTGRES_PASSWORD: zammad
redis:
image: redis:7
env:
ZAMMAD_REF: ${{ inputs.zammad_ref || 'develop' }}
TEST_USER: admin@example.com
TEST_PASSWORD: test
steps:
- uses: actions/checkout@v7
- name: Set up Zammad

- name: Report the toolchain
shell: bash
run: |
git clone --depth 1 https://github.com/zammad/zammad.git
source /etc/profile.d/rvm.sh
# The gem requires Ruby >= 3.4; fail here with a clear message rather
# than inside a confusing bundler resolution error.
ruby -v
ruby -e 'abort "zammad-ci image ships Ruby #{RUBY_VERSION}, this gem needs >= 3.4" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("3.4")'

- name: Boot Zammad
shell: bash
run: |
# No `set -u`: /etc/profile.d/rvm.sh reads unset variables and aborts
# under nounset.
set -eo pipefail
git clone --depth 1 --branch "$ZAMMAD_REF" https://github.com/zammad/zammad.git
cd zammad
source /etc/profile.d/rvm.sh # ensure RVM is loaded
source /etc/profile.d/rvm.sh
bundle config set --local frozen 'true'
bundle config set --local path 'vendor'
bundle install -j $(nproc)
bundle install -j "$(nproc)"
bundle exec ruby .gitlab/configure_environment.rb
# Each workflow step runs in its own shell, so Zammad's generated
# environment has to be promoted to the job environment to survive.
sed -E 's/^export +//' .gitlab/environment.env \
| grep -E '^[A-Za-z_][A-Za-z0-9_]*=' >> "$GITHUB_ENV"
source .gitlab/environment.env
RAILS_ENV=test bundle exec rake db:create
cp contrib/auto_wizard_test.json auto_wizard.json
bundle exec rake zammad:ci:test:start
- name: Run Ruby API integration tests
echo "TEST_URL=http://localhost:${RAILS_PORT:-3000}/" >> "$GITHUB_ENV"

- name: Wait for Zammad to answer
shell: bash
run: |
probe="${TEST_URL%/}/api/v1/getting_started"
for attempt in $(seq 1 60); do
if curl -sSf --max-time 5 "$probe" >/dev/null 2>&1; then
echo "Zammad answered at $TEST_URL after ${attempt} attempt(s)"
exit 0
fi
sleep 5
done
echo "::error::Zammad never answered at $probe"
exit 1

- name: Install the gem's dependencies
shell: bash
run: |
source /etc/profile.d/rvm.sh
bundle install -j "$(nproc)"

- name: Drive Zammad with this gem
shell: bash
run: |
source /etc/profile.d/rvm.sh
bundle exec ruby script/check_connection.rb

- name: Run the integration specs
shell: bash
run: |
source /etc/profile.d/rvm.sh
bundle exec rake spec:integration

- name: Collect Zammad logs on failure
if: failure()
shell: bash
run: |
source /etc/profile.d/rvm.sh # ensure RVM is loaded
bundle update --bundler
bundle install -j $(nproc)
bundle exec rspec
echo '--- zammad/log ---'
tail -n 200 zammad/log/*.log 2>/dev/null || echo 'no logs found'

- name: Upload Zammad logs
if: failure()
uses: actions/upload-artifact@v7
with:
name: zammad-logs
path: zammad/log/
if-no-files-found: ignore
retention-days: 7
45 changes: 45 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Release

# Publishes to RubyGems via trusted publishing (OIDC), so no API key is
# stored in this repository. Configure the trusted publisher once at
# https://rubygems.org/gems/zammad_api/trusted_publishers
on:
push:
tags: ['v*']

permissions:
contents: read

jobs:
release:
name: Build and publish
runs-on: ubuntu-latest
environment: rubygems
permissions:
contents: write # create the GitHub release and push the tag commit
id-token: write # request the OIDC token for trusted publishing
steps:
- uses: actions/checkout@v7
- uses: ruby/setup-ruby@v1
with:
ruby-version: '4.0'
bundler-cache: true
# The tag is what triggers this workflow, and nothing downstream reads
# it: the gem is built from the gemspec, so a tag that disagrees with
# ZammadAPI::VERSION publishes a gem under a version nobody tagged and
# leaves a GitHub release pointing at one that does not exist.
- name: Check the tag against the gem version and the changelog
run: |
tagged="${GITHUB_REF_NAME#v}"
declared="$(ruby -Ilib -rzammad_api/version -e 'print ZammadAPI::VERSION')"
if [ "$tagged" != "$declared" ]; then
echo "::error::tag ${GITHUB_REF_NAME} does not match ZammadAPI::VERSION ($declared)"
exit 1
fi
if ! grep -q "^## \[${declared}\]" CHANGELOG.md; then
echo "::error::CHANGELOG.md has no '## [${declared}]' heading"
exit 1
fi
- name: Verify the release candidate
run: bundle exec rake spec:unit rubocop steep rbs_published
- uses: rubygems/release-gem@v1
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/.bundle/
/.ruby-version
/.yardoc
/.steep/
/.yardoc/
/_yardoc/
/coverage/
/doc/
Expand Down
50 changes: 20 additions & 30 deletions .overcommit.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,23 @@
# Use this file to configure the Overcommit hooks you wish to use. This will
# extend the default configuration defined in:
# https://github.com/sds/overcommit/blob/master/config/default.yml
# See https://github.com/sds/overcommit#configuration
#
# At the topmost level of this YAML file is a key representing type of hook
# being run (e.g. pre-commit, commit-msg, etc.). Within each type you can
# customize each hook, such as whether to only run it on certain files (via
# `include`), whether to only display output if it fails (via `quiet`), etc.
#
# For a complete list of hooks, see:
# https://github.com/sds/overcommit/tree/master/lib/overcommit/hook
#
# For a complete list of options that you can use to customize hooks, see:
# https://github.com/sds/overcommit#configuration
#
# Uncomment the following lines to make the configuration take effect.
# Install with: bundle exec overcommit --install

PreCommit:
RuboCop:
enabled: true
on_warn: fail # Treat all warnings as failures
#
# TrailingWhitespace:
# enabled: true
# exclude:
# - '**/db/structure.sql' # Ignore trailing whitespace in generated files
#
#PostCheckout:
# ALL: # Special hook name that customizes all hooks of this type
# quiet: true # Change all post-checkout hooks to only display output on failure
#
# IndexTags:
# enabled: true # Generate a tags file with `ctags` each time HEAD changes
RuboCop:
enabled: true
on_warn: fail # Treat all warnings as failures
command: ['bundle', 'exec', 'rubocop']

TrailingWhitespace:
enabled: true

YamlSyntax:
enabled: true

BundleCheck:
enabled: true

RSpec:
enabled: true
description: 'Run the unit specs'
command: ['bundle', 'exec', 'rspec', 'spec/unit']
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
--require spec_helper
--format documentation
--color
Loading