diff --git a/.kitchen.yml b/.kitchen.yml deleted file mode 100644 index 0d4744d..0000000 --- a/.kitchen.yml +++ /dev/null @@ -1,23 +0,0 @@ -driver: - name: ec2 - -provisioner: - name: chef_zero - -platforms: - - name: windows-2012r2sp1 - driver: - instance_type: t2.medium - image_search: - name: "Windows_Server-2012-R2_RTM-English-64Bit-Base-*" - -verifier: - name: inspec - -suites: - - name: test - run_list: - - recipe[test::latest] - - name: test - run_list: - - recipe[test::specified_version] diff --git a/Berksfile b/Berksfile index 2c91ddf..cd6d06d 100644 --- a/Berksfile +++ b/Berksfile @@ -1,5 +1,5 @@ source 'https://supermarket.chef.io' -cookbook 'test', path: 'test/fixtures/cookbooks/test' +cookbook 'test', path: 'test/cookbooks/test' metadata diff --git a/CHANGELOG.md b/CHANGELOG.md index f41622e..8ac4940 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,10 +7,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [0.2.11](https://github.com/sous-chefs/appveyor-ci/compare/0.2.10...v0.2.11) (2025-10-14) - ### Bug Fixes -* **ci:** Update release workflow ([#71](https://github.com/sous-chefs/appveyor-ci/issues/71)) ([660220a](https://github.com/sous-chefs/appveyor-ci/commit/660220afd12867b079ac635db7b770888af3d0e9)) +- **ci:** Update release workflow ([#71](https://github.com/sous-chefs/appveyor-ci/issues/71)) ([660220a](https://github.com/sous-chefs/appveyor-ci/commit/660220afd12867b079ac635db7b770888af3d0e9)) ## 0.2.10 - *2025-09-04* diff --git a/LIMITATIONS.md b/LIMITATIONS.md new file mode 100644 index 0000000..fdb47d7 --- /dev/null +++ b/LIMITATIONS.md @@ -0,0 +1,5 @@ +# AppVeyor Deployment Agent Limitations + +- The AppVeyor deployment agent is Windows-only; this cookbook should only advertise and test Windows support. +- Installation depends on the public MSI download endpoint at `https://www.appveyor.com/downloads/deployment-agent//AppveyorDeploymentAgent.msi`. +- The resource expects an AppVeyor deployment access key and deployment group at converge time. diff --git a/appveyor.yml b/appveyor.yml index 085447f..23e9213 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,7 +11,7 @@ environment: user_password: Pass@word1 matrix: - - ruby_version: "23" + - ruby_version: "23" clone_folder: c:\GitHub\chef-appveyor-ci clone_depth: 1 diff --git a/documentation/appveyor-ci_appveyor_agent.md b/documentation/appveyor-ci_appveyor_agent.md new file mode 100644 index 0000000..1f3fe8d --- /dev/null +++ b/documentation/appveyor-ci_appveyor_agent.md @@ -0,0 +1,40 @@ +# appveyor-ci_appveyor_agent + +Installs the AppVeyor deployment agent MSI on Windows hosts. + +## Actions + +| Action | Description | +|--------|-------------| +| `:install` | Installs the AppVeyor deployment agent (default). | + +## Properties + +| Property | Type | Default | Description | +|----------|------|---------|-------------| +| `version` | String | name property | AppVeyor deployment agent version to install. | +| `access_key` | String | `nil` | Deployment access key used by the agent. | +| `environment_access_key` | String | `nil` | Alias for `access_key` for compatibility with existing examples. | +| `deployment_group` | String | required | AppVeyor deployment group name. | +| `installer_url` | String | derived from `version` | Custom MSI download URL. | +| `install_path` | String | `'C:\\Program Files (x86)\\AppVeyor\\DeploymentAgent\\Appveyor.DeploymentAgent.Service.exe'` | Expected installation path. | + +## Examples + +### Install the latest agent + +```ruby +appveyor_agent 'latest' do + access_key 'abc123' + deployment_group 'test' +end +``` + +### Install a specific version + +```ruby +appveyor_agent '3.12.0' do + environment_access_key 'abc123' + deployment_group 'production' +end +``` diff --git a/kitchen.exec.yml b/kitchen.exec.yml index ba7b2a9..44f268a 100644 --- a/kitchen.exec.yml +++ b/kitchen.exec.yml @@ -1,7 +1,3 @@ --- driver: { name: exec } transport: { name: exec } - -platforms: - - name: macos-latest - - name: windows-latest diff --git a/kitchen.global.yml b/kitchen.global.yml index a382fcd..4daf2ea 100644 --- a/kitchen.global.yml +++ b/kitchen.global.yml @@ -13,26 +13,3 @@ provisioner: verifier: name: inspec - -platforms: - - name: almalinux-8 - - name: almalinux-9 - - name: amazonlinux-2023 - - name: centos-7 - - name: centos-stream-8 - - name: centos-stream-9 - - name: debian-9 - - name: debian-10 - - name: debian-11 - - name: debian-12 - - name: fedora-latest - - name: opensuse-leap-15 - - name: oraclelinux-7 - - name: oraclelinux-8 - - name: oraclelinux-9 - - name: rockylinux-8 - - name: rockylinux-9 - - name: ubuntu-18.04 - - name: ubuntu-20.04 - - name: ubuntu-22.04 - - name: ubuntu-23.04 diff --git a/kitchen.yml b/kitchen.yml new file mode 100644 index 0000000..1d1be58 --- /dev/null +++ b/kitchen.yml @@ -0,0 +1,29 @@ +--- +verifier: + name: inspec + +x-run_lists: + default: &default_run_list + - recipe[test::default] + versioned: &versioned_run_list + - recipe[test::versioned] + +x-verifiers: + default: &default_verifier + inspec_tests: + - path: test/integration/default + versioned: &versioned_verifier + inspec_tests: + - path: test/integration/versioned + +platforms: + - name: windows-latest + +suites: + - name: default + run_list: *default_run_list + verifier: *default_verifier + + - name: versioned + run_list: *versioned_run_list + verifier: *versioned_verifier diff --git a/metadata.rb b/metadata.rb index 4fcbd51..249fd3b 100644 --- a/metadata.rb +++ b/metadata.rb @@ -6,6 +6,6 @@ issues_url 'https://github.com/sous-chefs/appveyor-ci/issues' source_url 'https://github.com/sous-chefs/appveyor-ci' version '0.2.11' -chef_version '>= 13.0' +chef_version '>= 15.3' supports 'windows' diff --git a/resources/agent_install.rb b/resources/agent_install.rb index 3098770..ac820ce 100644 --- a/resources/agent_install.rb +++ b/resources/agent_install.rb @@ -1,35 +1,30 @@ +# frozen_string_literal: true -# Cookbook:: appveyor-agent -# Resource:: agent -# -# Copyright:: (C) 2016 J Sainsburys PLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -resource_name :appveyor_agent_install +provides :appveyor_agent provides :appveyor_agent_install +unified_mode true -property :version, String, name_property: true -property :access_key, String, required: true +property :version, String, name_property: true +property :access_key, String, sensitive: true +property :environment_access_key, String, sensitive: true property :deployment_group, String, required: true -property :installer_url, String, default: lazy { "https://www.appveyor.com/downloads/deployment-agent/#{version}/AppveyorDeploymentAgent.msi" } -property :install_path, String, default: lazy { 'C:\\Program Files (x86)\\AppVeyor\\DeploymentAgent\\Appveyor.DeploymentAgent.Service.exe' } +property :installer_url, String, default: lazy { "https://www.appveyor.com/downloads/deployment-agent/#{version}/AppveyorDeploymentAgent.msi" } +property :install_path, String, default: 'C:\\Program Files (x86)\\AppVeyor\\DeploymentAgent\\Appveyor.DeploymentAgent.Service.exe' + +default_action :install + +action_class do + def resolved_access_key + new_resource.access_key || new_resource.environment_access_key + end +end action :install do + raise Chef::Exceptions::ValidationFailed, 'appveyor_agent requires access_key or environment_access_key' if resolved_access_key.nil? || resolved_access_key.empty? + windows_package 'AppveyorDeploymentAgent' do - source installer_url + source new_resource.installer_url installer_type :msi - options "/quiet /qn /norestart /log install.log ENVIRONMENT_ACCESS_KEY=#{new_resoruce.access_key} DEPLOYMENT_GROUP=#{new_resoruce.deployment_group}" + options "/quiet /qn /norestart /log install.log ENVIRONMENT_ACCESS_KEY=#{resolved_access_key} DEPLOYMENT_GROUP=#{new_resource.deployment_group}" end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..63e556f --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +require 'chefspec' +require 'chefspec/berkshelf' + +RSpec.configure do |config| + config.color = true + config.formatter = :documentation + config.log_level = :error +end diff --git a/spec/unit/recipes/default_spec.rb b/spec/unit/recipes/default_spec.rb deleted file mode 100644 index 16bc000..0000000 --- a/spec/unit/recipes/default_spec.rb +++ /dev/null @@ -1,10 +0,0 @@ - -require 'spec_helper' - -describe 'Default recipe on Ubuntu 16.04' do - let(:runner) { ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04', step_into: ['haproxy_install']) } - - it 'converges successfully' do - expect { :chef_run }.to_not raise_error - end -end diff --git a/spec/unit/resources/agent_spec.rb b/spec/unit/resources/agent_spec.rb new file mode 100644 index 0000000..6a4300b --- /dev/null +++ b/spec/unit/resources/agent_spec.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'appveyor_agent' do + step_into :appveyor_agent + platform 'windows', '2019' + + context 'with access_key' do + recipe do + appveyor_agent 'latest' do + access_key 'abc123' + deployment_group 'test' + end + end + + it do + is_expected.to install_windows_package('AppveyorDeploymentAgent').with( + source: 'https://www.appveyor.com/downloads/deployment-agent/latest/AppveyorDeploymentAgent.msi', + installer_type: :msi, + options: '/quiet /qn /norestart /log install.log ENVIRONMENT_ACCESS_KEY=abc123 DEPLOYMENT_GROUP=test' + ) + end + end + + context 'with environment_access_key' do + recipe do + appveyor_agent '3.12.0' do + environment_access_key 'def456' + deployment_group 'deploy' + end + end + + it do + is_expected.to install_windows_package('AppveyorDeploymentAgent').with( + source: 'https://www.appveyor.com/downloads/deployment-agent/3.12.0/AppveyorDeploymentAgent.msi', + options: '/quiet /qn /norestart /log install.log ENVIRONMENT_ACCESS_KEY=def456 DEPLOYMENT_GROUP=deploy' + ) + end + end +end diff --git a/test/cookbooks/test/metadata.rb b/test/cookbooks/test/metadata.rb new file mode 100644 index 0000000..c690e4d --- /dev/null +++ b/test/cookbooks/test/metadata.rb @@ -0,0 +1,4 @@ +name 'test' +version '0.1.0' + +depends 'appveyor-ci' diff --git a/test/cookbooks/test/recipes/default.rb b/test/cookbooks/test/recipes/default.rb new file mode 100644 index 0000000..acbfd8b --- /dev/null +++ b/test/cookbooks/test/recipes/default.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +appveyor_agent 'latest' do + access_key 'test-access-key' + deployment_group 'test' +end diff --git a/test/cookbooks/test/recipes/versioned.rb b/test/cookbooks/test/recipes/versioned.rb new file mode 100644 index 0000000..f9df3c3 --- /dev/null +++ b/test/cookbooks/test/recipes/versioned.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +appveyor_agent '3.12.0' do + access_key 'test-access-key' + deployment_group 'test' +end diff --git a/test/fixtures/cookbooks/test/latest.rb b/test/fixtures/cookbooks/test/latest.rb deleted file mode 100644 index b41ed76..0000000 --- a/test/fixtures/cookbooks/test/latest.rb +++ /dev/null @@ -1,4 +0,0 @@ -appveyor_agent 'latest' do - access_key node['environment_access_key'] - deployment_group 'test' -end diff --git a/test/fixtures/cookbooks/test/metadata.rb b/test/fixtures/cookbooks/test/metadata.rb deleted file mode 100644 index 6a12dc5..0000000 --- a/test/fixtures/cookbooks/test/metadata.rb +++ /dev/null @@ -1,4 +0,0 @@ -name 'appveyor-agent-3-12-0' -version '0.0.1' - -depends 'appveyor-ci' diff --git a/test/fixtures/cookbooks/test/specifed_version.rb b/test/fixtures/cookbooks/test/specifed_version.rb deleted file mode 100644 index 1bac302..0000000 --- a/test/fixtures/cookbooks/test/specifed_version.rb +++ /dev/null @@ -1,4 +0,0 @@ -appveyor_agent '3.12.0' do - access_key node['environment_access_key'] - deployment_group 'test' -end diff --git a/test/integration/appveyor-agent-3-12-0/default_spec.rb b/test/integration/appveyor-agent-3-12-0/default_spec.rb deleted file mode 100644 index 8b228a3..0000000 --- a/test/integration/appveyor-agent-3-12-0/default_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -describe file('C:\\Program Files\\AppVeyor\\DeploymentAgent\\Appveyor.DeploymentAgent.Service.exe') do - it { should exist } -end - -describe command('Write-Host ([System.Diagnostics.FileVersionInfo]::GetVersionInfo("C:\Program Files\AppVeyor\DeploymentAgent\Appveyor.DeploymentAgent.Service.exe")).FileVersion') do - its(:stdout) { should match(/3.12.0/) } -end diff --git a/test/integration/appveyor-agent-latest/default_spec.rb b/test/integration/appveyor-agent-latest/default_spec.rb deleted file mode 100644 index 32d0200..0000000 --- a/test/integration/appveyor-agent-latest/default_spec.rb +++ /dev/null @@ -1,3 +0,0 @@ -describe file('C:\\Program Files\\AppVeyor\\DeploymentAgent\\Appveyor.DeploymentAgent.Service.exe') do - it { should exist } -end diff --git a/test/integration/default/controls/default_spec.rb b/test/integration/default/controls/default_spec.rb new file mode 100644 index 0000000..58f30a2 --- /dev/null +++ b/test/integration/default/controls/default_spec.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +control 'appveyor-agent-default-01' do + impact 1.0 + title 'AppVeyor deployment agent is installed' + + describe file('C:\\Program Files (x86)\\AppVeyor\\DeploymentAgent\\Appveyor.DeploymentAgent.Service.exe') do + it { should exist } + end +end diff --git a/test/integration/default/inspec.yml b/test/integration/default/inspec.yml new file mode 100644 index 0000000..e1ac0c7 --- /dev/null +++ b/test/integration/default/inspec.yml @@ -0,0 +1,7 @@ +--- +name: default +title: Default AppVeyor agent tests +maintainer: Sous Chefs +license: Apache-2.0 +summary: Verifies the default AppVeyor agent installation +version: 1.0.0 diff --git a/test/integration/versioned/controls/versioned_spec.rb b/test/integration/versioned/controls/versioned_spec.rb new file mode 100644 index 0000000..319ede1 --- /dev/null +++ b/test/integration/versioned/controls/versioned_spec.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +control 'appveyor-agent-versioned-01' do + impact 1.0 + title 'Pinned AppVeyor deployment agent version is installed' + + describe file('C:\\Program Files (x86)\\AppVeyor\\DeploymentAgent\\Appveyor.DeploymentAgent.Service.exe') do + it { should exist } + end + + describe command('Write-Host ([System.Diagnostics.FileVersionInfo]::GetVersionInfo("C:\Program Files (x86)\AppVeyor\DeploymentAgent\Appveyor.DeploymentAgent.Service.exe")).FileVersion') do + its('stdout') { should match(/3.12.0/) } + end +end diff --git a/test/integration/versioned/inspec.yml b/test/integration/versioned/inspec.yml new file mode 100644 index 0000000..684d498 --- /dev/null +++ b/test/integration/versioned/inspec.yml @@ -0,0 +1,7 @@ +--- +name: versioned +title: Versioned AppVeyor agent tests +maintainer: Sous Chefs +license: Apache-2.0 +summary: Verifies a pinned AppVeyor agent installation +version: 1.0.0