Skip to content

Commit

Permalink
Merge pull request #56 from chef/bk_fixes
Browse files Browse the repository at this point in the history
Add windows testing in Buildkite
  • Loading branch information
tas50 authored Aug 7, 2019
2 parents 51dcee2 + 76b305a commit c775671
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 80 deletions.
3 changes: 3 additions & 0 deletions .expeditor/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Documentation available at https://expeditor.chef.io/docs/getting-started/
---

# Slack channel in Chef Software slack to send notifications about build failures, etc
slack:
notify_channel: chef-found-notify
Expand All @@ -11,6 +12,8 @@ rubygems:
github:
# This deletes the GitHub PR branch after successfully merged into the release branch
delete_branch_on_merge: true
# The tag format to use (e.g. v1.0.0)
version_tag_format: "v{{version}}"
# allow bumping the minor release via label
minor_bump_labels:
- "Expeditor: Bump Version Minor"
Expand Down
28 changes: 22 additions & 6 deletions .expeditor/verify.pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,44 @@
---
expeditor:
defaults:
buildkite:
timeout_in_minutes: 30

steps:

- label: run-lint-and-specs-ruby-2.4
command:
- asdf local ruby 2.4.5
- bundle install --jobs=7 --retry=3
- bundle install --jobs=7 --retry=3 --without docs debug
- bundle exec rake
expeditor:
executor:
docker:
image: ruby:2.4-stretch

- label: run-lint-and-specs-ruby-2.5
command:
- asdf local ruby 2.5.5
- bundle install --jobs=7 --retry=3
- bundle install --jobs=7 --retry=3 --without docs debug
- bundle exec rake
expeditor:
executor:
docker:
image: ruby:2.5-stretch

- label: run-lint-and-specs-ruby-2.6
command:
- asdf local ruby 2.6.3
- bundle install --jobs=7 --retry=3
- bundle install --jobs=7 --retry=3 --without docs debug
- bundle exec rake
expeditor:
executor:
docker:
image: ruby:2.6-stretch

- label: run-specs-windows
command:
- bundle install --jobs=7 --retry=3 --without docs debug
- bundle env
- bundle exec rake
expeditor:
executor:
docker:
host_os: windows
10 changes: 5 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ source "https://rubygems.org"
gemspec

group :docs do
gem "yard"
gem "redcarpet"
gem "github-markup"
gem "redcarpet"
gem "yard"
end

group :test do
gem "chefstyle", git: "https://github.com/chef/chefstyle.git", branch: "master"
gem "rspec", "~> 3.7"
gem "chefstyle"
gem "cucumber"
gem "rake"
gem "rspec", "~> 3.7"
end

group :development do
group :debug do
gem "pry"
gem "pry-byebug"
gem "pry-stack_explorer"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Mixlib::Log

