Skip to content

Commit 49fc85d

Browse files
committed
ci: enable Vagrant-based testing using GitHub Actions
* Semi-automated using myii/ssf-formula#304
1 parent 79257d5 commit 49fc85d

File tree

9 files changed

+277
-0
lines changed

9 files changed

+277
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
4+
name: 'Kitchen Vagrant (Windows)'
5+
'on': ['push', 'pull_request']
6+
7+
env:
8+
KITCHEN_LOCAL_YAML: 'kitchen.vagrant.yml'
9+
10+
jobs:
11+
test:
12+
runs-on: 'macos-10.15'
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
instance:
17+
- windows-windows-81-latest-py3
18+
steps:
19+
- name: 'Check out code'
20+
uses: 'actions/checkout@v2'
21+
- name: 'Set up Bundler cache'
22+
uses: 'actions/cache@v1'
23+
with:
24+
path: 'vendor/bundle'
25+
key: "${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}"
26+
restore-keys: "${{ runner.os }}-gems-"
27+
- name: 'Run Bundler'
28+
run: |
29+
ruby --version
30+
bundle config path vendor/bundle
31+
bundle install --jobs 4 --retry 3
32+
- name: 'Run Test Kitchen'
33+
run: 'bundle exec kitchen verify ${{ matrix.instance }}'
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
4+
name: 'Kitchen (Windows)'
5+
'on': ['push', 'pull_request']
6+
7+
env:
8+
machine_user: kitchen
9+
machine_pass: Pass@word1
10+
machine_port: 5985
11+
KITCHEN_LOCAL_YAML: 'kitchen.windows.yml'
12+
13+
jobs:
14+
test-2019:
15+
runs-on: 'windows-2019'
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
instance:
20+
- windows-windows-2019-latest-py3
21+
steps:
22+
- name: 'Check out code'
23+
uses: 'actions/checkout@v2'
24+
- name: 'Install Chef'
25+
uses: 'actionshub/[email protected]'
26+
with:
27+
project: 'chef'
28+
version: '16.10.8'
29+
- name: 'Add Chef bindir to PATH'
30+
uses: 'myci-actions/export-env-var-powershell@1'
31+
with:
32+
name: 'PATH'
33+
value: "C:\\opscode\\chef\\bin;\
34+
C:\\opscode\\chef\\embedded\\bin;$env:PATH"
35+
- name: 'Set up Bundler cache'
36+
uses: 'actions/cache@v1'
37+
with:
38+
path: 'vendor/bundle'
39+
key: "${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}"
40+
restore-keys: "${{ runner.os }}-gems-"
41+
- name: 'Set up test user'
42+
run: |
43+
$password = ConvertTo-SecureString $env:machine_pass -AsPlainText -Force
44+
New-LocalUser $env:machine_user -Password $password
45+
Add-LocalGroupMember -Group "Administrators" -Member $env:machine_user
46+
- name: 'Set up WinRM'
47+
run: >
48+
Set-WSManQuickConfig -Force;
49+
Set-WSManInstance -ResourceURI winrm/config/service
50+
-ValueSet @{AllowUnencrypted="true"}
51+
- name: 'Run Bundler'
52+
run: |
53+
ruby --version
54+
bundle config path vendor/bundle
55+
bundle install --jobs 4 --retry 3
56+
- name: 'Run Test Kitchen'
57+
run: 'bundle exec kitchen verify ${{ matrix.instance }}'
58+
test-2016:
59+
runs-on: 'windows-2016'
60+
strategy:
61+
fail-fast: false
62+
matrix:
63+
instance:
64+
- windows-windows-2016-latest-py3
65+
steps:
66+
- name: 'Check out code'
67+
uses: 'actions/checkout@v2'
68+
- name: 'Install Chef'
69+
uses: 'actionshub/[email protected]'
70+
with:
71+
project: 'chef'
72+
version: '16.10.8'
73+
- name: 'Add Chef bindir to PATH'
74+
uses: 'myci-actions/export-env-var-powershell@1'
75+
with:
76+
name: 'PATH'
77+
value: "C:\\opscode\\chef\\bin;\
78+
C:\\opscode\\chef\\embedded\\bin;$env:PATH"
79+
- name: 'Set up Bundler cache'
80+
uses: 'actions/cache@v1'
81+
with:
82+
path: 'vendor/bundle'
83+
key: "${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}"
84+
restore-keys: "${{ runner.os }}-gems-"
85+
- name: 'Set up test user'
86+
run: |
87+
$password = ConvertTo-SecureString $env:machine_pass -AsPlainText -Force
88+
New-LocalUser $env:machine_user -Password $password
89+
Add-LocalGroupMember -Group "Administrators" -Member $env:machine_user
90+
- name: 'Set up WinRM'
91+
run: >
92+
Set-WSManQuickConfig -Force;
93+
Set-WSManInstance -ResourceURI winrm/config/service
94+
-ValueSet @{AllowUnencrypted="true"}
95+
- name: 'Run Bundler'
96+
run: |
97+
ruby --version
98+
bundle config path vendor/bundle
99+
bundle install --jobs 4 --retry 3
100+
- name: 'Run Test Kitchen'
101+
run: 'bundle exec kitchen verify ${{ matrix.instance }}'

Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ gem 'kitchen-docker', git: 'https://gitlab.com/saltstack-formulas/infrastructure
1212
# rubocop:enable Layout/LineLength
1313
gem 'kitchen-inspec', '>= 2.2.1'
1414
gem 'kitchen-salt', '>= 0.6.3'
15+
16+
group :vagrant do
17+
gem 'kitchen-vagrant'
18+
end

Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ GEM
292292
kitchen-salt (0.6.3)
293293
hashie (>= 3.5)
294294
test-kitchen (>= 1.4)
295+
kitchen-vagrant (1.7.0)
296+
test-kitchen (>= 1.4, < 3)
295297
libyajl2 (1.2.0)
296298
license-acceptance (1.0.19)
297299
pastel (~> 0.7)
@@ -525,6 +527,7 @@ DEPENDENCIES
525527
kitchen-docker!
526528
kitchen-inspec (>= 2.2.1)
527529
kitchen-salt (>= 0.6.3)
530+
kitchen-vagrant
528531

