Skip to content

Commit

Permalink
ci: enable Vagrant-based testing using GitHub Actions
Browse files Browse the repository at this point in the history
* Semi-automated using myii/ssf-formula#307
  • Loading branch information
myii committed Apr 1, 2021
1 parent 1b7b265 commit a2cb899
Show file tree
Hide file tree
Showing 6 changed files with 225 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/kitchen.vagrant.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
name: 'Kitchen Vagrant (FreeBSD, OpenBSD & Windows)'
'on': ['push', 'pull_request']

env:
KITCHEN_LOCAL_YAML: 'kitchen.vagrant.yml'

jobs:
test:
runs-on: 'macos-10.15'
strategy:
fail-fast: false
matrix:
instance:
# - default-freebsd-122-latest-py3
- freebsd-122-latest-py3
# - default-freebsd-114-latest-py3
- freebsd-114-latest-py3
# - default-openbsd-68-latest-py3
- package-openbsd-68-latest-py3
# - default-windows-81-latest-py3
- windows-81-latest-py3
steps:
- name: 'Check out code'
uses: 'actions/checkout@v2'
- name: 'Set up Bundler cache'
uses: 'actions/cache@v1'
with:
path: 'vendor/bundle'
key: "${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}"
restore-keys: "${{ runner.os }}-gems-"
- name: 'Run Bundler'
run: |
ruby --version
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- name: 'Run Test Kitchen'
run: 'bundle exec kitchen verify ${{ matrix.instance }}'
103 changes: 103 additions & 0 deletions .github/workflows/kitchen.windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
name: 'Kitchen (Windows)'
'on': ['push', 'pull_request']

env:
machine_user: kitchen
machine_pass: Pass@word1
machine_port: 5985
KITCHEN_LOCAL_YAML: 'kitchen.windows.yml'

jobs:
test-2019:
runs-on: 'windows-2019'
strategy:
fail-fast: false
matrix:
instance:
# - default-windows-2019-latest-py3
- windows-2019-latest-py3
steps:
- name: 'Check out code'
uses: 'actions/checkout@v2'
- name: 'Install Chef'
uses: 'actionshub/chef-install@1.1.0'
with:
project: 'chef'
version: '16.10.8'
- name: 'Add Chef bindir to PATH'
uses: 'myci-actions/export-env-var-powershell@1'
with:
name: 'PATH'
value: "C:\\opscode\\chef\\bin;\
C:\\opscode\\chef\\embedded\\bin;$env:PATH"
- name: 'Set up Bundler cache'
uses: 'actions/cache@v1'
with:
path: 'vendor/bundle'
key: "${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}"
restore-keys: "${{ runner.os }}-gems-"
- name: 'Set up test user'
run: |
$password = ConvertTo-SecureString $env:machine_pass -AsPlainText -Force
New-LocalUser $env:machine_user -Password $password
Add-LocalGroupMember -Group "Administrators" -Member $env:machine_user
- name: 'Set up WinRM'
run: >
Set-WSManQuickConfig -Force;
Set-WSManInstance -ResourceURI winrm/config/service
-ValueSet @{AllowUnencrypted="true"}
- name: 'Run Bundler'
run: |
ruby --version
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- name: 'Run Test Kitchen'
run: 'bundle exec kitchen verify ${{ matrix.instance }}'
test-2016:
runs-on: 'windows-2016'
strategy:
fail-fast: false
matrix:
instance:
# - default-windows-2016-latest-py3
- windows-2016-latest-py3
steps:
- name: 'Check out code'
uses: 'actions/checkout@v2'
- name: 'Install Chef'
uses: 'actionshub/chef-install@1.1.0'
with:
project: 'chef'
version: '16.10.8'
- name: 'Add Chef bindir to PATH'
uses: 'myci-actions/export-env-var-powershell@1'
with:
name: 'PATH'
value: "C:\\opscode\\chef\\bin;\
C:\\opscode\\chef\\embedded\\bin;$env:PATH"
- name: 'Set up Bundler cache'
uses: 'actions/cache@v1'
with:
path: 'vendor/bundle'
key: "${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}"
restore-keys: "${{ runner.os }}-gems-"
- name: 'Set up test user'
run: |
$password = ConvertTo-SecureString $env:machine_pass -AsPlainText -Force
New-LocalUser $env:machine_user -Password $password
Add-LocalGroupMember -Group "Administrators" -Member $env:machine_user
- name: 'Set up WinRM'
run: >
Set-WSManQuickConfig -Force;
Set-WSManInstance -ResourceURI winrm/config/service
-ValueSet @{AllowUnencrypted="true"}
- name: 'Run Bundler'
run: |
ruby --version
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- name: 'Run Test Kitchen'
run: 'bundle exec kitchen verify ${{ matrix.instance }}'
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ gem 'kitchen-docker', git: 'https://gitlab.com/saltstack-formulas/infrastructure
# rubocop:enable Layout/LineLength
gem 'kitchen-inspec', '>= 2.2.1'
gem 'kitchen-salt', '>= 0.6.3'

