https://github.com/imposter-project/imposter-github-action
Official GitHub Actions for Imposter, a modern mock server designed for microservice development and testing.
https://github.com/imposter-project/imposter-github-action
github-actions imposter mock mock-server
Last synced: 3 months ago
JSON representation
Official GitHub Actions for Imposter, a modern mock server designed for microservice development and testing.
- Host: GitHub
- URL: https://github.com/imposter-project/imposter-github-action
- Owner: imposter-project
- License: mit
- Created: 2025-02-03T21:41:05.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-02-04T13:55:33.000Z (8 months ago)
- Last Synced: 2025-05-23T06:17:15.548Z (5 months ago)
- Topics: github-actions, imposter, mock, mock-server
- Homepage: https://www.imposter.sh
- Size: 29.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Imposter GitHub Actions [](https://github.com/imposter-project/imposter-github-action/actions/workflows/ci.yml)
This repository contains official GitHub Actions for [Imposter](https://www.imposter.sh), a modern mock server designed for microservice development and testing. These actions allow you to seamlessly integrate Imposter into your GitHub Actions workflows.
> [!NOTE]
> Replace `v1` in the examples below with the [latest release](https://github.com/imposter-project/imposter-github-action/releases).## Available Actions
### 1. Setup Imposter (`setup`)
Downloads and installs the Imposter mock server.```yaml
- uses: imposter-project/imposter-github-action/setup@v1
```### 2. Start Mocks (`start-mocks`)
Starts the Imposter mock server in the background, and waits for it to be ready.```yaml
- uses: imposter-project/imposter-github-action/start-mocks@v1
with:
# Optional: Path to the directory containing the Imposter configuration files
config-dir: './mocks' # default: './mocks'
# Optional: Port number for the Imposter server
port: '8080' # default: '8080'
# Optional: Version of the Imposter mock engine to use
version: '1.2.3' # default: '' (latest)
# Optional: Type of mock engine to use (jvm or docker)
engine-type: 'docker' # default: 'docker'
# Optional: Whether to recursively scan the config directory
recursive-config-scan: 'false' # default: 'false'
```> [!NOTE]
> For `version`, choose from the Imposter [releases](https://github.com/outofcoffee/imposter/releases) page.Advanced configuration options
- `auto-restart`: Whether to automatically restart when configuration changes (default: false)
- `max-attempts`: Maximum number of attempts to check if the server is ready (default: 30)
- `retry-interval`: Interval in seconds between retry attempts (default: 1)#### Outputs
- `base-url`: Base URL of the mock server (e.g. `http://localhost:8080`)### 3. Stop Mocks (`stop-mocks`)
Stops the running Imposter mock server.```yaml
- uses: imposter-project/imposter-github-action/stop-mocks@v1
with:
# Optional: Type of mock engine to use (jvm or docker)
engine-type: 'docker' # default: 'docker'
```## Sample Workflow
Here's a complete example showing how to use all three actions in a workflow:
```yaml
name: Integration Tests with Mockson:
push:
branches: [ main ]
pull_request:
branches: [ main ]jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Install Imposter CLI
- name: Setup Imposter
uses: imposter-project/imposter-github-action/setup@v1
# Start mock server
- name: Start Mocks
id: start-mocks
uses: imposter-project/imposter-github-action/start-mocks@v1
with:
config-dir: './mocks'
port: '8080' # Optional: specify port number
engine-type: 'docker' # Optional: specify engine type
version: '1.2.3' # Optional: specify engine version
recursive-config-scan: 'true' # Optional: scan config directory recursively
# Your test steps here
- name: Run Tests
run: |
# The mock server is available at ${{ steps.start-mocks.outputs.base-url }}
echo "Running tests against mock server at ${{ steps.start-mocks.outputs.base-url }}"
# Stop mock server
- name: Stop Mocks
uses: imposter-project/imposter-github-action/stop-mocks@v1
with:
engine-type: 'docker' # Should match the engine-type used in start-mocks
```## Configuration
The mock server configuration should be placed in your repository according to the `config-dir` parameter (defaults to `./mocks`). For detailed information about configuring Imposter mocks, please visit the [official documentation](https://docs.imposter.sh/configuration/).
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## License
This project is licensed under the MIT License - see the LICENSE file for details.
## Links
- [Imposter Official Website](https://www.imposter.sh)
- [Imposter Documentation](https://docs.imposter.sh)
- [GitHub Repository](https://github.com/imposter-project/imposter-github-action)