Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: enable Vagrant-based testing using GitHub Actions #502

Merged
36 changes: 36 additions & 0 deletions .github/workflows/kitchen.vagrant.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# -*- 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:
- v3002-py3-freebsd-122-latest-py3
- v3002-py3-freebsd-114-latest-py3
- v3001-py3-openbsd-68-latest-py3
- v3002-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 }}'
96 changes: 79 additions & 17 deletions .github/workflows/kitchen.windows.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,101 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
name: 'Kitchen (Windows)'

'on': [push, pull_request]
'on': ['push', 'pull_request']

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

jobs:
build:
runs-on: windows-latest

test-2019:
runs-on: 'windows-2019'
strategy:
fail-fast: false
matrix:
instance:
- v3002-py3-windows-2019-latest-py3
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v1
- 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:
- v3002-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-
- shell: powershell
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
- shell: powershell
- name: 'Set up WinRM'
run: >
Set-WSManQuickConfig -Force;
Set-WSManInstance -ResourceURI winrm/config/service
-ValueSet @{AllowUnencrypted="true"}
- run: gem install bundler --quiet --no-document
- name: Bundle install
- name: 'Run Bundler'
run: |
ruby --version
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- run: bundle exec kitchen test
- name: 'Run Test Kitchen'
run: 'bundle exec kitchen verify ${{ matrix.instance }}'
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ v3002-py3-fedora-33-3002-5-py3: {extends: '.test_instance'}
v3002-py3-amazonlinux-2-3002-5-py3: {extends: '.test_instance'}
v3002-py3-oraclelinux-8-3002-5-py3: {extends: '.test_instance'}
v3002-py3-oraclelinux-7-3002-5-py3: {extends: '.test_instance'}
# v3002-py3-arch-base-latest-3002-5-py3: {extends: '.test_instance'}
v3002-py3-arch-base-latest-3002-5-py3: {extends: '.test_instance'}
v3002-py3-gentoo-stage3-latest-3002-5-py3: {extends: '.test_instance'}
v3002-py3-gentoo-stage3-systemd-3002-5-py3: {extends: '.test_instance'}
v3001-py3-debian-10-3001-6-py3: {extends: '.test_instance'}
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
- env: INSTANCE=v3002-py3-amazonlinux-2-3002-5-py3
- env: INSTANCE=v3002-py3-oraclelinux-8-3002-5-py3
- env: INSTANCE=v3002-py3-oraclelinux-7-3002-5-py3
# - env: INSTANCE=v3002-py3-arch-base-latest-3002-5-py3
- env: INSTANCE=v3002-py3-arch-base-latest-3002-5-py3
- env: INSTANCE=v3002-py3-gentoo-stage3-latest-3002-5-py3
- env: INSTANCE=v3002-py3-gentoo-stage3-systemd-3002-5-py3
- env: INSTANCE=v3001-py3-debian-10-3001-6-py3
Expand Down
10 changes: 5 additions & 5 deletions docs/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ Gives you SSH access to the instance for manual testing.
Testing with Vagrant
--------------------

Windows testing is done with ``kitchen-salt``.
Windows/FreeBSD/OpenBSD testing is done with ``kitchen-salt``.

Requirements
^^^^^^^^^^^^
Expand All @@ -273,8 +273,8 @@ Setup
$ bundle install --with=vagrant
$ bin/kitchen test [platform]

Where ``[platform]`` is the platform name defined in ``kitchen.yml``,
e.g. ``windows``.
Where ``[platform]`` is the platform name defined in ``kitchen.vagrant.yml``,
e.g. ``windows-81-latest-py3``.

Note
^^^^
Expand All @@ -292,7 +292,7 @@ Then run the following commands as needed.
``bin/kitchen converge``
^^^^^^^^^^^^^^^^^^^^^^^^

Creates the Vagrant instance and runs the ``salt.minion`` main state, ready for testing.
Creates the Vagrant instance and runs the ``salt`` main states, ready for testing.

``bin/kitchen verify``
^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -312,4 +312,4 @@ Runs all of the stages above in one go: i.e. ``destroy`` + ``converge`` + ``veri
``bin/kitchen login``
^^^^^^^^^^^^^^^^^^^^^

