Skip to content

Commit 0ee210c

Browse files
authored
Merge pull request #310 from myii/ci/add-vagrant-testing-via-github-actions
ci: enable Vagrant-based testing using GitHub Actions
2 parents fc53d97 + ed2d688 commit 0ee210c

File tree

3 files changed

+111
-9
lines changed

3 files changed

+111
-9
lines changed

.github/workflows/kitchen.vagrant.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
4+
name: 'Kitchen Vagrant (FreeBSD)'
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+
- default-freebsd-122-latest-py3
18+
- default-freebsd-114-latest-py3
19+
steps:
20+
- name: 'Check out code'
21+
uses: 'actions/checkout@v2'
22+
- name: 'Set up Bundler cache'
23+
uses: 'actions/cache@v1'
24+
with:
25+
path: 'vendor/bundle'
26+
key: "${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}"
27+
restore-keys: "${{ runner.os }}-gems-"
28+
- name: 'Run Bundler'
29+
run: |
30+
ruby --version
31+
bundle config path vendor/bundle
32+
bundle install --jobs 4 --retry 3
33+
- name: 'Run Test Kitchen'
34+
run: 'bundle exec kitchen verify ${{ matrix.instance }}'

docs/README.rst

+62
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,66 @@ Runs all of the stages above in one go: i.e. ``destroy`` + ``converge`` + ``veri
164164

165165
Gives you SSH access to the instance for manual testing.
166166

167+
Testing with Vagrant
168+
--------------------
169+
170+
Windows/FreeBSD/OpenBSD testing is done with ``kitchen-salt``.
171+
172+
Requirements
173+
^^^^^^^^^^^^
174+
175+
* Ruby
176+
* Virtualbox
177+
* Vagrant
178+
179+
Setup
180+
^^^^^
181+
182+
.. code-block:: bash
183+
184+
$ gem install bundler
185+
$ bundle install --with=vagrant
186+
$ bin/kitchen test [platform]
187+
188+
Where ``[platform]`` is the platform name defined in ``kitchen.vagrant.yml``,
189+
e.g. ``windows-81-latest-py3``.
190+
191+
Note
192+
^^^^
193+
194+
When testing using Vagrant you must set the environment variable ``KITCHEN_LOCAL_YAML`` to ``kitchen.vagrant.yml``. For example:
195+
196+
.. code-block:: bash
197+
198+
$ KITCHEN_LOCAL_YAML=kitchen.vagrant.yml bin/kitchen test # Alternatively,
199+
$ export KITCHEN_LOCAL_YAML=kitchen.vagrant.yml
200+
$ bin/kitchen test
201+
202+
Then run the following commands as needed.
203+
204+
``bin/kitchen converge``
205+
^^^^^^^^^^^^^^^^^^^^^^^^
206+
207+
Creates the Vagrant instance and runs the ``postgres`` main state, ready for testing.
208+
209+
``bin/kitchen verify``
210+
^^^^^^^^^^^^^^^^^^^^^^
211+
212+
Runs the ``inspec`` tests on the actual instance.
213+
214+
``bin/kitchen destroy``
215+
^^^^^^^^^^^^^^^^^^^^^^^
216+
217+
Removes the Vagrant instance.
218+
219+
``bin/kitchen test``
220+
^^^^^^^^^^^^^^^^^^^^
221+
222+
Runs all of the stages above in one go: i.e. ``destroy`` + ``converge`` + ``verify`` + ``destroy``.
223+
224+
``bin/kitchen login``
225+
^^^^^^^^^^^^^^^^^^^^^
226+
227+
Gives you RDP/SSH access to the instance for manual testing.
228+
167229
.. vim: fenc=utf-8 spell spl=en cc=100 tw=99 fo=want sts=2 sw=2 et

kitchen.vagrant.yml

+15-9
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,21 @@
33
---
44
driver:
55
name: vagrant
6+
cache_directory: false
7+
customize:
8+
usbxhci: 'off'
9+
gui: false
10+
linked_clone: true
11+
ssh:
12+
shell: /bin/sh
613

714
platforms:
8-
- name: freebsd-120-2019-2-py3
15+
- name: freebsd-122-latest-py3
916
driver:
10-
box_url: https://freebsd.z.vstack.com/FreeBSD-12.0.box
11-
cache_directory: false
12-
customize:
13-
usbxhci: 'off'
14-
gui: false
15-
linked_clone: true
16-
ssh:
17-
shell: '/bin/sh'
17+
box: bento/freebsd-12.2
18+
- name: freebsd-114-latest-py3
19+
driver:
20+
box: bento/freebsd-11.4
21+
22+
provisioner:
23+
salt_install: bootstrap

0 commit comments

Comments
 (0)