group :vagrant do
gem 'kitchen-vagrant'
end
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ GEM
kitchen-salt (0.6.3)
hashie (>= 3.5)
test-kitchen (>= 1.4)
kitchen-vagrant (1.7.0)
test-kitchen (>= 1.4, < 3)
libyajl2 (1.2.0)
license-acceptance (1.0.19)
pastel (~> 0.7)
Expand Down Expand Up @@ -525,6 +527,7 @@ DEPENDENCIES
kitchen-docker!
kitchen-inspec (>= 2.2.1)
kitchen-salt (>= 0.6.3)
kitchen-vagrant

BUNDLED WITH
2.1.2
50 changes: 50 additions & 0 deletions kitchen.vagrant.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
driver:
name: vagrant
cache_directory: false
customize:
usbxhci: 'off'
gui: false
linked_clone: true
ssh:
shell: /bin/sh

platforms:
- name: freebsd-122-latest-py3
driver:
box: bento/freebsd-12.2
- name: freebsd-114-latest-py3
driver:
box: bento/freebsd-11.4
- name: openbsd-68-latest-py3
driver:
box: generic/openbsd6
ssh:
shell: /bin/ksh
- name: windows-81-latest-py3
driver:
box: techneg/win81x64-pro-salt
cache_directory: "/omnibus/cache"
customize: {}
ssh: {}
provisioner:
salt_install: none
# yamllint disable rule:line-length
init_environment: |
# Workaround to allow `kitchen converge` to be used multiple times
# without having to `kitchen destroy` first: remove state files cached by
# Salt during the previous `converge` (if present)
rm -recurse `
C:\Users\vagrant\AppData\Local\Temp\kitchen\var\cache\salt\minion\files\base `
-ErrorAction SilentlyContinue
salt-call --local state.single file.managed `
C:\Users\vagrant\AppData\Local\Temp\kitchen\srv\salt\win\repo-ng\golang.sls `
source=https://github.com/saltstack/salt-winrepo-ng/raw/master/golang.sls `
skip_verify=True makedirs=True
exit 0
# yamllint enable rule:line-length

provisioner:
salt_install: bootstrap
25 changes: 25 additions & 0 deletions kitchen.windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
driver:
name: proxy
host: localhost
reset_command: "exit 0"
port: 5985
username: kitchen
password: Pass@word1

platforms:
- name: windows-2019-latest-py3
- name: windows-2016-latest-py3

provisioner:
salt_install: bootstrap
salt_bootstrap_options: -pythonVersion 3
# yamllint disable rule:line-length
init_environment: |
C:\salt\salt-call --local state.single file.managed `
C:\Users\kitchen\AppData\Local\Temp\kitchen\srv\salt\win\repo-ng\golang.sls `
source=https://github.com/saltstack/salt-winrepo-ng/raw/master/golang.sls `
skip_verify=True makedirs=True
# yamllint enable rule:line-length

0 comments on commit a2cb899

Please sign in to comment.