Skip to content

Commit

Permalink
Fix release GHA; update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Nov 3, 2021
1 parent 62aa619 commit 78eefcc
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 24 deletions.
23 changes: 15 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
name: Release

on:
create:
ref_type: tag
push:
tags:
- '*'

jobs:
release:
runs-on: ubuntu-latest
if: github.repository == 'voxpupuli/beaker-rspec'
env:
BUNDLE_WITHOUT: release
if: github.repository_owner == 'voxpupuli'
steps:
- uses: actions/checkout@v2
- name: Install Ruby 2.7
- name: Install Ruby 3.0
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
ruby-version: '3.0'
bundler: 'none'
- name: Build gem
run: gem build *.gemspec
- name: Publish gem
- name: Publish gem to rubygems.org
run: gem push *.gem
env:
GEM_HOST_API_KEY: '${{ secrets.RUBYGEMS_AUTH_TOKEN }}'
- name: Setup GitHub packages access
run: |
mkdir -p ~/.gem
echo ":github: Bearer ${{ secrets.GITHUB_TOKEN }}" >> ~/.gem/credentials
chmod 0600 ~/.gem/credentials
- name: Publish gem to GitHub packages
run: gem push --key github --host https://rubygems.pkg.github.com/${{ github.repository_owner }} *.gem
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ Gemfile.lock
log
.vagrant
*.gem
.vendor/
65 changes: 49 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
# beaker-rspec

