Skip to content

Install Hoverfly (https://docs.hoverfly.io) so that other GitHub Actions can use it easily (e.g. for testing)

License

Notifications You must be signed in to change notification settings

SpectoLabs/hoverfly-github-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Hoverfly GitHub Action

tests reviewdog License

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

Using the Hoverfly action

Using this action is as simple as:

  1. create a .github\workflows directory in your repository
  2. create a YAML file in the .github\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: agilepathway/hoverfly-github-action@main
      with:
        runner_github_workspace_path: ${{ github.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: agilepathway/hoverfly-github-action@main
      with:
        runner_github_workspace_path: ${{ github.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 GitHub Actions workflow:

  • hoverfly
  • hoverctl

Specifying the Hoverfly version

Example:

  steps:
    - name: Install Hoverfly
      uses: agilepathway/hoverfly-github-action@main
      with:
        version: v1.3.6
        runner_github_workspace_path: ${{ github.workspace }}

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

Runner GitHub Workspace path and Hoverfly installation location

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

runner_github_workspace_path: ${{ github.workspace }}

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

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

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

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

Enabling HTTPS Hoverfly simulations

To enable HTTPS Hoverfly simulations, follow this example:

  steps:
    - name: Install Hoverfly
      uses: agilepathway/hoverfly-github-action@main
      with:
        runner_github_workspace_path: ${{ github.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 GitHub Action automatically makes this https cert install script available (in the same ${{ github.workspace }}/bin directory which we add to the path and which the Hoverfly binaries are located in too).

Tests / examples

The tests contain further configuration examples.

Suggestions / bug reports / contributions

The project is open source and all contributions are very welcome 🙂 💥 👍

Updating dependencies

See the DEPENDENCIES.md