Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
2256e96
init verify pipeline
rishichawda Jun 5, 2025
2f951c9
update gitignore to include vendor and .bundle
rishichawda Jun 6, 2025
f61cb08
fix cookstyle errors
rishichawda Jun 6, 2025
4faef43
fix undefined method `map` for WIN32OLE error
rishichawda Jun 6, 2025
3bff3ec
set privileged to true
rishichawda Jun 10, 2025
df9aa77
use a different image
rishichawda Jun 10, 2025
24fe84e
install ruby
rishichawda Jun 10, 2025
9208ceb
fix tests
rishichawda Jun 11, 2025
dba89a2
set install mode for newer installers
rishichawda Jun 12, 2025
ddd7da7
cookstyle update
rishichawda Jun 12, 2025
e6707b5
fix cspell errors
rishichawda Jun 12, 2025
bfe277e
test with rubydistors images
muthuja Jun 16, 2025
40a0774
test with rubydistors images
muthuja Jun 16, 2025
e9ca4bc
test with rubydistors images
muthuja Jun 16, 2025
743aed7
test with rubydistors images
muthuja Jun 16, 2025
b97ff2d
test with rubydistors images
muthuja Jun 16, 2025
a6986b3
test with rubydistors images
muthuja Jun 16, 2025
95f6b0f
test with rubydistors images
muthuja Jun 16, 2025
4c97ddd
test with rubydistors images
muthuja Jun 16, 2025
93dae5d
change spec helper file
muthuja Jun 16, 2025
8eb7e90
change spec helper file
muthuja Jun 16, 2025
4bf5328
change spec helper file
muthuja Jun 16, 2025
4ec1ddc
change spec helper file
muthuja Jun 16, 2025
a30e194
change spec helper file
muthuja Jun 16, 2025
3b0d0d2
change spec helper file
muthuja Jun 16, 2025
336db3a
change spec helper file
muthuja Jun 16, 2025
f6612eb
change spec helper file
muthuja Jun 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .expeditor/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
---
# Slack channel in Chef Software slack to send notifications about build failures, etc
slack:
notify_channel: sustaining-notify
notify_channel: chef-notify

notify_channel:
- sustaining-notify
- chef-notify
# This publish is triggered by the `built_in:publish_rubygems` artifact_action.
rubygems:
- win32-taskscheduler
Expand Down
18 changes: 18 additions & 0 deletions .expeditor/scripts/install_ruby.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
param(
[Parameter(Mandatory = $true)]
[string]$RubyVersion
)

$ErrorActionPreference = "Stop"

Write-Output "--- Downloading and installing Ruby"
$installerUrl = "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-$RubyVersion-1/rubyinstaller-devkit-$RubyVersion-1-x64.exe"
$installerPath = "$env:TEMP\rubyinstaller.exe"

Write-Output "Downloading Ruby $RubyVersion from $installerUrl"
Invoke-WebRequest -Uri $installerUrl -OutFile $installerPath
if (-not $?) { throw "Could not download ruby with devkit from https://github.com/oneclick/rubyinstaller2" }

Write-Output "Running Ruby installer..."
Start-Process -FilePath $installerPath -ArgumentList "/verysilent","/tasks=modpath", "/currentuser" -Wait
if (-not $?) { throw "Failed to install Ruby." }
31 changes: 31 additions & 0 deletions .expeditor/scripts/run_windows_tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Stop script execution when a non-terminating error occurs
$ErrorActionPreference = "Stop"

# Find the latest Ruby install directory
$RubyDir = Get-ChildItem -Directory "C:\Ruby*" | Sort-Object LastWriteTime -Descending | Select-Object -First 1
if ($RubyDir) {
$RubyBin = "$($RubyDir.FullName)\bin"
Write-Output "Ruby installed at $RubyBin"
} else {
throw "Could not find Ruby installation directory."
}
$env:PATH = "$env:PATH;$RubyBin"

Write-Output "--- Installed Ruby version"
ruby --version

Write-Output "--- Bundle install"

bundle config --local path vendor/bundle
bundle install --jobs=7 --retry=3
if (-not $?) { throw "bundle install failed" }

Write-Output "--- Running Cookstyle"
gem install cookstyle
cookstyle --chefstyle -c .rubocop.yml
if (-not $?) { throw "Cookstyle failed." }

Write-Output "--- Bundle Execute"

bundle exec rake
if (-not $?) { throw "Rake task failed." }
36 changes: 36 additions & 0 deletions .expeditor/verify.pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
expeditor:
defaults:
buildkite:
retry:
automatic:
limit: 1
timeout_in_minutes: 90

steps:
- label: run-specs-ruby-3.1
command:
#- .expeditor/scripts/install_ruby.ps1 -RubyVersion "3.1.6"
- .expeditor/scripts/run_windows_tests.ps1
expeditor:
executor:
docker:
host_os: windows
shell: [ "powershell", "-Command" ]
image: rubydistros/windows-2019:3.1
environment:
- BUILDKITE


