From 2ebc9c11da512c8bc2089e8ecb28f5d3e13261f1 Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Fri, 26 Mar 2021 11:15:17 +0000 Subject: [PATCH 1/2] ci: enable Vagrant-based testing using GitHub Actions * Semi-automated using https://github.com/myii/ssf-formula/pull/304 --- .github/workflows/kitchen.vagrant.yml | 34 +++++++++++++++++++++++++++ kitchen.vagrant.yml | 24 ++++++++++++------- 2 files changed, 49 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/kitchen.vagrant.yml diff --git a/.github/workflows/kitchen.vagrant.yml b/.github/workflows/kitchen.vagrant.yml new file mode 100644 index 0000000..08cf2cd --- /dev/null +++ b/.github/workflows/kitchen.vagrant.yml @@ -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 }}' diff --git a/kitchen.vagrant.yml b/kitchen.vagrant.yml index 2dcd6f3..cb9c6d9 100644 --- a/kitchen.vagrant.yml +++ b/kitchen.vagrant.yml @@ -3,15 +3,21 @@ --- driver: name: vagrant + cache_directory: false + customize: + usbxhci: 'off' + gui: false + linked_clone: true + ssh: + shell: /bin/sh platforms: - - name: freebsd-120-2019-2-py3 + - name: freebsd-122-latest-py3 driver: - box_url: https://freebsd.z.vstack.com/FreeBSD-12.0.box - cache_directory: false - customize: - usbxhci: 'off' - gui: false - linked_clone: true - ssh: - shell: '/bin/sh' + box: bento/freebsd-12.2 + - name: freebsd-114-latest-py3 + driver: + box: bento/freebsd-11.4 + +provisioner: + salt_install: bootstrap From ed2d6884b10725fad55b83de4972e59710f1970f Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Fri, 26 Mar 2021 14:28:15 +0000 Subject: [PATCH 2/2] docs(readme): add `Testing with Vagrant` section --- docs/README.rst | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/docs/README.rst b/docs/README.rst index ab98b40..bc38133 100644 --- a/docs/README.rst +++ b/docs/README.rst @@ -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. +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