Skip to content

Commit

Permalink
Merge pull request #89 from Sija/develop
Browse files Browse the repository at this point in the history
v1.9.3
  • Loading branch information
Sija committed Feb 26, 2023
2 parents de91bb3 + dd6167f commit f328bfd
Show file tree
Hide file tree
Showing 18 changed files with 62 additions and 68 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
20 changes: 10 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,27 @@ jobs:

steps:
- name: Install Crystal
uses: oprypin/install-crystal@v1
uses: crystal-lang/install-crystal@v1
with:
crystal: ${{ matrix.crystal }}

- name: Download source
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install dependencies
run: shards install
env:
SHARDS_OPTS: --ignore-crystal-version

- name: Run specs
run: |
crystal spec
crystal spec --no-debug
run: crystal spec

- name: Run specs (no-debug)
run: crystal spec --no-debug

- name: Run specs (release)
run: |
crystal spec --release
crystal spec --release --no-debug
run: crystal spec --release

- name: Run specs (release, no-debug)
run: crystal spec --release --no-debug

- name: Build crash handler
run: shards build crash_handler
Expand Down
47 changes: 14 additions & 33 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,33 @@ on:
push:
branches: [master]

permissions:
contents: write

jobs:
build:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v3.x
uses: rlespinasse/github-slug-action@v4

- name: Install Crystal
uses: oprypin/install-crystal@v1
uses: crystal-lang/install-crystal@v1

- name: Download source
uses: actions/checkout@v2
with:
persist-credentials: false
uses: actions/checkout@v3

- name: Install dependencies
run: shards install
env:
SHARDS_OPTS: --ignore-crystal-version

- name: Build docs
run: |
sed -i -e 's:<.*>::g' README.md
crystal docs src/raven.cr --project-version="${{ env.GITHUB_REF_SLUG }}" --source-refname="${{ env.GITHUB_SHA_SHORT }}"
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: docs
path: docs

deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: docs
path: docs
run: crystal docs src/raven.cr --project-version="${{ env.GITHUB_REF_SLUG }}" --source-refname="${{ env.GITHUB_SHA_SHORT }}"

- name: Deploy docs 🚀
uses: JamesIves/github-pages-deploy-action@3.7.1
uses: JamesIves/github-pages-deploy-action@v4
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: docs
CLEAN: true
CLEAN_EXCLUDE: '["img"]'
branch: gh-pages
folder: docs
clean: true
clean-exclude: |
img
8 changes: 4 additions & 4 deletions shard.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: raven
version: 1.9.2
version: 1.9.3

authors:
- Sijawusz Pur Rahnama <[email protected]>
Expand All @@ -15,15 +15,15 @@ dependencies:
development_dependencies:
timecop:
github: crystal-community/timecop.cr
version: ~> 0.4.0
version: ~> 0.5.0
ameba:
github: crystal-ameba/ameba
version: ~> 1.0.0
version: ~> 1.4.0

targets:
crash_handler:
main: src/crash_handler.cr

crystal: ">= 0.35.0"
crystal: ~> 1.6

license: MIT
2 changes: 1 addition & 1 deletion spec/raven/breadcrumb_buffer_spec.cr
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "../spec_helper"

private def with_breadcrumb_buffer
private def with_breadcrumb_buffer(&)
breadcrumbs = Raven::BreadcrumbBuffer.new(10)
yield breadcrumbs
end
Expand Down
2 changes: 1 addition & 1 deletion spec/raven/client_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ private class ClientTest < Raven::Client
end
end

private def with_client
private def with_client(&)
yield ClientTest.new(build_configuration)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/raven/client_state_spec.cr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "../spec_helper"
require "timecop"

private def with_client_state
private def with_client_state(&)
yield Raven::Client::State.new
end

Expand Down
4 changes: 2 additions & 2 deletions spec/raven/configuration_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ private class RandomSampleFail < Random::PCG32
end
end

private def with_configuration
private def with_configuration(&)
with_clean_env do
yield Raven::Configuration.new
end
end

private def with_configuration_with_dsn
private def with_configuration_with_dsn(&)
with_configuration do |configuration|
configuration.dsn = "http://12345:[email protected]:3000/sentry/42"
yield configuration
Expand Down
4 changes: 2 additions & 2 deletions spec/raven/event_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Raven::Test
class Exception < ::Exception; end
end

private def with_event(clear = true, **opts)
private def with_event(clear = true, **opts, &)
if clear
Raven::Context.clear!
Raven::BreadcrumbBuffer.clear!
Expand All @@ -13,7 +13,7 @@ private def with_event(clear = true, **opts)
yield event
end