[![Gem Version](https://badge.fury.io/rb/mixlib-log.svg)](https://badge.fury.io/rb/mixlib-log)
[![Build status](https://badge.buildkite.com/cb1e5b6f3cc77071f4b2315f6b605fe60d86e2862a490873d4.svg?branch=master)](https://buildkite.com/chef-oss/chef-mixlib-log-master-verify)

**Umbrella Project**: [Chef Foundation](https://github.com/chef/chef-oss-practices/blob/master/projects/chef-foundation.md)

Expand Down
39 changes: 27 additions & 12 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,41 @@
require "bundler/gem_tasks"
require "rspec/core/rake_task"
require "cucumber/rake/task"
require "bundler"

task default: [:style, :spec, :features]

Bundler::GemHelper.install_tasks
begin
require "cucumber/rake/task"

desc "Run specs"
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = "spec/**/*_spec.rb"
Cucumber::Rake::Task.new(:features) do |t|
t.cucumber_opts = "--format pretty"
t.bundler = false
end
rescue LoadError
desc "cucumber is not installed, this task is disabled"
task :spec do
abort "cucumber is not installed. bundle install first to make sure all dependencies are installed."
end
end

Cucumber::Rake::Task.new(:features) do |t|
t.cucumber_opts = "--format pretty"
begin
require "rspec/core/rake_task"

RSpec::Core::RakeTask.new do |t|
t.pattern = "spec/**/*_spec.rb"
end
rescue LoadError
desc "rspec is not installed, this task is disabled"
task :spec do
abort "rspec is not installed. bundle install first to make sure all dependencies are installed."
end
end

begin
require "chefstyle"
require "rubocop/rake_task"
desc "Run Chefstyle tests"
RuboCop::RakeTask.new(:style) do |task|
task.options += ["--display-cop-names", "--no-color"]
end
rescue LoadError
puts "chefstyle/rubocop is not available. bundle install first to make sure all dependencies are installed."
puts "chefstyle gem is not installed. bundle install first to make sure all dependencies are installed."
end

begin
Expand All @@ -39,3 +52,5 @@ task :console do
ARGV.clear
IRB.start
end

task default: %i{style spec features}
43 changes: 0 additions & 43 deletions appveyor.yml

This file was deleted.

10 changes: 6 additions & 4 deletions lib/mixlib/log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def use_log_devices(other)
if other.respond_to?(:loggers) && other.respond_to?(:logger)
@loggers = other.loggers
@logger = other.logger
elsif other.kind_of?(Array)
elsif other.is_a?(Array)
@loggers = other
@logger = other.first
else
Expand All @@ -82,7 +82,7 @@ def use_log_devices(other)
def init(*opts)
reset!
@logger = logger_for(*opts)
@logger.formatter = Mixlib::Log::Formatter.new() if @logger.respond_to?(:formatter=)
@logger.formatter = Mixlib::Log::Formatter.new if @logger.respond_to?(:formatter=)
@logger.level = Logger::WARN
@configured = true
@parent = nil
Expand Down Expand Up @@ -110,6 +110,7 @@ def configured?
def level=(new_level)
level_int = LEVEL_NAMES.key?(new_level) ? new_level : LEVELS[new_level]
raise ArgumentError, "Log level must be one of :trace, :debug, :info, :warn, :error, or :fatal" if level_int.nil?

loggers.each { |l| l.level = level_int }
end

Expand All @@ -125,7 +126,7 @@ def level(new_level = nil)
# Note that we *only* query the default logger (@logger) and not any other
# loggers that may have been added, even though it is possible to configure
# two (or more) loggers at different log levels.
[:trace?, :debug?, :info?, :warn?, :error?, :fatal?].each do |method_name|
%i{trace? debug? info? warn? error? fatal?}.each do |method_name|
define_method(method_name) do
logger.send(method_name)
end
Expand All @@ -137,7 +138,7 @@ def <<(msg)

def add(severity, message = nil, progname = nil, data: {}, &block)
message, progname, data = yield if block_given?
data = metadata.merge(data) if metadata.kind_of?(Hash) && data.kind_of?(Hash)
data = metadata.merge(data) if metadata.is_a?(Hash) && data.is_a?(Hash)
loggers.each do |l|
# if we don't have any metadata, let's not do the potentially expensive
# merging and managing that this call requires
Expand Down Expand Up @@ -193,6 +194,7 @@ def loggers_to_close
# to get access to it.
next unless logger.instance_variable_defined?(:"@logdev")
next unless (logdev = logger.instance_variable_get(:"@logdev"))

loggers_to_close << logger if logdev.filename
end
loggers_to_close
Expand Down
4 changes: 2 additions & 2 deletions lib/mixlib/log/child.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ def level
# Note that we *only* query the default logger (@logger) and not any other
# loggers that may have been added, even though it is possible to configure
# two (or more) loggers at different log levels.
[:trace?, :debug?, :info?, :warn?, :error?, :fatal?].each do |method_name|
%i{trace? debug? info? warn? error? fatal?}.each do |method_name|
define_method(method_name) do
parent.send(method_name)
end
end

def add(severity, message = nil, progname = nil, data: {}, &block)
data = metadata.merge(data) if data.kind_of?(Hash)
data = metadata.merge(data) if data.is_a?(Hash)
parent.send(:pass, severity, message, progname, data: data, &block)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/mixlib/log/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def self.show_time=(show = false)
# Otherwise, doesn't print the time.
def call(severity, time, progname, msg)
if @@show_time
sprintf("[%s] %s: %s\n", time.iso8601(), severity, msg2str(msg))
sprintf("[%s] %s: %s\n", time.iso8601, severity, msg2str(msg))
else
sprintf("%s: %s\n", severity, msg2str(msg))
end
Expand Down
6 changes: 4 additions & 2 deletions lib/mixlib/log/logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@ def initialize(logdev)

def add_data(severity, message, progname, data: {})
return true if @logdev.nil? || severity < @level

data ||= {}
if message.kind_of?(::Exception)
if message.is_a?(::Exception)
data[:err] = message
else
data[:msg] = message
end
@logdev.write(
format_message(to_label(severity), Time.now, progname, data))
format_message(to_label(severity), Time.now, progname, data)
)
true
end
alias_method :add, :add_data
Expand Down
2 changes: 1 addition & 1 deletion lib/mixlib/log/logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def pass(severity, args, progname = nil, data: {}, &block)

# Define the standard logger methods on this class programmatically.
# No need to incur method_missing overhead on every log call.
[:trace, :debug, :info, :warn, :error, :fatal].each do |method_name|
%i{trace debug info warn error fatal}.each do |method_name|
level = LEVELS[method_name]
define_method(method_name) do |msg = nil, data: {}, &block|
pass(level, msg, data: data, &block)
Expand Down
2 changes: 1 addition & 1 deletion spec/mixlib/log_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def add(severity, message = nil, progname = nil, data: {})
@messages << message
end

[:trace, :debug, :info, :warn, :error, :fatal].each do |method_name|
%i{trace debug info warn error fatal}.each do |method_name|
class_eval(<<-E)
def #{method_name}(message)
@messages << message
Expand Down
4 changes: 1 addition & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
require "mixlib/log"
require "mixlib/log/formatter"

RSpec.configure do |config|
config.disable_monkey_patching!
end
RSpec.configure(&:disable_monkey_patching!)

class Logit
extend Mixlib::Log
Expand Down

0 comments on commit c775671

Please sign in to comment.