-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ruby): add Readme::Webhook.verify() function to verify webhooks (#…
…568) * chore: initial commit of lightweight rails app Generated using this, which seemed to give me as lightweight a rails app as humanly possible: ```sh rails new metrics-rails --api --minimal --skip-keeps --skip-test ``` * feat(ruby): add very basic integration test scaffolding * chore(integration): add test watch command for mocha with nodemon * fix(ruby): send valid v4 uuid Update from `logId` to `_id` Remove uuid dependency and replace with std library securerandom: https://docs.ruby-lang.org/en/3.1/SecureRandom.html * fix(ruby): update to use UTC formatted date for startedDateTime * fix(integration): add support for rails-style querystrings * chore(integration): update code comment to be runnable * fix(ruby): ensure we're returning with host header Rack doesn't return with the port in the Host header, unless it is one of the known ports (80/443) https://rubydoc.info/gems/rack/Rack/Request/Helpers#DEFAULT_PORTS-constant So I opted to just use `host` instead of `host_with_port`, since I figured we'd actually probably only want the port if it was non-standard, not the other way around. * fix(ruby): allow endpoint to be overridden via METRICS_SERVER env var * feat(integration/ruby/rails): get the Metrics middleware configured * chore(integration/ruby/rails): lint * chore(integration/ruby/rails): update README.md * feat(integration/ruby/rails): get test working in Docker * chore(ruby): bump rubocop and lint everything * feat(integration/ruby/rails): webhooks code working * chore(integration/ruby/rails): switch default port to 8000 to match others * chore(integration/ruby/rails): add to docker and github action * chore(integration/ruby/rails): add webhooks example to readme.md * chore(integration/ruby/rails): lint * feat(ruby): add Readme::Webhook.verify() function to verify webhooks * chore(integration/ruby/rails): switch app to use Readme::Webhook.verify * chore(prettier): lint * Update packages/ruby/examples/metrics-rails/README.md Co-authored-by: Jon Ursenbach <[email protected]> * Update packages/ruby/examples/metrics-rails/app/controllers/metrics_controller.rb Co-authored-by: Kelly Joseph Price <[email protected]> * refactor(ruby): use custom error classes Co-authored-by: Kelly Joseph Price <[email protected]> * refactor(ruby): switched to using more specific exception types * chore(ruby): lint and fix tests * refactor(ruby/webhooks): switch to using rspec raise_error matcher in tests * refactor(ruby/integration): switch base image to ruby:3.1.2 * feat: ruby sdk snippet (#584) * refactor(ruby/webhooks): add consistent code comments with other snippets * feat(ruby/sdk-snippets): add webhook code snippet * chore(ruby): lint * chore(ruby/integration): fix up ruby.yml for gh actions * ci: try to make sure external webserver is up before spinning mock metrics * ci: attempt to sleep for 500ms in test before resolving isListening * chore(integration): try and sleep before running tests * chore(integration): add comment about `sleep 5` Co-authored-by: Jon Ursenbach <[email protected]> Co-authored-by: Kelly Joseph Price <[email protected]>
- Loading branch information
1 parent
65117ef
commit 9189727
Showing
70 changed files
with
1,707 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM ruby:3.1.2 | ||
|
||
RUN bundle config --global frozen 1 | ||
|
||
WORKDIR /usr/src/app | ||
|
||
COPY packages/ruby . | ||
RUN bundle install | ||
|
||
# Install example dependencies | ||
WORKDIR /usr/src/app/examples/metrics-rails | ||
RUN bundle install | ||
|
||
CMD ["bin/rails", "server", "-b", "0.0.0.0", "-p", "8000"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# See https://git-scm.com/docs/gitattributes for more about git attribute files. | ||
|
||
# Mark the database schema as having been generated. | ||
db/schema.rb linguist-generated | ||
|
||
# Mark any vendored files as having been vendored. | ||
vendor/* linguist-vendored |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# See https://help.github.com/articles/ignoring-files for more about ignoring files. | ||
# | ||
# If you find yourself ignoring temporary files generated by your text editor | ||
# or operating system, you probably want to add a global ignore instead: | ||
# git config --global core.excludesfile '~/.gitignore_global' | ||
|
||
# Ignore bundler config. | ||
/.bundle | ||
|
||
# Ignore the default SQLite database. | ||
/db/*.sqlite3 | ||
/db/*.sqlite3-* | ||
|
||
# Ignore all logfiles and tempfiles. | ||
/log/* | ||
/tmp/* | ||
|
||
|
||
# Ignore master key for decrypting credentials and more. | ||
/config/master.key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ruby-3.1.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
source 'https://rubygems.org' | ||
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | ||
|
||
ruby '3.1.2' | ||
|
||
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" | ||
gem 'rails', '~> 7.0.3', '>= 7.0.3.1' | ||
|
||
# Use sqlite3 as the database for Active Record | ||
gem 'sqlite3', '~> 1.4' | ||
|
||
# Use the Puma web server [https://github.com/puma/puma] | ||
gem 'puma', '~> 5.0' | ||
|
||
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem | ||
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby] | ||
|
||
# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible | ||
# gem "rack-cors" | ||
|
||
group :development, :test do | ||
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem | ||
gem 'debug', platforms: %i[mri mingw x64_mingw] | ||
end | ||
|
||
group :development do | ||
# Speed up commands on slow machines / big apps [https://github.com/rails/spring] | ||
# gem "spring" | ||
end | ||
|
||
gem 'readme-metrics', path: '../../' |
Oops, something went wrong.