Skip to content

Commit fe1855c

Browse files
Initial public release
0 parents  commit fe1855c

34 files changed

Lines changed: 4361 additions & 0 deletions

.github/workflows/ci.yml

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Install Rust
16+
uses: dtolnay/rust-toolchain@stable
17+
with:
18+
components: rustfmt, clippy
19+
20+
- name: Check formatting
21+
run: cargo fmt --manifest-path ext/amq_protocol_native/Cargo.toml -- --check
22+
23+
- name: Clippy
24+
run: cargo clippy --manifest-path ext/amq_protocol_native/Cargo.toml -- -D warnings
25+
26+
test:
27+
runs-on: ${{ matrix.os }}
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
os: [ubuntu-latest, macos-latest, macos-13, windows-latest]
32+
ruby: ['2.7', '3.0', '3.1', '3.2', '3.3', '3.4']
33+
exclude:
34+
# macOS 13 (x64) with older Ruby versions
35+
- os: macos-13
36+
ruby: '3.4'
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- uses: oxidize-rb/actions/setup-ruby-and-rust@v1
41+
with:
42+
ruby-version: ${{ matrix.ruby }}
43+
bundler-cache: true
44+
cargo-cache: true
45+
46+
- name: Compile extension
47+
run: bundle exec rake compile
48+
49+
- name: Run tests
50+
run: bundle exec rake spec
51+
52+
# Separate job for Ruby 2.5/2.6 which may need special handling
53+
test-legacy-ruby:
54+
runs-on: ${{ matrix.os }}
55+
strategy:
56+
fail-fast: false
57+
matrix:
58+
os: [ubuntu-22.04]
59+
ruby: ['2.5', '2.6']
60+
continue-on-error: true
61+
steps:
62+
- uses: actions/checkout@v4
63+
64+
- uses: ruby/setup-ruby@v1
65+
with:
66+
ruby-version: ${{ matrix.ruby }}
67+
68+
- name: Install Rust
69+
uses: dtolnay/rust-toolchain@stable
70+
71+
- name: Install dependencies
72+
run: bundle install
73+
74+
- name: Compile extension
75+
run: bundle exec rake compile
76+
77+
- name: Run tests
78+
run: bundle exec rake spec
79+
80+
cross-compile:
81+
runs-on: ubuntu-latest
82+
strategy:
83+
fail-fast: false
84+
matrix:
85+
platform:
86+
- x86_64-linux
87+
- x86_64-linux-musl
88+
- aarch64-linux
89+
- aarch64-linux-musl
90+
- x86_64-darwin
91+
- arm64-darwin
92+
- x64-mingw-ucrt
93+
- x64-mingw32
94+
steps:
95+
- uses: actions/checkout@v4
96+
97+
- uses: oxidize-rb/actions/setup-ruby-and-rust@v1
98+
with:
99+
ruby-version: '3.3'
100+
bundler-cache: true
101+
cargo-cache: true
102+
103+
- uses: oxidize-rb/actions/cross-gem@v1
104+
with:
105+
platform: ${{ matrix.platform }}
106+
ruby-versions: '2.7,3.0,3.1,3.2,3.3,3.4'
107+
108+
- name: Upload gems
109+
uses: actions/upload-artifact@v4
110+
with:
111+
name: gem-${{ matrix.platform }}
112+
path: pkg/*.gem
113+
if-no-files-found: error
114+
115+
source-gem:
116+
runs-on: ubuntu-latest
117+
steps:
118+
- uses: actions/checkout@v4
119+
120+
- uses: ruby/setup-ruby@v1
121+
with:
122+
ruby-version: '3.3'
123+
bundler-cache: true
124+
125+
- name: Build source gem
126+
run: bundle exec rake build
127+
128+
- name: Upload gem
129+
uses: actions/upload-artifact@v4
130+
with:
131+
name: gem-source
132+
path: pkg/*.gem
133+
if-no-files-found: error

.github/workflows/release.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
native-gems:
10+
name: Build native gems
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
platform:
16+
- x86_64-linux
17+
- x86_64-linux-musl
18+
- aarch64-linux
19+
- aarch64-linux-musl
20+
- x86_64-darwin
21+
- arm64-darwin
22+
- x64-mingw-ucrt
23+
- x64-mingw32
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- uses: oxidize-rb/actions/setup-ruby-and-rust@v1
28+
with:
29+
ruby-version: '3.3'
30+
bundler-cache: true
31+
cargo-cache: true
32+
33+
- uses: oxidize-rb/actions/cross-gem@v1
34+
with:
35+
platform: ${{ matrix.platform }}
36+
ruby-versions: '2.7,3.0,3.1,3.2,3.3,3.4'
37+
38+
- uses: actions/upload-artifact@v4
39+
with:
40+
name: gem-${{ matrix.platform }}
41+
path: pkg/*.gem
42+
if-no-files-found: error
43+
44+
source-gem:
45+
name: Build source gem
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@v4
49+
50+
- uses: ruby/setup-ruby@v1
51+
with:
52+
ruby-version: '3.3'
53+
bundler-cache: true
54+
55+
- run: bundle exec rake build
56+
57+
- uses: actions/upload-artifact@v4
58+
with:
59+
name: gem-source
60+
path: pkg/*.gem
61+
if-no-files-found: error
62+
63+
release:
64+
name: Release to RubyGems
65+
needs: [native-gems, source-gem]
66+
runs-on: ubuntu-latest
67+
environment: rubygems
68+
permissions:
69+
id-token: write
70+
contents: write
71+
steps:
72+
- uses: actions/checkout@v4
73+
74+
- uses: ruby/setup-ruby@v1
75+
with:
76+
ruby-version: '3.3'
77+
78+
- uses: actions/download-artifact@v4
79+
with:
80+
path: gems
81+
pattern: gem-*
82+
merge-multiple: true
83+
84+
- name: List gems
85+
run: ls -la gems/
86+
87+
- name: Configure RubyGems credentials
88+
run: |
89+
mkdir -p ~/.gem
90+
cat << EOF > ~/.gem/credentials
91+
---
92+
:rubygems_api_key: ${{ secrets.RUBYGEMS_API_KEY }}
93+
EOF
94+
chmod 0600 ~/.gem/credentials
95+
96+
- name: Publish to RubyGems
97+
run: |
98+
for gem in gems/*.gem; do
99+
echo "Publishing $gem..."
100+
gem push "$gem" || echo "Failed to push $gem (may already exist)"
101+
done
102+
103+
- name: Create GitHub Release
104+
uses: softprops/action-gh-release@v2
105+
with:
106+
files: gems/*.gem
107+
generate_release_notes: true

.gitignore

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Rust build artifacts
2+
/target/
3+
ext/amq_protocol_native/target/
4+
**/*.rs.bk
5+
6+
# Ruby native extension build artifacts
7+
*.bundle
8+
*.so
9+
*.dll
10+
*.dylib
11+
*.o
12+
*.a
13+
lib/amq/protocol/*.bundle
14+
lib/amq/protocol/*.so
15+
lib/amq/protocol/*.dylib
16+
lib/amq/protocol/*/*.bundle
17+
lib/amq/protocol/*/*.so
18+
lib/amq/protocol/*/*.dylib
19+
20+
# Build directories
21+
tmp/
22+
pkg/
23+
24+
# Cross-compilation (rb-sys)
25+
ports/
26+
27+
# IDE and editors
28+
.idea/
29+
.vscode/
30+
*.swp
31+
*.swo
32+
*~
33+
\#*\#
34+
.#*
35+
36+
# macOS
37+
.DS_Store
38+
._*
39+
40+
# Ruby version managers
41+
.ruby-version
42+
.ruby-gemset
43+
.rvmrc
44+
45+
# Bundler
46+
Gemfile.lock
47+
.bundle/
48+
vendor/bundle/
49+
50+
# RSpec
51+
.rspec_status
52+
53+
# Test coverage
54+
coverage/
55+
.simplecov
56+
57+
# Documentation
58+
doc/
59+
.yardoc/
60+
rdoc/

