|
1 |
| - |
2 | 1 | <p align="center">
|
3 | 2 | <img align="center" src="https://docs.keploy.io/img/keploy-logo-dark.svg?s=200&v=4" height="40%" width="500%" alt="keploy logo"/>
|
4 | 3 | </p>
|
5 | 4 | <br/>
|
6 | 5 |
|
7 |
| -# Overview |
8 |
| -It allow users to utilize Keploy's features in test-mode. |
| 6 | +# Keploy TestGPT GitHub Action |
| 7 | + |
| 8 | +TestGPT is a GitHub Action that allows you to automatically execute Keploy test cases for your applications and display test results directly in your GitHub workflow and PR comments. |
| 9 | + |
| 10 | +## Overview |
| 11 | + |
| 12 | +Keploy TestGPT integrates [Keploy](https://keploy.io) testing capabilities into your CI/CD pipeline. It: |
| 13 | + |
| 14 | +- Automatically runs Keploy test cases when triggered by a GitHub workflow |
| 15 | +- Supports multiple programming languages (Go, Java, Node.js, Python) |
| 16 | +- Works with containerized applications (Docker, Docker Compose) |
| 17 | +- Provides detailed test reports as workflow logs and PR comments |
| 18 | +- Helps identify potential issues before merging code changes |
| 19 | + |
| 20 | +## Supported Languages/Frameworks |
9 | 21 |
|
10 |
| -## Usage |
| 22 | +- **Go**: Automatically downloads dependencies and builds your application |
| 23 | +- **Node.js**: Installs npm dependencies and runs your application |
| 24 | +- **Java**: Builds with Maven and runs your Java application |
| 25 | +- **Python**: Installs pip requirements and runs your Python scripts |
| 26 | +- **Docker**: Supports both Docker and Docker Compose configurations |
11 | 27 |
|
12 |
| -Enviormental Varibales needed : - |
13 |
| -`working-directory` :- Path where the main code and pkg is present. |
14 |
| -`delay` :- is optional, it is the time taken by the application to get started. |
15 |
| -`command` :- Command to run the application. |
16 |
| -`keploy-path` :- Path where Keploy folder is present. |
| 28 | +## Setup Instructions |
17 | 29 |
|
18 |
| -Right Now languages such as :- `Go`,`Java`,`NodeJS` & `Python` are supported. |
| 30 | +### Prerequisites |
| 31 | + |
| 32 | +- A GitHub repository with your application code |
| 33 | +- Keploy test cases already created and stored in your repository |
| 34 | +- GitHub Actions workflow setup in your repository |
| 35 | + |
| 36 | +### Basic GitHub Action Workflow |
| 37 | + |
| 38 | +Create or update a GitHub workflow file (e.g., `.github/workflows/keploy-tests.yml`) with the following content: |
19 | 39 |
|
20 | 40 | ```yaml
|
21 |
| -name: Run test-cases |
| 41 | +name: Run Keploy Tests |
22 | 42 | on:
|
23 | 43 | push:
|
24 | 44 | branches:
|
25 | 45 | - main
|
| 46 | + pull_request: |
| 47 | + branches: |
| 48 | + - main |
26 | 49 |
|
27 | 50 | jobs:
|
28 |
| - my_job: |
| 51 | + keploy_tests: |
29 | 52 | runs-on: ubuntu-latest
|
30 |
| - |
31 | 53 | steps:
|
32 |
| - - name: Keploy Report |
| 54 | + - name: Checkout code |
| 55 | + uses: actions/checkout@v2 |
| 56 | + |
| 57 | + - name: Run Keploy Test Cases |
33 | 58 | uses: keploy/testgpt@main
|
34 | 59 | with:
|
35 |
| - working-directory: / |
36 |
| - delay: 10 |
37 |
| - command: node src/app.js |
38 |
| - keploy-path: ./ |
| 60 | + working-directory: / # Root directory of your project |
| 61 | + delay: 10 # Time in seconds to wait for application startup |
| 62 | + command: node src/app.js # Command to run your application |
| 63 | + keploy-path: ./ # Path where Keploy test cases are stored |
39 | 64 | ```
|
40 | 65 |
|
41 |
| -### Test summary on PR |
| 66 | +### Configuration Parameters |
42 | 67 |
|
43 |
| -Before merging PR, `keploy/testgpt@main` would let you in advance whether the test-cases are passing or not. We just need to add the below code on the `job_on:` . |
| 68 | +| Parameter | Required | Description | Default | |
| 69 | +|-----------|----------|-------------|---------| |
| 70 | +| `working-directory` | Yes | Path where your application code is located | - | |
| 71 | +| `command` | Yes | Command to run your application | - | |
| 72 | +| `keploy-path` | Yes | Path where Keploy test files are stored | `./` | |
| 73 | +| `delay` | Yes | Time in seconds to wait for application startup | `10` | |
| 74 | +| `container-name` | No | Container name when using Docker Compose | - | |
| 75 | +| `build-delay` | No | Time to wait for Docker container build | `50s` | |
44 | 76 |
|
45 |
| -```yml |
46 |
| - pull_request: |
47 |
| - branches: |
48 |
| - - main |
| 77 | +### Language-Specific Configuration Examples |
| 78 | + |
| 79 | +#### Node.js Application |
| 80 | + |
| 81 | +```yaml |
| 82 | +- name: Run Keploy Tests for Node.js |
| 83 | + uses: keploy/testgpt@main |
| 84 | + with: |
| 85 | + working-directory: / |
| 86 | + delay: 5 |
| 87 | + command: node index.js |
| 88 | + keploy-path: ./keploy |
| 89 | +``` |
| 90 | + |
| 91 | +#### Go Application |
| 92 | + |
| 93 | +```yaml |
| 94 | +- name: Run Keploy Tests for Go |
| 95 | + uses: keploy/testgpt@main |
| 96 | + with: |
| 97 | + working-directory: / |
| 98 | + delay: 3 |
| 99 | + command: go run main.go |
| 100 | + keploy-path: ./keploy |
49 | 101 | ```
|
50 | 102 |
|
51 |
| -The test-cases will be visible on both the github_action logs as well as on the PR as the comment, which allows maintainer and contributor to know beforehand if there are fix associated with the PR |
| 103 | +#### Java/Maven Application |
| 104 | + |
| 105 | +```yaml |
| 106 | +- name: Run Keploy Tests for Java |
| 107 | + uses: keploy/testgpt@main |
| 108 | + with: |
| 109 | + working-directory: / |
| 110 | + delay: 15 |
| 111 | + command: java -jar target/myapp.jar |
| 112 | + keploy-path: ./keploy |
| 113 | +``` |
| 114 | + |
| 115 | +#### Python Application |
| 116 | + |
| 117 | +```yaml |
| 118 | +- name: Run Keploy Tests for Python |
| 119 | + uses: keploy/testgpt@main |
| 120 | + with: |
| 121 | + working-directory: / |
| 122 | + delay: 5 |
| 123 | + command: python3 app.py |
| 124 | + keploy-path: ./keploy |
| 125 | +``` |
| 126 | + |
| 127 | +#### Docker Application |
| 128 | + |
| 129 | +```yaml |
| 130 | +- name: Run Keploy Tests for Docker |
| 131 | + uses: keploy/testgpt@main |
| 132 | + with: |
| 133 | + working-directory: / |
| 134 | + delay: 20 |
| 135 | + command: docker run -p 8080:8080 myapp |
| 136 | + keploy-path: ./keploy |
| 137 | + build-delay: 60s |
| 138 | +``` |
| 139 | + |
| 140 | +#### Docker Compose Application |
| 141 | + |
| 142 | +```yaml |
| 143 | +- name: Run Keploy Tests for Docker Compose |
| 144 | + uses: keploy/testgpt@main |
| 145 | + with: |
| 146 | + working-directory: / |
| 147 | + delay: 30 |
| 148 | + command: docker compose up |
| 149 | + keploy-path: ./keploy |
| 150 | + container-name: app |
| 151 | + build-delay: 90s |
| 152 | +``` |
| 153 | + |
| 154 | +## Test Results |
| 155 | + |
| 156 | +Test results will be displayed in two places: |
| 157 | +1. In the GitHub Actions workflow logs |
| 158 | +2. As a comment on your Pull Request (when used in a PR workflow) |
| 159 | + |
| 160 | +The test report includes: |
| 161 | +- Total number of tests run |
| 162 | +- Number of tests passed |
| 163 | +- Number of tests failed |
| 164 | + |
| 165 | + |
| 166 | + |
| 167 | +## GitHub App Integration (Beta) |
| 168 | + |
| 169 | +The Keploy GitHub App (beta version) provides extended functionality: |
| 170 | +- PR analysis with LLM assistance |
| 171 | +- Automatic triggering of Keploy tests |
| 172 | +- Security scanning integration |
| 173 | +- Linting checks |
| 174 | + |
| 175 | +To use the GitHub App, see the documentation in the `keploy-github-app-beta` directory. |
| 176 | + |
| 177 | +## License |
52 | 178 |
|
53 |
| - |
| 179 | +This project is licensed under the terms specified in the [LICENSE](LICENCE) file. |
0 commit comments