Skip to content

Commit 85c159a

Browse files
feat!: v1.0.0
0 parents  commit 85c159a

25 files changed

+998
-0
lines changed

.github/workflows/ci.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
ruby-version: ['3.1', '3.2', '3.3', '3.4']
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up Ruby ${{ matrix.ruby-version }}
21+
uses: ruby/setup-ruby@v1
22+
with:
23+
ruby-version: ${{ matrix.ruby-version }}
24+
bundler-cache: true
25+
26+
- name: Run all checks (tests, rubocop, rbs)
27+
run: bundle exec rake
28+
29+
- name: Check conventional commits (PR only)
30+
if: github.event_name == 'pull_request'
31+
run: bundle exec rake commit_lint
32+
33+
test-build:
34+
runs-on: ubuntu-latest
35+
needs: test
36+
strategy:
37+
fail-fast: false
38+
matrix:
39+
ruby-version: ['3.1', '3.2', '3.3', '3.4']
40+
steps:
41+
- uses: actions/checkout@v4
42+
43+
- name: Set up Ruby ${{ matrix.ruby-version }}
44+
uses: ruby/setup-ruby@v1
45+
with:
46+
ruby-version: ${{ matrix.ruby-version }}
47+
bundler-cache: true
48+
49+
- name: Build gem
50+
run: bundle exec rake build
51+
52+
- name: Test gem installation
53+
run: gem install ./pkg/activejob-compressible-*.gem
54+
55+
- name: Test gem loading
56+
run: ruby -e "require 'activejob-compressible'; puts 'Gem loads successfully!'; puts 'Version:', ActiveJob::Compressible::VERSION"

