Fix rubocop issues. Improve documentation. Add travis

This commit is contained in:
Dmitry Ivanov 2016-01-22 20:06:26 +01:00
Родитель e20a4249ae
Коммит 2b4cce2b9a
6 изменённых файлов: 68 добавлений и 35 удалений

16
.travis.yml Normal file
Просмотреть файл

@ -0,0 +1,16 @@
language: generic
sudo: false
env:
global:
- PATH="/opt/chefdk/bin:/opt/chef/bin:/opt/chef/embedded/bin:/opt/chefdk/embedded/bin:$PATH"
addons:
apt:
sources:
- chef-stable-precise
packages:
- chefdk
script: chef exec rake travis

Просмотреть файл

@ -1,6 +1,6 @@
Visual Studio Team Services Build Agent Cookbook Visual Studio Team Services Build Agent Cookbook
================ ================
Installs and configures Visual Studio Team Services [Build Agents](https://www.visualstudio.com/en-us/get-started/build/build-your-app-vs) (a.k.a VSO Build Agents) Installs and configures Visual Studio Team Services [Build Agent](https://www.visualstudio.com/en-us/get-started/build/build-your-app-vs) (a.k.a VSO Build Agent)
Requirements Requirements
------------ ------------
@ -34,25 +34,25 @@ Resource/Provider
### windows ### windows
This resource installs and configures a build agent on windows host This resource installs and configures a build agent on windows host
#### Actions #### Actions
- :install: Install and configure a build agent - `:install`: Install and configure a build agent
- :remove: Remove a build agent and unregister it from VSTS - `:remove`: Remove a build agent and unregister it from VSTS
- :restart: Restart a build agent service - `:restart`: Restart a build agent service
#### Parameters #### Parameters
- agent_name: Name attribute. The name of a build agent - `agent_name`: Name attribute. The name of a build agent
- install_dir: A target directory to install a build agent - `install_dir`: A target directory to install a build agent
- sv_name: Set a windows service name. Default vsoagent.host.agent_name - `sv_name`: Set a windows service name. Default vsoagent.host.agent_name
- sv_user: Set a user name to run windows service. Possible values are "NT AUTHORITY\\NetworkService", "NT AUTHORITY\\LocalService" or any system valid username - `sv_user`: Set a user name to run windows service. Possible values are "NT AUTHORITY\\NetworkService", "NT AUTHORITY\\LocalService" or any system valid username
- sv_password: Set password with sv_user unless it is equal to NetworkService or LocalService - `sv_password`: Set password with sv_user unless it is equal to NetworkService or LocalService
- vsts_url: A target VSTS url - `vsts_url`: A target VSTS url
- vsts_user: A user to connect with VSTS - `vsts_user`: A user to connect with VSTS
- vsts_token: A personal access token from VSTS. [See](http://roadtoalm.com/2015/07/22/using-personal-access-tokens-to-access-visual-studio-online/) - `vsts_token`: A personal access token from VSTS. [See](http://roadtoalm.com/2015/07/22/using-personal-access-tokens-to-access-visual-studio-online/)
- vsts_pool: A pool name on VSTS - `vsts_pool`: A pool name on VSTS
- work_folder: Set different workspace location. Default is "install_dir/\_work" - `work_folder`: Set different workspace location. Default is "install_dir/\_work"
#### Examples #### Examples
Install, configure, restart and remove a build agent. Install, configure, restart and remove a build agent.
Check [tests](test/cookbooks/basic/recipes/xplat.rb) for more examples. Check [tests](test/cookbooks/windows-basic/recipes/default.rb) for more examples.
```ruby ```ruby
include_recipe 'vsts_build_agent::default' include_recipe 'vsts_build_agent::default'
@ -81,26 +81,26 @@ end
### xplat ### xplat
This resource installs and configures a build agent on linux or macosx host This resource installs and configures a build agent on linux or macosx host
#### Actions #### Actions
- :install: Install and configure a build agent - `:install`: Install and configure a build agent
- :remove: Remove a build agent and unregister it from VSTS - `:remove`: Remove a build agent and unregister it from VSTS
- :restart: Restart a build agent service - `:restart`: Restart a build agent service
#### Parameters #### Parameters
- agent_name: Name attribute. The name of build agent - `agent_name`: Name attribute. The name of build agent
- install_dir: A target directory to install build agent - `install_dir`: A target directory to install build agent
- user: Set a user to run build agent. - `user`: Set a user to run build agent.
- group: Set a group to run build agent. - `group`: Set a group to run build agent.
- sv_name: Set a service name. Default vsoagent.host.agent_name - `sv_name`: Set a service name. Default vsoagent.host.agent_name
- sv_envs: Set hash of environment variables to pass into an agent process - `sv_envs`: Set hash of environment variables to pass into an agent process
- sv_session: For MacOsX only. Set a LaunchAgent session. - `sv_session`: For MacOsX only. Set a LaunchAgent session.
- vsts_url: A target VSTS url - `vsts_url`: A target VSTS url
- vsts_user: A user to connect with VSTS - `vsts_user`: A user to connect with VSTS
- vsts_token: A personal access token from VSTS. [See](http://roadtoalm.com/2015/07/22/using-personal-access-tokens-to-access-visual-studio-online/) - `vsts_token`: A personal access token from VSTS. [See](http://roadtoalm.com/2015/07/22/using-personal-access-tokens-to-access-visual-studio-online/)
- vsts_pool: A pool name on VSTS - `vsts_pool`: A pool name on VSTS
#### Examples #### Examples
Install, configure, restart and remove build agent. Install, configure, restart and remove build agent.
Check [tests](test/cookbooks/basic/recipes/windows.rb) for more examples. Check [tests](test/cookbooks/xplat-basic/recipes/default.rb) for more examples.
```ruby ```ruby
include_recipe 'vsts_build_agent::default' include_recipe 'vsts_build_agent::default'

Просмотреть файл

@ -26,3 +26,5 @@ namespace :kitchen do
end end
task :default => ['style', 'kitchen:linux'] task :default => ['style', 'kitchen:linux']
task :travis => ['style']

Просмотреть файл

@ -17,7 +17,26 @@ rake style
## Integration Testing ## Integration Testing
Integration tests are orchestrated by [test-kitchen](https://github.com/test-kitchen/test-kitchen). Currently kitchen.yml contains mix of public(linux) and private boxes(Windows and MacOSX). Windows and MacOSX boxes can be built locally with help of Hashicorp's [packer](https://www.packer.io/) tool. Integration tests are orchestrated by [test-kitchen](https://github.com/test-kitchen/test-kitchen). Currently kitchen.yml contains mix of public(linux) and private boxes(Windows and MacOSX). Windows and MacOSX boxes can be built locally with help of Hashicorp's [packer](https://www.packer.io/) tool.
!NOTE: To use MacOSX boxes you need an Apple-branded computer. :small_red_triangle:NOTE: To use MacOSX boxes you need an Apple-branded computer.
Additionally you need [vsts account url](https://www.visualstudio.com/en-us/get-started/setup/sign-up-for-visual-studio-online), username, [personal access token](http://roadtoalm.com/2015/07/22/using-personal-access-tokens-to-access-visual-studio-online/) and [pool name](http://blog.devmatter.com/understanding-pools-and-queues-in-vso/).
Set environment variables
on windows:
```
set VSTS_URL=account.visualstudio.com
set VSTS_POOL=default
set VSTS_USER=username
set VSTS_TOKEN=my_secret_token_from_vsts
```
on linux or macosx:
```
export VSTS_URL=account.visualstudio.com
export VSTS_POOL=default
export VSTS_USER=username
export VSTS_TOKEN=my_secret_token_from_vsts
```
To run test against specific platform run: To run test against specific platform run:
``` ```

Просмотреть файл

@ -12,10 +12,8 @@ def load_current_resource
@current_resource = Chef::Resource::VstsBuildAgentWindows.new(@new_resource.name) @current_resource = Chef::Resource::VstsBuildAgentWindows.new(@new_resource.name)
@current_resource.agent_name(@new_resource.agent_name) @current_resource.agent_name(@new_resource.agent_name)
@current_resource.exists = false @current_resource.exists = false
load_current_state(@current_resource, node) load_current_state(@current_resource, node)
@new_resource.sv_name(service_name(@new_resource)) @new_resource.sv_name(service_name(@new_resource))
if agent_installed?(@current_resource, node) if agent_installed?(@current_resource, node)
@current_resource.vsts_token(@new_resource.vsts_token) @current_resource.vsts_token(@new_resource.vsts_token)
@current_resource.exists = true @current_resource.exists = true

Просмотреть файл

@ -13,10 +13,8 @@ def load_current_resource
@current_resource = Chef::Resource::VstsBuildAgentXplat.new(@new_resource.name) @current_resource = Chef::Resource::VstsBuildAgentXplat.new(@new_resource.name)
@current_resource.agent_name(@new_resource.agent_name) @current_resource.agent_name(@new_resource.agent_name)
@current_resource.exists = false @current_resource.exists = false
load_current_state(@current_resource, node) load_current_state(@current_resource, node)
@new_resource.sv_name(service_name(@new_resource)) @new_resource.sv_name(service_name(@new_resource))
if agent_installed?(@current_resource, node) if agent_installed?(@current_resource, node)
@current_resource.vsts_token(@new_resource.vsts_token) @current_resource.vsts_token(@new_resource.vsts_token)
@current_resource.exists = true @current_resource.exists = true