diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..69176ee --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,101 @@ +version: 2.1 +tagged_build_filters: &tagged_build_filters + branches: + ignore: /.*/ + tags: + only: /v[0-9]+\.[0-9]+\.[0-9]+/ +test_build_filters: &test_build_filters + branches: + only: /.*/ + tags: + ignore: /v[0-9]+\.[0-9]+\.[0-9]+/ +jobs: + test: + docker: + - image: circleci/ruby:2.6.5 + steps: + - checkout + - run: bundle install + - run: rubocop -c .rubocop.yml -a + build: + docker: + - image: circleci/ruby:2.6.5 + steps: + - checkout + - run: + name: Check Tagged Push + command: | + PKG_VERSION=$(grep VERSION lib/version.rb | cut -d'"' -f2) + if [[ "${CIRCLE_TAG}" != "v${PKG_VERSION}" ]]; then + echo "There is mismatch:" + echo " TAG_VERSION: ${CIRCLE_TAG}" + echo " PKG_VERSION: v${PKG_VERSION}" + exit 1 + fi + - run: gem build logdna.gemspec + - persist_to_workspace: + root: . + paths: + - ./logdna-*.gem + release: + docker: + - image: circleci/golang:1.12 + steps: + - attach_workspace: + at: . + - run: go get -u github.com/tcnksm/ghr + - run: + name: Create a Release + command: | + ghr \ + -n "LogDNA Ruby Logger ${CIRCLE_TAG}" \ + -t ${GITHUB_TOKEN} \ + -u ${CIRCLE_PROJECT_USERNAME} \ + -r ${CIRCLE_PROJECT_REPONAME} \ + -draft ${CIRCLE_TAG} ${CIRCLE_WORKING_DIRECTORY} + - persist_to_workspace: + root: . + paths: + - ./logdna-*.gem + approve: + machine: true + steps: + - attach_workspace: + at: . + - persist_to_workspace: + root: . + paths: + - ./logdna-*.gem + publish: + docker: + - image: circleci/ruby:2.6.5 + steps: + - attach_workspace: + at: . + - run: gem push logdna-*.gem -k ${RUBYGEMS_API_KEY} +workflows: + update: + jobs: + - test: + filters: *tagged_build_filters + - build: + requires: + - test + filters: *tagged_build_filters + - release: + requires: + - build + filters: *tagged_build_filters + - approve: + type: approval + requires: + - release + filters: *tagged_build_filters + - publish: + requires: + - approve + filters: *tagged_build_filters + test: + jobs: + - test: + filters: *test_build_filters diff --git a/.rspec b/.rspec deleted file mode 100755 index 8c18f1a..0000000 --- a/.rspec +++ /dev/null @@ -1,2 +0,0 @@ ---format documentation ---color diff --git a/.rubocop.yml b/.rubocop.yml index 63b7ceb..bd8c31c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -56,11 +56,11 @@ Style/CollectionMethods: # inject seems more common in the community. reduce: "inject" -Style/UnneededInterpolation: - Enabled: flase +Style/RedundantInterpolation: + Enabled: false Style/RescueStandardError: - Enabled: flase + Enabled: false # Either allow this style or don't. Marking it as safe with parenthesis # is silly. Let's try to live without them for now. @@ -83,7 +83,7 @@ Style/SignalException: # Suppressing exceptions can be perfectly fine, and be it to avoid to # explicitly type nil into the rescue since that's what you want to return, # or suppressing LoadError for optional dependencies -Lint/HandleExceptions: +Lint/SuppressedException: Enabled: false # { ... } for multi-line blocks is okay, follow Weirichs rule instead: diff --git a/.ruby-version b/.ruby-version deleted file mode 100644 index 24ba9a3..0000000 --- a/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -2.7.0 diff --git a/LICENSE.txt b/LICENSE similarity index 89% rename from LICENSE.txt rename to LICENSE index 0f18fd1..37e8e3d 100755 --- a/LICENSE.txt +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2016 edwin-lai +Copyright (c) 2019 LogDNA Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Rakefile b/Rakefile deleted file mode 100755 index b7e9ed5..0000000 --- a/Rakefile +++ /dev/null @@ -1,6 +0,0 @@ -require "bundler/gem_tasks" -require "rspec/core/rake_task" - -RSpec::Core::RakeTask.new(:spec) - -task :default => :spec diff --git a/logdna.gemspec b/logdna.gemspec index 1769c6e..be05c27 100755 --- a/logdna.gemspec +++ b/logdna.gemspec @@ -6,26 +6,17 @@ require 'logdna/version' Gem::Specification.new do |spec| spec.name = 'logdna' spec.version = LogDNA::VERSION - spec.authors = 'Gun Woo Choi, Derek Zhou' + spec.authors = 'Gun Woo Choi, Derek Zhou, Vilya Levitskiy, Muaz Siddiqui' spec.email = 'support@logdna.com' - spec.summary = 'LogDNA Ruby logger' spec.homepage = 'https://github.com/logdna/ruby' spec.license = 'MIT' - - spec.files = `git ls-files -z`.split("\x0").reject do |f| - f.match(%r{^(test|spec|features)/}) - end + spec.files = Dir.glob("{lib}/**/*.rb") + %w(LICENSE README.md) spec.bindir = 'exe' spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ['lib'] - spec.add_runtime_dependency 'concurrent-ruby', '~> 1.0' spec.add_runtime_dependency 'require_all', '~> 1.4' spec.add_runtime_dependency 'json', '~> 2.0' - - spec.add_development_dependency 'bundler', '~> 1.13' - spec.add_development_dependency 'rake', '~> 10.5' - spec.add_development_dependency 'rspec', '~> 3.5' - spec.add_development_dependency 'webmock', '~> 2.3' + spec.add_development_dependency 'rubocop', '~> 0.78' end diff --git a/test.rb b/test.rb deleted file mode 100644 index b554d4b..0000000 --- a/test.rb +++ /dev/null @@ -1,56 +0,0 @@ -require 'require_all' -require_all 'lib' - -options = { hostname: "new_ruby", meta: { :once => { :first => "nested1", :another => "nested2" } } } - -logger1 = Logdna::Ruby.new('Your API Key', options) - -logger1.log('**************** This is the start of test ****************') -logger1.env = 'STAGING' -logger1.app = 'HELLO' -logger1.warn('Warn message with Staging and Hello') -logger1.clear -logger1.log('Is everything back to normal?') - -logger1.log('Testing env app name change using log') -logger1.env = 'PRODUCTION' -logger1.app = 'CHANGED' -logger1.log('This should be stage = PRODUCTION and appname = CHANGED') -logger1.log('Testing env app name change using other messages') - -logger1.error('This is error message with env = DEVELOPMENT and appname = NIHAO', { :env => 'DEVELOPMENT', :app => 'NIHAO' }) -logger1.log('Should not stay as DEVELOPMENT and NIHAO') -logger1.env = 'DEVELOPMENT' -logger1.app = 'NIHAO' -logger1.log('Now should be DEVELOPMENT and NIHAO') -logger1.log('Logging metadata in trace level', { :meta => { :once => { :first => "nested1", :another => "nested2" } }, :level => "TRACE" }) - -logger1.level = Logger::DEBUG -logger1.log('This is debug message') -logger1.add('this should not be supported') -logger1.fatal('Does this continue as fatal?') -logger1.log('This should be debug') -logger1.level = Logger::WARN -logger1.log('**************** This is the end of test ****************') - -=begin -logger1.level = Logger::WARN -logger1.log('This should be warn') -logger1.trace('This should be trace') -logger1.log('Again warn level') - -logger1.log('Warn level log1') -logger1.info('Info level log1') -logger1.level = Logger::DEBUG -logger1.log('DEBUG log1') - -logger1.app = 'NEW APP NAME' -logger1.env = 'Staging' -logger1.level = 'INFO' - -logger1.level = 'INFO' -logger1.level == Logger::INFO - -logger1.log('are changes all updated') -=end -sleep 3