529532
BUNDLED WITH
530533
2.1.2

kitchen.vagrant.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
4+
driver:
5+
name: vagrant
6+
cache_directory: false
7+
customize:
8+
usbxhci: 'off'
9+
gui: false
10+
linked_clone: true
11+
ssh:
12+
shell: /bin/sh
13+
14+
platforms:
15+
- name: windows-81-latest-py3
16+
driver:
17+
box: techneg/win81x64-pro-salt
18+
cache_directory: "/omnibus/cache"
19+
customize: {}
20+
ssh: {}
21+
provisioner:
22+
salt_install: none
23+
# yamllint disable rule:line-length
24+
init_environment: |
25+
# Workaround to allow `kitchen converge` to be used multiple times
26+
# without having to `kitchen destroy` first: remove state files cached by
27+
# Salt during the previous `converge` (if present)
28+
rm -recurse `
29+
C:\Users\vagrant\AppData\Local\Temp\kitchen\var\cache\salt\minion\files\base `
30+
-ErrorAction SilentlyContinue
31+
exit 0
32+
# yamllint enable rule:line-length
33+
34+
provisioner:
35+
salt_install: bootstrap

kitchen.windows.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
4+
driver:
5+
name: proxy
6+
host: localhost
7+
reset_command: "exit 0"
8+
port: 5985
9+
username: kitchen
10+
password: Pass@word1
11+
12+
platforms:
13+
- name: windows-2019-latest-py3
14+
- name: windows-2016-latest-py3
15+
16+
provisioner:
17+
salt_install: bootstrap
18+
salt_bootstrap_options: -pythonVersion 3

kitchen.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,3 +609,23 @@ suites:
609609
verifier:
610610
inspec_tests:
611611
- path: test/integration/default
612+
- name: windows
613+
includes:
614+
- windows-81-latest-py3
615+
- windows-2019-latest-py3
616+
- windows-2016-latest-py3
617+
provisioner:
618+
state_top:
619+
base:
620+
'*':
621+
- packages.chocolatey
622+
pillars:
623+
top.sls:
624+
base:
625+
'*':
626+
- packages
627+
pillars_from_files:
628+
packages.sls: test/salt/pillar/windows.sls
629+
verifier:
630+
inspec_tests:
631+
- path: test/integration/windows

test/integration/windows/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# InSpec Profile: `windows`
2+
3+
This shows the implementation of the `windows` InSpec [profile](https://github.com/inspec/inspec/blob/master/docs/profiles.md).
4+
5+
## Verify a profile
6+
7+
InSpec ships with built-in features to verify a profile structure.
8+
9+
```bash
10+
$ inspec check windows
11+
Summary
12+
-------
13+
Location: windows
14+
Profile: profile
15+
Controls: 4
16+
Timestamp: 2019-06-24T23:09:01+00:00
17+
Valid: true
18+
19+
Errors
20+
------
21+
22+
Warnings
23+
--------
24+
```
25+
26+
## Execute a profile
27+
28+
To run all **supported** controls on a local machine use `inspec exec /path/to/profile`.
29+
30+
```bash
31+
$ inspec exec windows
32+
..
33+
34+
Finished in 0.0025 seconds (files took 0.12449 seconds to load)
35+
8 examples, 0 failures
36+
```
37+
38+
## Execute a specific control from a profile
39+
40+
To run one control from the profile use `inspec exec /path/to/profile --controls name`.
41+
42+
```bash
43+
$ inspec exec windows --controls package
44+
.
45+
46+
Finished in 0.0025 seconds (files took 0.12449 seconds to load)
47+
1 examples, 0 failures
48+
```
49+
50+
See an [example control here](https://github.com/inspec/inspec/blob/master/examples/profile/controls/example.rb).
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
4+
name: windows
5+
title: packages formula
6+
maintainer: SaltStack Formulas
7+
license: Apache-2.0
8+
summary: Verify that the packages formula is setup and configured correctly (on Windows)
9+
depends:
10+
- name: share
11+
path: test/integration/share
12+
supports:
13+
- platform: windows

0 commit comments

Comments
 (0)