beaker-rspec is a bridge between the puppet acceptance test harness ([beaker](https://github.com/puppetlabs/beaker)) and [rspec](https://github.com/rspec/rspec). It also integrates [serverspec](http://serverspec.org/).
[![License](https://img.shields.io/github/license/voxpupuli/beaker.svg)](https://github.com/voxpupuli/beaker/blob/master/LICENSE)
[![Test](https://github.com/voxpupuli/beaker/actions/workflows/test.yml/badge.svg)](https://github.com/voxpupuli/beaker/actions/workflows/test.yml)
[![Release](https://github.com/voxpupuli/beaker/actions/workflows/release.yml/badge.svg)](https://github.com/voxpupuli/beaker/actions/workflows/release.yml)
[![RubyGem Version](https://img.shields.io/gem/v/beaker.svg)](https://rubygems.org/gems/beaker)
[![RubyGem Downloads](https://img.shields.io/gem/dt/beaker.svg)](https://rubygems.org/gems/beaker)
[![Donated by Puppet Inc](https://img.shields.io/badge/donated%20by-Puppet%20Inc-fb7047.svg)](#transfer-notice)

# Upgrading from beaker-rspec 5 to 6
beaker-rspec is a bridge between the puppet acceptance test harness ([beaker](https://github.com/voxpupuli/beaker)) and [rspec](https://github.com/rspec/rspec). It also integrates [serverspec](http://serverspec.org/).

## Upgrading from beaker-rspec 5 to 6

In beaker-rspec 6, we've picked up the newest beaker, 3.y. In this release, we've
given up support for Ruby 1.9 and moved to 2.2.5 as our lowest tested version,
given up support for EoL Ruby and moved to 2.4 as our lowest tested version,
as well as a number of other changes underneath.

To learn more about those changes, please checkout our
[how-to upgrade](https://github.com/puppetlabs/beaker/blob/master/docs/how_to/upgrade_from_2_to_3.md)
[how-to upgrade](https://github.com/voxpupuli/beaker/blob/master/docs/how_to/upgrade_from_2_to_3.md)
doc. Note that besides the Ruby version & beaker dependency change, nothing else
was changed in beaker-rspec itself.

# Typical Workflow
To figure out our current lowest supported Ruby version, check for the
`required_ruby_version` key in `beaker-rspec.gemspec`. To see all Ruby versions
we test on, check the list in `.github/workflows/test.yml`.

## Typical Workflow

Beaker does setup and provision all nodes from your nodeset on each test run, and cleans up the VMs after use. During development on a module it can be very handy to keep the VMs available for inspection or reuse. Set `BEAKER_destroy=no` do skip the cleanup and `BEAKER_provision=no` once the VMs are created.

Expand All @@ -34,30 +45,30 @@ Beaker does setup and provision all nodes from your nodeset on each test run, an
cd .vagrant/beaker_vagrant_files/default.yml ; vagrant destroy --force
```

## Supported ENV variables
### Supported ENV variables

* `BEAKER_color`: set to `no` to disable color output
* `BEAKER_debug`: set to any value to enable beaker debug logging
* `BEAKER_destroy`: set to `no` to keep the VMs after the test run. Set to `onpass` to keep the VMs around only after a test failure.
* `BEAKER_keyfile`: specify alternate SSH key to access the test VMs
* `BEAKER_options_file`: set to the file path of the options file to be used as the default options for beaker. Equivalent to the `--options-file` parameter.
* `BEAKER_options_file`: set to the file path of the options file to be used as the default options for beaker. Equivalent to the `--options-file` parameter.
* `BEAKER_provision`: set to `no` to skip provisioning boxes before testing, beaker will then assume that boxes are already provisioned and reachable
* `BEAKER_setdir`: change the directory with nodesets. Defaults to the module's `spec/acceptance/nodesets` directory.
* `BEAKER_set`: set to the name of the node file to be used during testing (exclude .yml file extension, it will be added by beaker-rspec). The file is assumed to be in the `setdir` (see `BEAKER_setdir`).
* `BEAKER_setfile` - set to the full path to a node file be used during testing (be sure to include full path and file extensions, beaker-rspec will use this path without editing/altering it in any way)

For details on the specific mappings, the [setup code](https://github.com/puppetlabs/beaker-rspec/blob/2771b4b1864692690254a969680a57ff22ac0516/lib/beaker-rspec/spec_helper.rb#L26-L32) and the [beaker docs](https://github.com/puppetlabs/beaker/blob/master/docs/tutorials/the_command_line.md).
For details on the specific mappings, the [setup code](https://github.com/voxpupuli/beaker-rspec/blob/2771b4b1864692690254a969680a57ff22ac0516/lib/beaker-rspec/spec_helper.rb#L26-L32) and the [beaker docs](https://github.com/voxpupuli/beaker/blob/master/docs/tutorials/the_command_line.md).

# Building your Module Testing Environment
## Building your Module Testing Environment

Using puppetlabs-mysql as an example module.

## Clone the module repository of the module where you want to add tests
### Clone the module repository of the module where you want to add tests

git clone https://github.com/puppetlabs/puppetlabs-mysql
cd puppetlabs-mysql

## Install beaker-rspec
### Install beaker-rspec

In module's top level directory edit the Gemfile. You should see a `:system_tests`
or `:acceptance` group there, but if not, add beaker-rspec there:
Expand All @@ -72,23 +83,23 @@ Then run

bundle install

## Create node files
### Create node files

These files indicate the nodes (or hosts) that the tests will be run on. By default, any node file called `default.yml` will be used. You can override this using the `BEAKER_set` environment variable to indicate an alternate file. Do not provide full path or the '.yml' file extension to `BEAKER_set`, beaker-rspec expands the filename to '${DIR}/${NAME}.yml'. The directory defaults to `spec/acceptance/nodesets` but can be overridden with the `BEAKER_setdir` variable. `BEAKER_setdir` gives full control over the path (including file extension).

Nodes are pulled from [Puppet Labs Vagrant Boxes](https://vagrantcloud.com/puppetlabs).

Example node files can be found here:

* [Puppet Labs example Vagrant node files](https://github.com/puppetlabs/beaker-vagrant/blob/master/docs/vagrant_hosts_file_examples.md)
* [Puppet Labs example Vagrant node files](https://github.com/voxpupuli/beaker-vagrant/blob/master/docs/vagrant_hosts_file_examples.md)

Create the nodesets directory. From module's top level directory:

mkdir -p spec/acceptance/nodesets

Copy any nodesets that you wish to use into the nodesets directory.

## Create the spec_helper_acceptance.rb
### Create the spec_helper_acceptance.rb

In the `spec` folder, you should see the project's `spec_helper_acceptance.rb`.
This file contains all of the setup logic needed to get your Systems Under Test
Expand Down Expand Up @@ -138,7 +149,7 @@ This method will install the latest puppet-agent from the specified

Update spec_helper_acceptance.rb to reflect the module under test. You will need to set the correct module name and add any module dependencies. Place the file in the `spec` directory (in this case `puppetlabs-mysql/spec`)

## Create spec tests for your module
### Create spec tests for your module

Spec tests are written in [RSpec](http://rspec.info). You can also use [serverspec](http://serverspec.org/) matchers to test [resources](http://serverspec.org/resource_types.html).

Expand Down Expand Up @@ -183,10 +194,32 @@ describe 'mysql::server::account_security class' do
end
```

## Run your spec tests
### Run your spec tests

From module's top level directory

```
bundle exec rspec spec/acceptance
```

## Transfer Notice

This plugin was originally authored by [Puppet Inc](http://puppet.com).
The maintainer preferred that [Vox Pupuli](https://voxpupuli.org) take ownership of the module for future improvement and maintenance.
Existing pull requests and issues were transferred over, please fork and continue to contribute here.

Previously: https://github.com/puppetlabs/beaker

## License

This gem is licensed under the Apache-2 license.

## Release information

To make a new release, please do:
* update the version in lib/beaker-rspec/version.rb
* Install gems with `bundle install --with release --path .vendor`
* generate the changelog with `bundle exec rake changelog`
* Check if the new version matches the closed issues/PRs in the changelog
* Create a PR with it
* After it got merged, push a tag. GitHub actions will do the actual release to rubygems and GitHub Packages

0 comments on commit 78eefcc

Please sign in to comment.