Merge pull request #310 from myii/ci/add-vagrant-testing-via-github-actions
ci: enable Vagrant-based testing using GitHub Actions
This commit is contained in:
34
.github/workflows/kitchen.vagrant.yml
vendored
Normal file
34
.github/workflows/kitchen.vagrant.yml
vendored
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: ft=yaml
|
||||||
|
---
|
||||||
|
name: 'Kitchen Vagrant (FreeBSD)'
|
||||||
|
'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
|
||||||
|
- default-freebsd-114-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 }}'
|
||||||
@@ -164,4 +164,66 @@ Runs all of the stages above in one go: i.e. ``destroy`` + ``converge`` + ``veri
|
|||||||
|
|
||||||
Gives you SSH access to the instance for manual testing.
|
Gives you SSH access to the instance for manual testing.
|
||||||
|
|
||||||
|
Testing with Vagrant
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
Windows/FreeBSD/OpenBSD testing is done with ``kitchen-salt``.
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
^^^^^^^^^^^^
|
||||||
|
|
||||||
|
* Ruby
|
||||||
|
* Virtualbox
|
||||||
|
* Vagrant
|
||||||
|
|
||||||
|
Setup
|
||||||
|
^^^^^
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
$ gem install bundler
|
||||||
|
$ bundle install --with=vagrant
|
||||||
|
$ bin/kitchen test [platform]
|
||||||
|
|
||||||
|
Where ``[platform]`` is the platform name defined in ``kitchen.vagrant.yml``,
|
||||||
|
e.g. ``windows-81-latest-py3``.
|
||||||
|
|
||||||
|
Note
|
||||||
|
^^^^
|
||||||
|
|
||||||
|
When testing using Vagrant you must set the environment variable ``KITCHEN_LOCAL_YAML`` to ``kitchen.vagrant.yml``. For example:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
$ KITCHEN_LOCAL_YAML=kitchen.vagrant.yml bin/kitchen test # Alternatively,
|
||||||
|
$ export KITCHEN_LOCAL_YAML=kitchen.vagrant.yml
|
||||||
|
$ bin/kitchen test
|
||||||
|
|
||||||
|
Then run the following commands as needed.
|
||||||
|
|
||||||
|
``bin/kitchen converge``
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
Creates the Vagrant instance and runs the ``postgres`` main state, ready for testing.
|
||||||
|
|
||||||
|
``bin/kitchen verify``
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
Runs the ``inspec`` tests on the actual instance.
|
||||||
|
|
||||||
|
``bin/kitchen destroy``
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
Removes the Vagrant instance.
|
||||||
|
|
||||||
|
``bin/kitchen test``
|
||||||
|
^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
Runs all of the stages above in one go: i.e. ``destroy`` + ``converge`` + ``verify`` + ``destroy``.
|
||||||
|
|
||||||
|
``bin/kitchen login``
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
Gives you RDP/SSH access to the instance for manual testing.
|
||||||
|
|
||||||
.. vim: fenc=utf-8 spell spl=en cc=100 tw=99 fo=want sts=2 sw=2 et
|
.. vim: fenc=utf-8 spell spl=en cc=100 tw=99 fo=want sts=2 sw=2 et
|
||||||
|
|||||||
@@ -3,15 +3,21 @@
|
|||||||
---
|
---
|
||||||
driver:
|
driver:
|
||||||
name: vagrant
|
name: vagrant
|
||||||
|
cache_directory: false
|
||||||
|
customize:
|
||||||
|
usbxhci: 'off'
|
||||||
|
gui: false
|
||||||
|
linked_clone: true
|
||||||
|
ssh:
|
||||||
|
shell: /bin/sh
|
||||||
|
|
||||||
platforms:
|
platforms:
|
||||||
- name: freebsd-120-2019-2-py3
|
- name: freebsd-122-latest-py3
|
||||||
driver:
|
driver:
|
||||||
box_url: https://freebsd.z.vstack.com/FreeBSD-12.0.box
|
box: bento/freebsd-12.2
|
||||||
cache_directory: false
|
- name: freebsd-114-latest-py3
|
||||||
customize:
|
driver:
|
||||||
usbxhci: 'off'
|
box: bento/freebsd-11.4
|
||||||
gui: false
|
|
||||||
linked_clone: true
|
provisioner:
|
||||||
ssh:
|
salt_install: bootstrap
|
||||||
shell: '/bin/sh'
|
|
||||||
|
|||||||
Reference in New Issue
Block a user