From 39117f0e4574f56e4d8d692841f9c13f3aba18e3 Mon Sep 17 00:00:00 2001 From: Derek Groh Date: Mon, 30 Nov 2020 09:55:47 -0600 Subject: [PATCH 1/5] Update Add windows github action workflow (#129) * archive_file notifies delete directory * favor Powershell for sensuctl configure powershell is able to access path variables without additional configuration powershell_script - use code * test recipes changes for Github * cookstyle fixes v7.2.1 * adjust spec to match recipe * github action - windows * delete kitchen.appveyor.yml * split sensuctl test by platform * update changelog --- .github/workflows/windows.yml | 71 ++++++++++++++++++++++ CHANGELOG.md | 2 + Gemfile | 1 - Rakefile | 1 - kitchen.appveyor.yml | 48 --------------- resources/ctl.rb | 17 ++++-- spec/unit/recipes/sensu_ctl_spec.rb | 4 +- test/cookbooks/sensu_test/recipes/agent.rb | 4 +- test/cookbooks/sensu_test/recipes/ctl.rb | 4 +- test/integration/ctl/ctl_spec.rb | 13 ++-- 10 files changed, 104 insertions(+), 61 deletions(-) create mode 100644 .github/workflows/windows.yml delete mode 100644 kitchen.appveyor.yml diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 00000000..bd8cc70b --- /dev/null +++ b/.github/workflows/windows.yml @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cb843b1..b827fb7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/Gemfile b/Gemfile index b5db1163..3a2b96f4 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,6 @@ gem 'berkshelf' gem 'chef-sugar' group :development do - gem 'foodcritic' gem 'chefspec' gem 'cookstyle', '~> 4.0' gem 'guard' diff --git a/Rakefile b/Rakefile index ad2934f3..b4a3a7e3 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,5 @@ require 'rspec/core/rake_task' require 'rubocop/rake_task' -require 'foodcritic' require 'kitchen' require 'chefspec' require 'cookstyle' diff --git a/kitchen.appveyor.yml b/kitchen.appveyor.yml deleted file mode 100644 index b666035f..00000000 --- a/kitchen.appveyor.yml +++ /dev/null @@ -1,48 +0,0 @@ ---- -driver: - name: proxy - host: localhost - reset_command: "exit 0" - port: 5985 - username: <%= ENV["machine_user"] %> - password: <%= ENV["machine_pass"] %> - -provisioner: - name: chef_zero - client_rb: - chef_license: accept - -platforms: - - name: windows-2012r2 - driver: - box: tas50/windows_2012r2 - - name: windows-2016 - driver: - box: tas50/windows_2016 - customize: - memory: 3072 - - name: windows-2019 - driver: - box: tas50/windows_2016 - customize: - memory: 3072 - -verifier: - name: inspec - -suites: - - name: agent - run_list: - - recipe[sensu_test::agent] - verifier: - inspec_tests: - - test/integration/agent - attributes: -# - name: remove -# run_list: -# - recipe[sensu_test::agent] -# - recipe[sensu_test::remove_agent] -# verifier: -# inspec_tests: -# - test/integration/remove_agent -# attributes: diff --git a/resources/ctl.rb b/resources/ctl.rb index 2e527cfd..4285f3d8 100644 --- a/resources/ctl.rb +++ b/resources/ctl.rb @@ -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 @@ -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 diff --git a/spec/unit/recipes/sensu_ctl_spec.rb b/spec/unit/recipes/sensu_ctl_spec.rb index fabc0748..1ee00356 100644 --- a/spec/unit/recipes/sensu_ctl_spec.rb +++ b/spec/unit/recipes/sensu_ctl_spec.rb @@ -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 @@ -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 diff --git a/test/cookbooks/sensu_test/recipes/agent.rb b/test/cookbooks/sensu_test/recipes/agent.rb index 0d7a2ef9..c65355b9 100644 --- a/test/cookbooks/sensu_test/recipes/agent.rb +++ b/test/cookbooks/sensu_test/recipes/agent.rb @@ -1 +1,3 @@ -sensu_agent 'default' +sensu_agent 'default' do + ignore_failure true +end diff --git a/test/cookbooks/sensu_test/recipes/ctl.rb b/test/cookbooks/sensu_test/recipes/ctl.rb index f977171b..5147581e 100644 --- a/test/cookbooks/sensu_test/recipes/ctl.rb +++ b/test/cookbooks/sensu_test/recipes/ctl.rb @@ -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 diff --git a/test/integration/ctl/ctl_spec.rb b/test/integration/ctl/ctl_spec.rb index 6a84fefb..646bf1fd 100644 --- a/test/integration/ctl/ctl_spec.rb +++ b/test/integration/ctl/ctl_spec.rb @@ -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? @@ -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 From 9b370d961f9657683ba819dd8d02f942a7cc93fb Mon Sep 17 00:00:00 2001 From: Derek Groh Date: Mon, 30 Nov 2020 09:40:32 -0600 Subject: [PATCH 2/5] draft maintainers section --- CONTRIBUTING.md | 62 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 7 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1c3af598..e4a0ea09 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,17 +1,65 @@ -Contributing -============ +# Contributing -TODO: Fill out your contributing process, or just stick with the default. - -Steps ------ +## Steps Thanks for your interest in sensu-go cookbook! If you'd like to help out please: 1. Fork it 1. Create your feature branch (`git checkout -b my-new-feature`) -1. Add tests for the new feature; ensure they pass (`rake`) +1. Add tests for the new feature; ensure they pass See [TESTING.md](./TESTING.md) 1. Add a changelog entry under `## [Unreleased]` and the appropriate sub header for the type of change per our [guidelines](https://github.com/sensu-plugins/community/blob/master/HOW_WE_CHANGELOG.md) 1. Commit your changes (`git commit -am 'Add some feature'`) 1. Push to the branch (`git push origin my-new-feature`) 1. Create a new Pull Request + +## How to Become a Maintainer + +### Types of Maintainers + +#### SME (Subject Matter Expert) + +##### Pre Conditions + +To become an SME maintainer you must meet one of the following conditions: + +1. Has made significant contributions to a particular repo +2. Has specific area knowledge related to the content. + +The following is required: + +1. Have MFA (Multi Factor Authentication) enabled on your Github account + +##### Process + +1. Open an [issue](https://github.com/sensu/sensu-go-chef/issues/new) indicating that you would like to become a maintainer and your subject matter expertise. + +#### Maintainer + +Most maintainers are targetted at maintainting a specific set of repositiories based on language, function (plugin vs extension), Documentation, etc + +##### Pre Conditions + +1. Shown consistent and quality contributions to multiple repositories in the Sensu ecosystem. +1. MFA enabled on your Github account +1. Have setup PGP with github so you can sign commits to guarantee that your commits are your own + +##### Process + +1. Open an [issue](https://github.com/sensu/sensu-go-chef/issues/new) indicating that you would like to become a maintainer +1. Endorsed by two or more active maintainers with no vetos against them +1. Have acknowledged that they have read and will abide by the terms outlined in the [Code of Conduct](https://sensu.io/conduct) +1. Will be invited to the organization, teams, slack channels, etc as outlined via internal maintainer processes. + +#### Org Maintainer + +An org maintainer is not scoped to specific projects (even if they mostly focus on an area), they provide OSS mentorship to other maintainers, manage permissions + credentials, set organization wide policies, etc. + +##### Pre conditions + +1. Meet all conditions of being a maintainer +1. Kick ass on a regular basis +1. Be endorsed by two current Org Maintainers + +##### Process + +1. This is really an internal process, once becoming a maintainer reach out to an existing org maintainer to start informal internal discussions. From 005b99e547ae13e385e9abf916d80205b2180b2b Mon Sep 17 00:00:00 2001 From: Derek Groh Date: Mon, 30 Nov 2020 09:45:39 -0600 Subject: [PATCH 3/5] maintainers process --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b827fb7a..621d8db2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ This CHANGELOG follows the format located [here](https://github.com/sensu-plugin ## [Unreleased] +- Updated Contributing to document maintainers processes (@derekgroh) - Introduced CI/CD testing for windows for agent and ctl (@derekgroh) ## [1.3.0] - 2020-10-28 From 0fa93de1de32a7afcf70c998818fce940d559184 Mon Sep 17 00:00:00 2001 From: Derek Groh Date: Tue, 1 Dec 2020 09:32:42 -0600 Subject: [PATCH 4/5] refactor maintainer process --- CONTRIBUTING.md | 44 ++++---------------------------------------- 1 file changed, 4 insertions(+), 40 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e4a0ea09..47cfdde4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,54 +12,18 @@ Thanks for your interest in sensu-go cookbook! If you'd like to help out please: 1. Push to the branch (`git push origin my-new-feature`) 1. Create a new Pull Request -## How to Become a Maintainer +## Maintainer -### Types of Maintainers +Maintainers are GitHub Members who help review Pull Request and help organize and triage issues. -#### SME (Subject Matter Expert) - -##### Pre Conditions - -To become an SME maintainer you must meet one of the following conditions: - -1. Has made significant contributions to a particular repo -2. Has specific area knowledge related to the content. - -The following is required: - -1. Have MFA (Multi Factor Authentication) enabled on your Github account - -##### Process - -1. Open an [issue](https://github.com/sensu/sensu-go-chef/issues/new) indicating that you would like to become a maintainer and your subject matter expertise. - -#### Maintainer - -Most maintainers are targetted at maintainting a specific set of repositiories based on language, function (plugin vs extension), Documentation, etc - -##### Pre Conditions +### Pre Conditions 1. Shown consistent and quality contributions to multiple repositories in the Sensu ecosystem. 1. MFA enabled on your Github account -1. Have setup PGP with github so you can sign commits to guarantee that your commits are your own -##### Process +### Process 1. Open an [issue](https://github.com/sensu/sensu-go-chef/issues/new) indicating that you would like to become a maintainer 1. Endorsed by two or more active maintainers with no vetos against them 1. Have acknowledged that they have read and will abide by the terms outlined in the [Code of Conduct](https://sensu.io/conduct) 1. Will be invited to the organization, teams, slack channels, etc as outlined via internal maintainer processes. - -#### Org Maintainer - -An org maintainer is not scoped to specific projects (even if they mostly focus on an area), they provide OSS mentorship to other maintainers, manage permissions + credentials, set organization wide policies, etc. - -##### Pre conditions - -1. Meet all conditions of being a maintainer -1. Kick ass on a regular basis -1. Be endorsed by two current Org Maintainers - -##### Process - -1. This is really an internal process, once becoming a maintainer reach out to an existing org maintainer to start informal internal discussions. From 33281efa106df13046f10ddaba26ec9d80a81364 Mon Sep 17 00:00:00 2001 From: Derek Groh Date: Wed, 2 Dec 2020 18:09:29 -0600 Subject: [PATCH 5/5] Update CONTRIBUTING.md Co-authored-by: Ben Abrams --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 47cfdde4..aa13345e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,7 +18,7 @@ Maintainers are GitHub Members who help review Pull Request and help organize an ### Pre Conditions -1. Shown consistent and quality contributions to multiple repositories in the Sensu ecosystem. +1. Shown consistent and quality contributions to this repository as well as active engagement in the Sensu ecosystem. 1. MFA enabled on your Github account ### Process