Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Add windows github action workflow #129

Merged
merged 9 commits into from
Nov 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
71 changes: 71 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
name: windows

"on":
pull_request:
push:
branches:
- master

jobs:
windows_agent:
runs-on: windows-latest
steps:
- name: Check out code
uses: actions/checkout@master
- name: Install Chef
uses: actionshub/chef-install@master
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
- name: Create directory
run: mkdir D:\a\berks-cookbooks\
- name: Create Link
run: cmd /c mklink /d D:\a\cookbooks\ D:\a\berks-cookbooks\
- name: Vendor Cookbooks
working-directory: D:\a\
run: berks vendor -b D:\a\sensu-go-chef\sensu-go-chef\Berksfile
- name: Chef Zero
working-directory: D:\a\cookbooks\sensu-go\
env:
CHEF_LICENSE: accept-no-persist
run: chef-client -z -o sensu_test::agent
- name: Verify
run: >
chef exec inspec
exec
D:\a\sensu-go-chef\sensu-go-chef\test\integration\agent\agent_spec.rb
env:
CHEF_LICENSE: accept-no-persist
windows_ctl:
runs-on: windows-latest
steps:
- name: Check out code
uses: actions/checkout@master
- name: Install Chef
uses: actionshub/chef-install@master
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
- name: Create directory
run: mkdir D:\a\berks-cookbooks\
- name: Create Link
run: cmd /c mklink /d D:\a\cookbooks\ D:\a\berks-cookbooks\
- name: Vendor Cookbooks
working-directory: D:\a\
run: berks vendor -b D:\a\sensu-go-chef\sensu-go-chef\Berksfile
- name: Chef Zero
working-directory: D:\a\cookbooks\sensu-go\
env:
CHEF_LICENSE: accept-no-persist
run: chef-client -z -o sensu_test::ctl
- name: GitHub Windows Path (Deprecated Add-Path)
run: >
echo "c:\Program Files\Sensu\sensu-cli\bin\sensuctl"
| Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
- name: Verify
run: >
chef exec inspec
exec D:\a\sensu-go-chef\sensu-go-chef\test\integration\ctl\ctl_spec.rb
env:
CHEF_LICENSE: accept-no-persist
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ This CHANGELOG follows the format located [here](https://github.com/sensu-plugin

## [Unreleased]

- Introduced CI/CD testing for windows for agent and ctl (@derekgroh)

## [1.3.0] - 2020-10-28

### Fixed
Expand Down
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ gem 'berkshelf'
gem 'chef-sugar'

group :development do
gem 'foodcritic'
gem 'chefspec'
gem 'cookstyle', '~> 4.0'
gem 'guard'
Expand Down
1 change: 0 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
require 'foodcritic'
require 'kitchen'
require 'chefspec'
require 'cookstyle'
Expand Down
48 changes: 0 additions & 48 deletions kitchen.appveyor.yml

This file was deleted.

17 changes: 13 additions & 4 deletions resources/ctl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,13 @@
destination sensuctl_bin
overwrite true
action :nothing
notifies :delete, 'directory[c:\sensutemp]'
end

windows_path sensuctl_bin

directory 'c:\sensutemp' do
action :delete
action :nothing
recursive true
end
end
Expand All @@ -93,9 +94,17 @@
action :configure do
if shell_out('sensuctl user list').error?
converge_by 'Reconfiguring sensuctl' do
execute 'configure sensuctl' do
command sensuctl_configure_cmd
sensitive true unless new_resource.debug
unless platform?('windows')
execute 'configure sensuctl' do
command sensuctl_configure_cmd
sensitive true unless new_resource.debug
end
end
if platform?('windows')
powershell_script 'configure sensuctl' do
code sensuctl_configure_cmd
sensitive true unless new_resource.debug
end
end
end
end
Expand Down
4 changes: 3 additions & 1 deletion spec/unit/recipes/sensu_ctl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@

it 'does nothing for an archive' do
expect(chef_run).to nothing_archive_file('Extract Sensuctl')
archive_file_resource = chef_run.archive_file('Extract Sensuctl')
expect(archive_file_resource).to notify('directory[c:\sensutemp]')
end

it 'notifies to extract the archive' do
Expand All @@ -90,7 +92,7 @@
end

it 'deletes the temporary directory `c:\sensutemp`' do
expect(chef_run).to delete_directory('c:\sensutemp')
expect(chef_run).to nothing_directory('c:\sensutemp')
end

it 'configures the sensu cli' do
Expand Down
4 changes: 3 additions & 1 deletion test/cookbooks/sensu_test/recipes/agent.rb
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
sensu_agent 'default'
sensu_agent 'default' do
ignore_failure true
end
4 changes: 3 additions & 1 deletion test/cookbooks/sensu_test/recipes/ctl.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
sensu_ctl 'default' do
action [:install, :configure]
backend_url 'http://172.128.10.2:8080'
username 'guest'
password 'i<3sensu'
backend_url 'https://caviar.tf.sensu.io:8080/'
end
13 changes: 9 additions & 4 deletions test/integration/ctl/ctl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
describe package('sensu-go-cli') do
it { should be_installed }
end

describe command('sensuctl user list') do
its('stdout') { should match /Username/ }
its('exit_status') { should eq 0 }
end
end

if os.windows?
Expand All @@ -33,9 +38,9 @@
describe file('c:\Program Files\Sensu\sensu-cli\bin\sensuctl\sensuctl.exe') do
it { should exist }
end
end

describe command('sensuctl user list') do
its('stdout') { should match /Username/ }
its('exit_status') { should eq 0 }
describe command('sensuctl entity list') do
its('stdout') { should match /backend/ }
its('exit_status') { should eq 0 }
end
end