.rspec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--require spec_helper
2+
--format documentation
3+
--color

AGENTS.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Instructions for AI Agents
2+
3+
## Overview
4+
5+
This is a native implementation of the Ruby `amq-protocol` gem (an AMQP 0-9-1 serializer and deserializer)
6+
that strives to be a (much) more efficient drop-in replacement
7+
to be eventually adopted by Bunny.
8+
9+
10+
## Build and Test
11+
12+
```bash
13+
bundle install
14+
bundle exec rake compile
15+
bundle exec rake spec
16+
```
17+
18+
For Rust linting:
19+
20+
```bash
21+
cargo fmt --manifest-path ext/amq_protocol_native/Cargo.toml
22+
cargo clippy --manifest-path ext/amq_protocol_native/Cargo.toml
23+
```
24+
25+
## Target Rust Version
26+
27+
* This project requires Rust 1.70+
28+
29+
## Rust Code Style
30+
31+
* Use top-level `use` statements (imports) to fully-qualified names, e.g. `Display` or `fmt::Display` with a `use` statement, to `std::fmt::Display`
32+
* Never use function-local `use` statements (imports)
33+
* Add tests to the modules under `tests`, never in the implementation files
34+
* At the end of each task, run `cargo fmt --all`
35+
* At the end of each task, run `cargo clippy --all` and fix any warnings it might emit
36+
37+
## Comments
38+
39+
* Only add very important comments, both in tests and in the implementation
40+
41+
## Git Instructions
42+
43+
* Never add yourself to the list of commit co-authors
44+
45+
## Style Guide
46+
47+
* Never add full stops to Markdown list items

0 commit comments

Comments
 (0)