SpectoLabs/hoverfly--action

Repository files navigation

testsreviewdogLicense

Action that installs Hoverfly, so that it can be used in subsequent steps in your Actions CI/CD pipeline (e.g. when running tests that use Hoverfly).

Using this action is as simple as:

  1. create a .\workflows directory in your repository
  2. create a YAML file in the .\workflows directory (file name can be anything you like, with either a .yml or .yaml file extension), with this content:
---
name: Hoverfly
on:
  push:

jobs:

  install-hoverfly:
  name: Install
  runs-on: ubuntu-latest
  steps:
    - name: Install Hoverfly
      uses: SpectoLabs/hoverfly--action@main
      with:
        version: v1.11.1
        runner__workspace_path: ${{ .workspace }}

You will also typically have additional steps both before and after the Hoverfly installation step, e.g. to checkout your code and to run your tests. Here's an example:

---
name: Run tests
on:
  push:

jobs:

  run-tests:
  name: Install Hoverfly and run tests
  runs-on: ubuntu-latest
  steps:
    - name: Checkout code
        uses: actions/checkout@v2
    - name: Install Hoverfly
      uses: SpectoLabs/hoverfly--action@main
      with:
        version: v1.11.1
        runner__workspace_path: ${{ .workspace }}
    - name: Run Tests
        run: <command-to-run-your-tests>

Once the Hoverfly installation has completed, both the Hoverfly and Hoverctl commands are available to you for the remainder of your Actions workflow:

  • hoverfly
  • hoverctl

Example:

  steps:
    - name: Install Hoverfly
      uses: SpectoLabs/hoverfly--action@main
      with:
        version: v1.11.1
        runner__workspace_path: ${{ .workspace }}

version can be any released Hoverfly version. If you do not provide a version, it will default to the latest release.

As per the above examples, you have to provide the following parameter:

runner__workspace_path: ${{ .workspace }}

The value must always be ${{ .workspace }}

This is so that the Hoverfly binaries are added to the path properly.

The Hoverfly binaries are installed at ${{ .workspace }}/bin

(The workspace directory is persistent throughout the Action workflow, which means that the binaries are available to any subsequent workflow steps.)

To enable HTTPS Hoverfly simulations, follow this example:

  steps:
    - name: Install Hoverfly
      uses: SpectoLabs/hoverfly--action@main
      with:
        runner__workspace_path: ${{ .workspace }}
      - name: Enable https calls to be simulated by Hoverfly
        run: install-and-trust-hoverfly-default-cert.sh

This script installs and trusts the default Hoverfly certificate, after which you can go ahead and simulate HTTPS calls (see this example in the end-to-end tests).

Our Hoverfly Action automatically makes this https cert install script available (in the same ${{ .workspace }}/bin directory which we add to the path and which the Hoverfly binaries are located in too).

The tests contain further configuration examples.

The project is open source and all contributions are very welcome πŸ™‚ πŸ’₯ πŸ‘

See the DEPENDENCIES.md