Skip to content

Commit

Permalink
start azure pipelines testing
Browse files Browse the repository at this point in the history
  • Loading branch information
smurawski committed Jul 12, 2019
1 parent 7329f66 commit 0ebf8fd
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .kitchen.appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ driver:
host: localhost
reset_command: "exit 0"
port: 5985
username: <%= ENV["machine_user"] %>
password: <%= ENV["machine_pass"] %>
username: <%= ENV["MACHINE_USER"] %>
password: <%= ENV["MACHINE_PASS"] %>

provisioner:
name: shell
Expand Down
26 changes: 24 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,27 @@ source 'https://rubygems.org'
# Specify your gem's dependencies in kitchen-pester.gemspec
gemspec

gem 'kitchen-vagrant'
gem 'winrm-fs', '~> 1.0'
group :integration do
gem "berkshelf"
gem "kitchen-inspec"
gem "kitchen-dokken"
gem "kitchen-vagrant"
end

group :changelog do
gem "github_changelog_generator", "1.11.3"
end

group :debug do
gem "pry"
gem "pry-byebug"
gem "pry-stack_explorer"
end

group :chefstyle do
gem "chefstyle"
end

group :docs do
gem "yard"
end
64 changes: 40 additions & 24 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,60 @@ Rake::TestTask.new(:unit) do |t|
t.verbose = true
end


desc "Run all test suites"
task :test => [:unit]
task test: %i{unit}

desc "Display LOC stats"
task :stats do
puts "\n## Production Code Stats"
sh "countloc -r lib"
sh "countloc -r lib/kitchen lib/kitchen.rb"
puts "\n## Test Code Stats"
sh "countloc -r spec"
sh "countloc -r spec features"
end

require "finstyle"
require "rubocop/rake_task"
RuboCop::RakeTask.new(:style) do |task|
task.options << "--display-cop-names"
task.options << "--lint"
task.options << '--config' << '.rubocop.yml'
task.patterns = ['lib/**/*.rb']
begin
require "chefstyle"
require "rubocop/rake_task"
RuboCop::RakeTask.new(:style) do |task|
task.options += ["--display-cop-names", "--no-color"]
end
rescue LoadError
puts "chefstyle is not available. (sudo) gem install chefstyle to do style checking."
end

require "cane/rake_task"
desc "Run cane to check quality metrics"
Cane::RakeTask.new do |cane|
cane.canefile = "./.cane"
desc "Run all quality tasks"
task quality: %i{style stats}

begin
require "yard"
YARD::Rake::YardocTask.new
rescue LoadError
puts "yard is not available. (sudo) gem install yard to generate yard documentation."
end

desc "Run all quality tasks"
task :quality => [:cane, :style, :stats]
task default: %i{test quality}

require "yard"
YARD::Rake::YardocTask.new
begin
require "github_changelog_generator/task"
require "kitchen/version"

desc "Generate gem dependency graph"
task :viz do
Bundler.with_clean_env do
sh "bundle viz --without test development guard " \
"--requirements --version"
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
config.future_release = "v#{Kitchen::VERSION}"
config.enhancement_labels = "enhancement,Enhancement,New Feature,Feature,Improvement".split(",")
config.bug_labels = "bug,Bug".split(",")
config.exclude_labels = %w{Duplicate Question Discussion No_Changelog}
end
rescue LoadError
puts "github_changelog_generator is not available." \
" (sudo) gem install github_changelog_generator to generate changelogs"
end

task :default => [:test, :quality]
namespace :docs do
desc "Deploy docs"
task :deploy do
sh "cd docs && hugo"
sh "aws --profile chef-cd s3 sync docs/public s3://test-kitchen-legacy.cd.chef.co --delete --acl public-read"
sh "aws --profile chef-cd cloudfront create-invalidation --distribution-id EQD8MRW086SRT --paths '/*'"
end
end
82 changes: 82 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
trigger:
batch: true
branches:
include:
- master
- smurawski/azure-pipelines
pr:
autoCancel: true
branches:
include:
- master

stages:
- stage: Build
jobs:
- job: Validate
strategy:
matrix:
Windows_Ruby25:
version: 2.5.3
imageName: 'windows-2019'
task: windows_ci.bat
Windows_Ruby26:
version: 2.6.1
imageName: 'windows-2019'
task: windows_ci.bat
Windows_Integration:
version: 2.6.1
imageName: 'windows-2019'
task: windows_integration.bat
machine_user: test_user
machine_pass: Pass@word1
machine_port: 5985
KITCHEN_YAML: kitchen.appveyor.yml
pool:
vmImage: $(imageName)
steps:
- task: UseRubyVersion@0
inputs:
versionSpec: $(version)
addToPath: true
- script: |
echo "ruby version:"
ruby --version
echo "gem version:"
gem --version
displayName: Show Ruby Version
- script: |
gem install bundler --quiet
echo "bundler version:"
bundler --version
displayName: Install Bundler
- script: |
bundle install || bundle install || bundle install
displayName: Bundle Install Dependencies
- script: |
./support/ci/$(task)
displayName: Run Tests
env:
SPEC_OPTS: --format progress
- job: Package
dependsOn: Validate
condition: and(succeeded(), eq(variables['build.sourceBranch'], 'refs/heads/master'), notIn(variables['Build.Reason'], 'PullRequest'))
pool:
imageName: 'ubuntu-16.04'
steps:
- task: UseRubyVersion@0
inputs:
versionSpec: 2.6.2
addToPath: true
- script: |
gem install bundler --quiet
bundle install || bundle install || bundle install
bundle exec rake build
displayName: Package Gem
- task: PublishBuildArtifacts@1
displayName: "Publish Artifact: Release Build"
inputs:
PathtoPublish: ./pkg
ArtifactName: gem
ArtifactType: Container
1 change: 0 additions & 1 deletion kitchen-pester.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Gem::Specification.new do |spec|

spec.add_development_dependency "bundler"
spec.add_development_dependency "rake"
spec.add_development_dependency "pry"

spec.add_dependency "test-kitchen", ">= 1.10", "< 3"
end
1 change: 1 addition & 0 deletions support/ci/windows_ci.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bundle exec rake unit && bundle exec rake quality
5 changes: 5 additions & 0 deletions support/ci/windows_integration.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
winrm.cmd quickconfig -q
net user /add %machine_user% %machine_pass%
net localgroup administrators %machine_user% /add
bundle install --with integration
bundle exec kitchen verify windows

0 comments on commit 0ebf8fd

Please sign in to comment.