Gives you RDP access to the instance for manual testing.
Gives you RDP/SSH access to the instance for manual testing.
67 changes: 39 additions & 28 deletions kitchen.vagrant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,48 @@
---
driver:
name: vagrant
cache_directory: false
customize:
usbxhci: 'off'
gui: false
linked_clone: true
ssh:
shell: /bin/sh

platforms:
- name: windows-81
- 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
gui: false
linked_clone: true
cache_directory: "/omnibus/cache"
customize: {}
ssh: {}
provisioner:
init_environment: >
salt-call --local state.single file.managed
C:\Users\vagrant\AppData\Local\Temp\kitchen\srv\salt\win\repo-ng\salt-minion-py3.sls
source=https://github.com/saltstack/salt-winrepo-ng/raw/master/salt-minion-py3.sls
skip_verify=True makedirs=True
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\salt-minion-py3.sls `
source=https://github.com/saltstack/salt-winrepo-ng/raw/master/salt-minion-py3.sls `
skip_verify=True makedirs=True
exit 0
# yamllint enable rule:line-length

suites:
- name: v3000-py3
provisioner:
state_top:
base:
'*':
- salt._mapdata
- salt.minion
pillars:
top.sls:
base:
'*':
- salt
- v3000-py3
pillars_from_files:
salt.sls: test/salt/pillar/salt.sls
v3000-py3.sls: test/salt/pillar/v3000-py3.sls
verifier:
inspec_tests:
- path: test/integration/v3000-py3
provisioner:
salt_install: bootstrap
40 changes: 12 additions & 28 deletions kitchen.windows.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
driver:
name: proxy
Expand All @@ -8,34 +10,16 @@ driver:
password: Pass@word1

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

provisioner:
salt_install: bootstrap
salt_bootstrap_options: -pythonVersion 3 -version 3000.3
init_environment: >
C:\salt\salt-call --local state.single file.managed
C:\Users\kitchen\AppData\Local\Temp\kitchen\srv\salt\win\repo-ng\salt-minion-py3.sls
source=https://github.com/saltstack/salt-winrepo-ng/raw/master/salt-minion-py3.sls
skip_verify=True makedirs=True

suites:
- name: v3000-py3
provisioner:
state_top:
base:
'*':
- salt._mapdata
- salt.minion
pillars:
top.sls:
base:
'*':
- salt
- v3000-py3
pillars_from_files:
salt.sls: test/salt/pillar/salt.sls
v3000-py3.sls: test/salt/pillar/v3000-py3.sls
verifier:
inspec_tests:
- path: test/integration/v3000-py3
salt_bootstrap_options: -pythonVersion 3 -version 3002.5
# 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\salt-minion-py3.sls `
source=https://github.com/saltstack/salt-winrepo-ng/raw/master/salt-minion-py3.sls `
skip_verify=True makedirs=True
# yamllint enable rule:line-length
6 changes: 6 additions & 0 deletions kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,11 @@ suites:
- arch-base-latest-3002-5-py3
- gentoo-stage3-latest-3002-5-py3
- gentoo-stage3-systemd-3002-5-py3
- freebsd-122-latest-py3
- freebsd-114-latest-py3
- windows-81-latest-py3
- windows-2019-latest-py3
- windows-2016-latest-py3
provisioner:
state_top:
base:
Expand Down Expand Up @@ -363,6 +368,7 @@ suites:
- arch-base-latest-3001-6-py3
- gentoo-stage3-latest-3001-6-py3
- gentoo-stage3-systemd-3001-6-py3
- openbsd-68-latest-py3
provisioner:
state_top:
base:
Expand Down
7 changes: 7 additions & 0 deletions pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,13 @@ salt:
- 'deploy':
- /srv/salt/reactors/deploy.sls

# https://docs.saltstack.com/en/latest/ref/states/requisites.html#retrying-states
retry_options:
attempts: 2
until: true
interval: 10
splay: 10

salt_cloud_certs:
aws:
pem: |
Expand Down
7 changes: 7 additions & 0 deletions salt/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ salt:
profiles: salt://salt/files/cloud.profiles.d
maps: salt://salt/files/cloud.maps.d

# https://docs.saltstack.com/en/latest/ref/states/requisites.html#retrying-states
retry_options:
attempts: 2
until: true
interval: 10
splay: 10

salt_formulas:
list: {} # via pillar data
checkout_orig_branch: false
Expand Down
Loading