.github/workflows/publish.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Publish Gem
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
tag_name:
9+
description: 'Tag name to publish (e.g., v1.0.0)'
10+
required: true
11+
type: string
12+
13+
jobs:
14+
publish:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Ruby
20+
uses: ruby/setup-ruby@v1
21+
with:
22+
ruby-version: '3.2'
23+
bundler-cache: true
24+
25+
- name: Extract version from tag
26+
id: version
27+
run: |
28+
# Get tag from either release event or manual input
29+
if [ "${{ github.event_name }}" = "release" ]; then
30+
TAG_NAME="${{ github.event.release.tag_name }}"
31+
else
32+
TAG_NAME="${{ inputs.tag_name }}"
33+
fi
34+
VERSION=${TAG_NAME#v} # Remove 'v' prefix
35+
echo "version=$VERSION" >> $GITHUB_OUTPUT
36+
echo "tag=$TAG_NAME" >> $GITHUB_OUTPUT
37+
38+
- name: Verify version matches
39+
run: |
40+
GEMSPEC_VERSION=$(ruby -r ./lib/activejob/compressible/version.rb -e "puts ActiveJob::Compressible::VERSION")
41+
RELEASE_VERSION="${{ steps.version.outputs.version }}"
42+
43+
if [ "$GEMSPEC_VERSION" != "$RELEASE_VERSION" ]; then
44+
echo "Error: Version mismatch!"
45+
echo "Gemspec version: $GEMSPEC_VERSION"
46+
echo "Release version: $RELEASE_VERSION"
47+
exit 1
48+
fi
49+
50+
echo "✅ Version verified: $GEMSPEC_VERSION"
51+
52+
- name: Build gem with checksum
53+
run: bundle exec rake build:checksum
54+
55+
- name: Set up RubyGems credentials
56+
run: |
57+
mkdir -p ~/.gem
58+
echo ":rubygems_api_key: ${{ secrets.RUBYGEMS_API_KEY }}" > ~/.gem/credentials
59+
chmod 0600 ~/.gem/credentials
60+
61+
- name: Publish to RubyGems
62+
run: gem push pkg/activejob-compressible-*.gem
63+
64+
- name: Annotate publication success
65+
id: publish_info
66+
run: |
67+
VERSION="${{ steps.version.outputs.version }}"
68+
TAG="${{ steps.version.outputs.tag }}"
69+
RUBYGEMS_URL="https://rubygems.org/gems/activejob-compressible/versions/$VERSION"
70+
INSTALL_CMD="gem install activejob-compressible -v $VERSION"
71+
72+
echo "version=$VERSION" >> $GITHUB_OUTPUT
73+
echo "tag=$TAG" >> $GITHUB_OUTPUT
74+
echo "rubygems_url=$RUBYGEMS_URL" >> $GITHUB_OUTPUT
75+
echo "install_cmd=$INSTALL_CMD" >> $GITHUB_OUTPUT
76+
77+
cat >> $GITHUB_STEP_SUMMARY << EOF
78+
# 🎉 Gem Published Successfully!
79+
80+
`activejob-compressible` version `$VERSION` has been published to RubyGems.
81+
82+
## 📦 Installation
83+
\`\`\`bash
84+
$INSTALL_CMD
85+
\`\`\`
86+
87+
## 🔗 Links
88+
- **RubyGems:** [$RUBYGEMS_URL]($RUBYGEMS_URL)
89+
- **Git Tag:** \`$TAG\`
90+
- **GitHub Release:** [View Release](https://github.com/Archetypically/activejob-compressible/releases/tag/$TAG)
91+
EOF

.github/workflows/release.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths:
7+
- 'lib/activejob/compressible/version.rb'
8+
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Extract version
18+
id: version
19+
run: |
20+
VERSION=$(ruby -r ./lib/activejob/compressible/version.rb -e "puts ActiveJob::Compressible::VERSION")
21+
echo "version=$VERSION" >> $GITHUB_OUTPUT
22+
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
23+
24+
- name: Extract changelog entry
25+
id: changelog
26+
run: |
27+
VERSION="${{ steps.version.outputs.version }}"
28+
29+
# Extract the changelog entry for this version
30+
awk -v version="$VERSION" '
31+
BEGIN { found=0; content="" }
32+
/^## \[/ {
33+
if (found) exit
34+
if ($0 ~ "\\[" version "\\]") found=1
35+
next
36+
}
37+
found && /^## \[/ { exit }
38+
found {
39+
if (content != "") content = content "\n"
40+
content = content $0
41+
}
42+
END { print content }
43+
' CHANGELOG.md > changelog_entry.txt
44+
45+
# Set the changelog content as output
46+
{
47+
echo 'changelog<<EOF'
48+
cat changelog_entry.txt
49+
echo EOF
50+
} >> $GITHUB_OUTPUT
51+
52+
- name: Check if tag exists
53+
id: check_tag
54+
run: |
55+
TAG="${{ steps.version.outputs.tag }}"
56+
if git rev-parse "$TAG" >/dev/null 2>&1; then
57+
echo "exists=true" >> $GITHUB_OUTPUT
58+
else
59+
echo "exists=false" >> $GITHUB_OUTPUT
60+
fi
61+
62+
- name: Create Release
63+
if: steps.check_tag.outputs.exists == 'false'
64+
uses: actions/create-release@v1
65+
env:
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
with:
68+
tag_name: ${{ steps.version.outputs.tag }}
69+
release_name: Release ${{ steps.version.outputs.tag }}
70+
body: ${{ steps.changelog.outputs.changelog }}
71+
draft: false
72+
prerelease: false

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/.bundle/
2+
/.yardoc
3+
/_yardoc/
4+
/coverage/
5+
/doc/
6+
/pkg/
7+
/checksums/
8+
/spec/reports/
9+
/tmp/
10+
11+
# Generated gem files
12+
*.gem

.gitmessage

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# <type>[optional scope]: <description>
2+
#
3+
# [optional body]
4+
#
5+
# [optional footer(s)]
6+
#
7+
# Types:
8+
# feat: A new feature
9+
# fix: A bug fix
10+
# docs: Documentation only changes
11+
# style: Changes that do not affect the meaning of the code
12+
# refactor: A code change that neither fixes a bug nor adds a feature
13+
# test: Adding missing tests or correcting existing tests
14+
# chore: Changes to the build process or auxiliary tools
15+
# ci: Changes to CI configuration files and scripts
16+
#
17+
# Examples:
18+
# feat: add compression threshold configuration
19+
# fix(config): handle missing cache backend gracefully
20+
# docs: update README with installation instructions
21+
# ci: add RBS validation to workflow

.rubocop.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
AllCops:
2+
TargetRubyVersion: 3.1
3+
NewCops: enable
4+
5+
Style/StringLiterals:
6+
EnforcedStyle: double_quotes
7+
8+
Style/StringLiteralsInInterpolation:
9+
EnforcedStyle: double_quotes
10+
11+
Naming/FileName:
12+
Exclude:
13+
- lib/activejob-compressible.rb

CHANGELOG.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [1.0.0] - 2025-06-05
9+
10+
### Added
11+
- Initial release of ActiveJob::Compressible gem
12+
- Transparent compression/decompression for large ActiveJob payloads
13+
- Automatic detection of Rails cache backend limits for smart defaults
14+
- Configurable compression threshold via `ActiveJob::Compressible.configure`
15+
- Support for zlib compression algorithm with base64 encoding
16+
- Backward compatibility for existing uncompressed jobs
17+
- Safe compression markers (`"_compressed"` key) for reliable detection
18+
- Comprehensive test suite with dynamic configuration testing
19+
- Support for Ruby >= 3.1 and Rails 6.0-8.x
20+
- Detailed documentation and usage examples
21+
22+
### Technical Details
23+
- Uses zlib compression with base64 encoding for safety
24+
- Only compresses Hash arguments that exceed the configured threshold
25+
- Defaults to cache `value_max_bytes` minus 100KB for safety margin
26+
- Graceful fallback to 948KB default if cache limits not detected
27+
- Thread-safe configuration system
28+
- Minimal performance overhead (~1-5ms for typical payloads)
29+
30+
### Documentation
31+
- Complete README with usage examples and configuration options
32+
- API documentation with inline comments
33+
- Development setup and testing instructions
34+
- Performance characteristics and compatibility notes

Gemfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# frozen_string_literal: true
2+
3+
source "https://rubygems.org"
4+
5+
# Specify your gem's dependencies in activejob-compressible.gemspec
6+
gemspec
7+
8+
gem "rake", "~> 13.0"
9+
10+
gem "minitest", "~> 5.16"
11+
12+
gem "rubocop", "~> 1.21"
13+
14+
# RBS type checking
15+
gem "rbs", "~> 3.0"
16+
17+
# For testing
18+
gem "activejob", ">= 6.0"

0 commit comments

Comments
 (0)