- label: run-specs-ruby-3.4
command:
#- .expeditor/scripts/install_ruby.ps1 -RubyVersion "3.4.3"
- .expeditor/scripts/run_windows_tests.ps1
expeditor:
executor:
docker:
host_os: windows
shell: [ "powershell", "-Command" ]
image: rubydistros/windows-2019:3.4
environment:
- BUILDKITE
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
Gemfile.lock
vendor
.bundle
5 changes: 4 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ source "https://rubygems.org"
gemspec

group :development do
gem "chefstyle"
gem "rake"
gem "rspec", "~> 3.0"
end
Expand All @@ -12,6 +11,10 @@ group :ci do
gem "rspec_junit_formatter"
end

group :style do
gem "cookstyle", "~> 8.1"
end

group :docs do
gem "github-markup"
gem "redcarpet"
Expand Down
21 changes: 10 additions & 11 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ task :example do
ruby "-Iib examples/taskscheduler_example.rb"
end

desc "Check the code for linting/styling errors"
task :style do
require "rubocop/rake_task"

system("bundle exec cookstyle --chefstyle -c .rubocop.yml")
rescue LoadError => e
puts "rubocop/cookstyle gem is not installed. Run `bundle install` first to make sure all dependencies are installed."
puts e.message
end

begin
require "rspec/core/rake_task"

Expand All @@ -38,17 +48,6 @@ rescue LoadError
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 gem is not installed. bundle install first to make sure all dependencies are installed."
end

begin
require "yard"
YARD::Rake::YardocTask.new(:docs)
Expand Down
2 changes: 2 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -1348,6 +1348,7 @@
"TERMSRV",
"testswapfile",
"testswapfiledir",
"testtask",
"texteditor",
"THRDS",
"THREADID",
Expand Down Expand Up @@ -1532,6 +1533,7 @@
"XEEDS",
"XFORM",
"XMLHTTP",
"Yardoc",
"yieldparam",
"zabbix",
"zanetti",
Expand Down
2 changes: 1 addition & 1 deletion lib/win32/taskscheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def enum

array = []

taskCollection.each do |registeredTask|
taskCollection.each do |registeredTask| # rubocop:disable Style/MapIntoArray
array << registeredTask.Name
end

Expand Down
2 changes: 1 addition & 1 deletion lib/win32/taskscheduler/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module Helper
ffi_lib :kernel32, :advapi32

attach_function :FormatMessage, :FormatMessageA,
%i{ulong pointer ulong ulong pointer ulong pointer}, :ulong
%i{ulong pointer ulong ulong pointer ulong pointer}, :ulong

attach_function :ConvertStringSidToSidW, %i{pointer pointer}, :bool
attach_function :LookupAccountSidW, %i{pointer pointer pointer pointer pointer pointer pointer}, :bool
Expand Down
4 changes: 3 additions & 1 deletion lib/win32/taskscheduler/time_calc_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ def extra_days(days_count, month_count, year_count, init_month, init_year)
# time_details("PT3S") #=> {sec: 3}
#
def time_details(time_str)
raise TypeError unless time_str.is_a?(String) || time_str.nil?

tm_detail = {}
if time_str.to_s != ""
# time_str will be like "PxxYxxMxxDTxxHxxMxxS"
Expand Down Expand Up @@ -157,7 +159,7 @@ def time_details(time_str)
# dt_tm_string_to_hash("10year3month", {}) #=> {:year=>"10", :month=>"3"}
#
def dt_tm_string_to_hash(str, tm_detail)
str.split(/(\d+)/)[1..-1].each_slice(2).each_with_object(tm_detail) { |i, h| h[i.last.to_sym] = i.first; }
str.split(/(\d+)/)[1..-1].each_slice(2).with_object(tm_detail) { |i, h| h[i.last.to_sym] = i.first }
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/functional/win32/taskscheduler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
expect(no_of_tasks).to eq(0)
end

it "Raises error when path separators(\\\) are absent" do
it "Raises error when path separators(\\) are absent" do
invalid_path = "Foo"
expect { ts.new(@task, @trigger, invalid_path) }.to raise_error(ArgumentError)
expect(no_of_tasks).to eq(0)
Expand Down Expand Up @@ -670,7 +670,7 @@

describe "#trigger_string" do
before { create_task }
it "Returns a string that describes the current trigger at "\
it "Returns a string that describes the current trigger at " \
"the specified index for the active task" do
expect(@ts.trigger_string(0)).to be_a(String)
end
Expand Down Expand Up @@ -842,7 +842,7 @@
describe "#trigger" do
before { create_task }

it "Returns a hash that describes the trigger "\
it "Returns a hash that describes the trigger " \
"at the given index for the current task" do
trigger = @ts.trigger(0)
expect(trigger).to be_a(Hash)
Expand Down
1 change: 0 additions & 1 deletion win32-taskscheduler.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Gem::Specification.new do |spec|
spec.email = "djberg96@gmail.com"
spec.homepage = "https://github.com/chef/win32-taskscheduler"
spec.summary = "A library for the Windows task scheduler"
spec.test_files = Dir["test/*, spec/**/*"]
spec.files = Dir["lib/**/*"]

spec.add_dependency("ffi")
Expand Down