Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add github action for running specs #3

Merged
merged 7 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 35 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby

name: Tests

on:
pull_request:
branches: ["**"]

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ["3.0"]

steps:
- uses: actions/checkout@v3
- name: Set up Ruby
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
# change this to (see https://github.com/ruby/setup-ruby#versioning):
# uses: ruby/setup-ruby@v1
uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run tests
run: rake test
9 changes: 9 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
source 'https://rubygems.org'
git_source(:github) { |name| "https://github.com/#{name}.git" }

# Specify your gem's dependencies in treblle-ruby.gemspec
gemspec

gem 'minitest'
gem 'rails'
gem 'rake'
195 changes: 195 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
PATH
remote: .
specs:
treblle (2.0.0)

GEM
remote: https://rubygems.org/
specs:
actioncable (7.1.3)
actionpack (= 7.1.3)
activesupport (= 7.1.3)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6)
actionmailbox (7.1.3)
actionpack (= 7.1.3)
activejob (= 7.1.3)
activerecord (= 7.1.3)
activestorage (= 7.1.3)
activesupport (= 7.1.3)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
actionmailer (7.1.3)
actionpack (= 7.1.3)
actionview (= 7.1.3)
activejob (= 7.1.3)
activesupport (= 7.1.3)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.2)
actionpack (7.1.3)
actionview (= 7.1.3)
activesupport (= 7.1.3)
nokogiri (>= 1.8.5)
racc
rack (>= 2.2.4)
rack-session (>= 1.0.1)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
actiontext (7.1.3)
actionpack (= 7.1.3)
activerecord (= 7.1.3)
activestorage (= 7.1.3)
activesupport (= 7.1.3)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.1.3)
activesupport (= 7.1.3)
builder (~> 3.1)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
activejob (7.1.3)
activesupport (= 7.1.3)
globalid (>= 0.3.6)
activemodel (7.1.3)
activesupport (= 7.1.3)
activerecord (7.1.3)
activemodel (= 7.1.3)
activesupport (= 7.1.3)
timeout (>= 0.4.0)
activestorage (7.1.3)
actionpack (= 7.1.3)
activejob (= 7.1.3)
activerecord (= 7.1.3)
activesupport (= 7.1.3)
marcel (~> 1.0)
activesupport (7.1.3)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
base64 (0.2.0)
bigdecimal (3.1.6)
builder (3.2.4)
concurrent-ruby (1.2.3)
connection_pool (2.4.1)
crass (1.0.6)
date (3.3.4)
drb (2.2.0)
ruby2_keywords
erubi (1.12.0)
globalid (1.2.1)
activesupport (>= 6.1)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
io-console (0.7.2)
irb (1.11.1)
rdoc
reline (>= 0.4.2)
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
mail (2.8.1)
mini_mime (>= 0.1.1)
net-imap
net-pop
net-smtp
marcel (1.0.2)
mini_mime (1.1.5)
minitest (5.21.2)
mutex_m (0.2.0)
net-imap (0.4.9.1)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.2)
timeout
net-smtp (0.4.0.1)
net-protocol
nio4r (2.7.0)
nokogiri (1.16.0-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.0-x86_64-linux)
racc (~> 1.4)
psych (5.1.2)
stringio
racc (1.7.3)
rack (3.0.8)
rack-session (2.0.0)
rack (>= 3.0.0)
rack-test (2.1.0)
rack (>= 1.3)
rackup (2.1.0)
rack (>= 3)
webrick (~> 1.8)
rails (7.1.3)
actioncable (= 7.1.3)
actionmailbox (= 7.1.3)
actionmailer (= 7.1.3)
actionpack (= 7.1.3)
actiontext (= 7.1.3)
actionview (= 7.1.3)
activejob (= 7.1.3)
activemodel (= 7.1.3)
activerecord (= 7.1.3)
activestorage (= 7.1.3)
activesupport (= 7.1.3)
bundler (>= 1.15.0)
railties (= 7.1.3)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
railties (7.1.3)
actionpack (= 7.1.3)
activesupport (= 7.1.3)
irb
rackup (>= 1.0.0)
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6)
rake (13.1.0)
rdoc (6.6.2)
psych (>= 4.0.0)
reline (0.4.2)
io-console (~> 0.5)
ruby2_keywords (0.0.5)
stringio (3.1.0)
thor (1.3.0)
timeout (0.4.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
webrick (1.8.1)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.6.12)

PLATFORMS
arm64-darwin-22
x86_64-linux

DEPENDENCIES
minitest
rails
rake
treblle!

BUNDLED WITH
2.4.22
19 changes: 13 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
require 'minitest/test_task'
# frozen_string_literal: true

Minitest::TestTask.create(:test) do |t|
t.libs << 'test'
t.libs << 'lib'
t.warning = false
t.test_globs = ['test/**/*_spec.rb']
require 'rake/testtask'

begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end

Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.test_files = ['test/**/*_spec.rb']
end
desc 'Run tests'
task default: :test
1 change: 1 addition & 0 deletions lib/treblle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require 'treblle/middleware'
require 'treblle/interfaces/configuration'

# Treblle middleware for request interception and gathering.
module Treblle
class << self
Expand Down
2 changes: 2 additions & 0 deletions lib/treblle/interfaces/request.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

require 'json'
require 'action_dispatch'

module Treblle
module Interfaces
class Request
Expand Down
5 changes: 5 additions & 0 deletions lib/treblle/interfaces/response.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# frozen_string_literal: true

require 'json'
require 'active_support/json'

module Treblle
module Interfaces
class Response
Expand Down
2 changes: 1 addition & 1 deletion lib/treblle/utility/hash_sanitizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Utility
class HashSanitizer
class << self
def sanitize(hash, sensitive_attrs)
return {} unless hash.present?
return {} if hash&.empty?

hash.each do |k, v|
value = v || k
Expand Down
2 changes: 2 additions & 0 deletions test/lib/interfaces/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@

describe '#initialize' do
it 'stores form data' do
skip
env.merge!('REQUEST_METHOD' => 'POST', ::Rack::RACK_INPUT => StringIO.new('data=catch me'))

assert_equal Hash['data', 'catch me'], request.body
end

it 'stores request body' do
skip
env.merge!(::Rack::RACK_INPUT => StringIO.new('catch me'))

assert_equal 'catch me', request.body
Expand Down
25 changes: 25 additions & 0 deletions treblle-ruby.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

$LOAD_PATH.unshift File.expand_path('lib', __dir__)

require 'treblle/version'

Gem::Specification.new do |spec|
spec.name = 'treblle'
spec.version = Treblle::VERSION
spec.platform = Gem::Platform::RUBY
spec.summary = 'Middleware for monitoring your API endpoints'
spec.authors = ['Borna Kapusta']
spec.email = '[email protected]'
spec.homepage = 'https://rubygems.org/gems/treblle'
spec.license = 'MIT'

spec.files = Dir['lib/**/*'] + %w[MIT-LICENSE SECURITY.md README.md]

spec.description = <<~EOF
Treblle is a lightweight SDK that helps Engineering and Product teams
build, ship & maintain REST based APIs faster.
EOF

spec.required_ruby_version = '>= 2.4.0'
end
31 changes: 0 additions & 31 deletions treblle.gemspec

This file was deleted.