|
1 |
| -# Container Action Template |
| 1 | +# Hoverfly GitHub Action |
2 | 2 |
|
3 |
| -To get started, click the `Use this template` button on this repository [which will create a new repository based on this template](https://github.blog/2019-06-06-generate-new-repositories-with-repository-templates/). |
| 3 | +[](https://github.com/agilepathway/hoverfly-github-action/actions?query=workflow%3Areviewdog+event%3Apush+branch%3Amain) |
| 4 | +[](LICENSE) |
4 | 5 |
|
5 |
| -For info on how to build your first Container action, see the [toolkit docs folder](https://github.com/actions/toolkit/blob/master/docs/container-action.md). |
| 6 | +**[GitHub Action](https://github.com/features/actions) that installs [Hoverfly](https://docs.hoverfly.io/), so that it can be used in subsequent steps in your GitHub Actions CI/CD pipeline (e.g. when running tests that use Hoverfly).** |
| 7 | + |
| 8 | + |
| 9 | +## Using the Hoverfly action |
| 10 | + |
| 11 | +Using this action is as simple as: |
| 12 | + |
| 13 | +1. **create a `.github\workflows` directory** in your repository |
| 14 | +2. **create a |
| 15 | + [YAML](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#about-yaml-syntax-for-workflows) |
| 16 | + file** in the `.github\workflows` directory (file name can be anything you like, |
| 17 | + with either a `.yml` or `.yaml` file extension), with this content: |
| 18 | + |
| 19 | +``` |
| 20 | +--- |
| 21 | +name: Hoverfly |
| 22 | +on: |
| 23 | + push: |
| 24 | +
|
| 25 | +jobs: |
| 26 | +
|
| 27 | + install-hoverfly: |
| 28 | + name: Install |
| 29 | + runs-on: ubuntu-latest |
| 30 | + steps: |
| 31 | + - name: Install Hoverfly |
| 32 | + uses: agilepathway/hoverfly-github-action@main |
| 33 | + with: |
| 34 | + runner_github_workspace_path: ${{ github.workspace }} |
| 35 | +``` |
| 36 | + |
| 37 | +You will also typically have additional steps both before and after the Hoverfly installation step, |
| 38 | +e.g. to checkout your code and to run your tests. Here's an example: |
| 39 | + |
| 40 | +``` |
| 41 | +--- |
| 42 | +name: Run tests |
| 43 | +on: |
| 44 | + push: |
| 45 | +
|
| 46 | +jobs: |
| 47 | +
|
| 48 | + run-tests: |
| 49 | + name: Install Hoverfly and run tests |
| 50 | + runs-on: ubuntu-latest |
| 51 | + steps: |
| 52 | + - name: Checkout code |
| 53 | + uses: actions/checkout@v2 |
| 54 | + - name: Install Hoverfly |
| 55 | + uses: agilepathway/hoverfly-github-action@main |
| 56 | + with: |
| 57 | + runner_github_workspace_path: ${{ github.workspace }} |
| 58 | + - name: Run Tests |
| 59 | + run: <command-to-run-your-tests> |
| 60 | +``` |
| 61 | + |
| 62 | +Once the Hoverfly installation has completed, both the |
| 63 | +[Hoverfly](https://docs.hoverfly.io/en/latest/pages/reference/hoverfly/hoverflycommands.html) and |
| 64 | +[Hoverctl](https://docs.hoverfly.io/en/latest/pages/keyconcepts/hoverctl.html) |
| 65 | +commands are available to you for the remainder of your GitHub Actions workflow: |
| 66 | +- `hoverfly` |
| 67 | +- `hoverctl` |
| 68 | + |
| 69 | + |
| 70 | +## Specifying the Hoverfly version |
| 71 | + |
| 72 | +Example: |
| 73 | + |
| 74 | +``` |
| 75 | + steps: |
| 76 | + - name: Install Hoverfly |
| 77 | + uses: agilepathway/hoverfly-github-action@main |
| 78 | + with: |
| 79 | + version: v1.3.0 |
| 80 | + runner_github_workspace_path: ${{ github.workspace }} |
| 81 | +``` |
| 82 | + |
| 83 | +`version` can be any [released Hoverfly version](https://github.com/SpectoLabs/hoverfly/releases). |
| 84 | +If you do not provide a version, it will default to the |
| 85 | +[latest](https://github.com/SpectoLabs/hoverfly/releases/latest) release. |
| 86 | + |
| 87 | + |
| 88 | +## Runner GitHub Workspace path and Hoverfly installation location |
| 89 | + |
| 90 | +As per the above examples, you have to provide the following parameter: |
| 91 | + |
| 92 | +`runner_github_workspace_path: ${{ github.workspace }}` |
| 93 | + |
| 94 | +The value must always be `${{ github.workspace }}` |
| 95 | + |
| 96 | +This is so that the Hoverfly binaries are added to the path properly. |
| 97 | + |
| 98 | +The Hoverfly binaries are installed at `${{ github.workspace }}/bin` |
| 99 | + |
| 100 | +(The [GitHub workspace directory is persistent throughout the GitHub Action workflow](https://docs.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners#filesystems-on-github-hosted-runners), which means that the binaries are available to any subsequent workflow steps.) |
| 101 | + |
| 102 | + |
| 103 | +## Suggestions / bug reports / contributions |
| 104 | + |
| 105 | +The project is [open source](https://opensource.guide/how-to-contribute/) and all contributions are very welcome :slightly_smiling_face: :boom: :thumbsup: |
| 106 | + |
| 107 | +* [How to report a bug or suggest a new feature](CONTRIBUTING.md#how-to-report-a-bug-or-suggest-a-new-feature) |
| 108 | + |
| 109 | +* [How to make a contribution](CONTRIBUTING.md#how-to-make-a-contribution) |
0 commit comments