private def with_event_hash(**opts)
private def with_event_hash(**opts, &)
with_event(**opts) do |event|
yield event.to_hash
end
Expand Down
2 changes: 1 addition & 1 deletion spec/raven/instance_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ private class InstanceTest < Raven::Instance
end
end

private def with_instance(context = nil)
private def with_instance(context = nil, &)
yield InstanceTest.new(context, build_configuration)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/raven/log_backend_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ private def build_logger(source = nil, **opts)
.for(source.to_s)
end

private def with_clean_configuration
private def with_clean_configuration(&)
prev_configuration = Raven.instance.configuration.dup
begin
Raven.instance.configuration = build_configuration
Expand Down
2 changes: 1 addition & 1 deletion spec/raven/processors/spec_helper.cr
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "../../spec_helper"

def with_processor(klass : Raven::Processor.class)
def with_processor(klass : Raven::Processor.class, &)
configuration = Raven::Configuration.new
client = Raven::Client.new(configuration)
processor = klass.new(client)
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require "log/spec"
require "../src/raven"

# Make sure we reset the env in case something leaks in
def with_clean_env
def with_clean_env(&)
sentry_vars = ->{ ENV.to_h.select { |key, _| key.starts_with?("SENTRY_") } }
previous_vars = sentry_vars.call
begin
Expand Down
4 changes: 2 additions & 2 deletions src/crash_handler.cr
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module Raven
end
end

private def capture_with_options(*args, **options)
private def capture_with_options(*args, **options, &)
options = DEFAULT_OPTS.merge(options)
capture(*args, **options) do |event|
yield event
Expand All @@ -84,7 +84,7 @@ module Raven
capture_with_options(*args, **options) { }
end

private def capture_with_options(**options)
private def capture_with_options(**options, &)
yield
rescue ex : Raven::Error
raise ex # Don't capture Raven errors
Expand Down
4 changes: 2 additions & 2 deletions src/raven/breadcrumb_buffer.cr
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module Raven
@buffer << crumb
end

def record(**opts) : Nil
def record(**opts, &) : Nil
crumb = Breadcrumb.new(**opts)
yield crumb
record crumb
Expand All @@ -50,7 +50,7 @@ module Raven
members.last?
end

def each
def each(&)
members.each do |breadcrumb|
yield breadcrumb
end
Expand Down
9 changes: 7 additions & 2 deletions src/raven/context.cr
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@ module Raven
end

class_getter runtime_context : AnyHash::JSON do
v = Crystal::DESCRIPTION.match /^(.+?) (\d+[^\n]+)\n+LLVM: (\d+[^\n]+)\nDefault target: (.+?)$/m
_, name, version = v.not_nil!
version_pattern = /^(.+?) (\d+[^\n]+)\n+LLVM: (\d+[^\n]+)\nDefault target: (.+?)$/m

unless match = Crystal::DESCRIPTION.match(version_pattern)
raise Raven::Error.new("Couldn't parse runtime version")
end

_, name, version, _llvm_version, _target = match
{
name: name,
version: version,
Expand Down
8 changes: 4 additions & 4 deletions src/raven/instance.cr
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ module Raven
end

# :ditto:
def configure
def configure(&)
yield configuration
configure
end
Expand Down Expand Up @@ -127,7 +127,7 @@ module Raven
# event.extra.merge! foo: "bar"
# end
# ```
def capture(obj : Exception | String, **options, &block)
def capture(obj : Exception | String, **options, &)
unless configuration.capture_allowed?(obj)
Log.debug {
"'#{obj}' excluded from capture: #{configuration.error_messages}"
Expand Down Expand Up @@ -190,7 +190,7 @@ module Raven
# NOTE: Useful in scenarios where you need to reconstruct the error
# (usually along with a backtrace from external source), while
# having no access to the actual Exception object.
def capture(klass : String, message : String, backtrace : String? = nil, **options, &block)
def capture(klass : String, message : String, backtrace : String? = nil, **options, &)
formatted_message = "#{klass}: #{message}"
capture(formatted_message, **options) do |event|
ex = Interface::SingleException.new.tap do |iface|
Expand Down Expand Up @@ -219,7 +219,7 @@ module Raven
# MyApp.run
# end
# ```
def capture(**options, &block)
def capture(**options, &)
yield
rescue ex : Raven::Error
raise ex # Don't capture Raven errors
Expand Down
1 change: 1 addition & 0 deletions src/raven/transports/http.cr
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module Raven
private def build_client
ssl = configuration.ssl
ssl = configuration.scheme == "https" if ssl.nil?
# ameba:disable Lint/NotNil
::HTTP::Client.new(configuration.host.not_nil!, configuration.port, ssl).tap do |client|
client.before_request do |request|
request.headers["User-Agent"] = Client::USER_AGENT
Expand Down

0 comments on commit f328bfd

Please sign in to comment.