Skip to content

feat: Github App For Keploy (Beta) #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
00bb3aa
feat: initialize keploy-github-app-beta with Docker support and essen…
SkySingh04 Feb 12, 2025
f8f5aa8
feat: add check for /keploy folder existence in pull request events
SkySingh04 Feb 12, 2025
2865040
feat: added Keploy Github App
SkySingh04 Feb 12, 2025
0bd2663
refactor: introduce type definitions and improve type safety across t…
SkySingh04 Mar 15, 2025
0d8de5c
refactor: enhance type definitions and improve function signatures in…
SkySingh04 Mar 15, 2025
0674256
refactor: enhance diff parsing and error handling in diffparser.ts
SkySingh04 Mar 15, 2025
8040006
refactor: enhance type safety and logging in various modules
SkySingh04 Mar 15, 2025
aec11b4
refactor: improve error handling and logging in workflow triggers and…
SkySingh04 Mar 15, 2025
4ac4230
feat: implement structured error handling and improve configuration l…
SkySingh04 Mar 15, 2025
161ebcd
refactor: optimize asynchronous operations in PR and workflow handling
SkySingh04 Mar 15, 2025
d0cd28f
feat: enhance linked issue handling in PR analysis
SkySingh04 Mar 15, 2025
817708e
fix: improve validation of response content in getRulesForLLM
SkySingh04 Mar 15, 2025
8bfd0a1
feat: enhance label determination logic in addLabel.ts
SkySingh04 Mar 15, 2025
518bc31
feat: add PDF export functionality for pull request summaries
SkySingh04 Mar 16, 2025
d1c86ed
feat: implement user feedback improvements in PR analysis
SkySingh04 Mar 16, 2025
31dbc3f
fix: update API endpoint in configuration
SkySingh04 Mar 16, 2025
de71c91
fix: clear selected model in configuration
SkySingh04 Mar 16, 2025
7628857
refactor: remove unnecessary comment from types.ts
SkySingh04 Mar 20, 2025
e8f9aec
refactor: remove unnecessary comment from pr.ts
SkySingh04 Mar 20, 2025
fd313b9
chore: add comment for core data collection functions in pr.ts
SkySingh04 Mar 20, 2025
27192ee
feat: add CI workflows for testing, linting, and security scanning
SkySingh04 Mar 20, 2025
ce2c164
refactor: update logging for LLM output in PR analysis
SkySingh04 Mar 20, 2025
76fc8ae
feat: add README for Keploy Github App
SkySingh04 Mar 20, 2025
b0d8d32
feat: update JavaScript linting configuration
SkySingh04 Mar 20, 2025
0a1126c
feat: add ESLint formatter for improved reporting
SkySingh04 Mar 20, 2025
0f3a9a0
feat: add whitespace for improved code formatting
SkySingh04 Mar 20, 2025
5f0f1ed
feat: enhance error logging across the application
SkySingh04 Mar 21, 2025
29f7c3a
feat: improve data handling and type safety in PR and types files
SkySingh04 Mar 21, 2025
6c0de73
feat: enhance type safety and structure in diffparser.ts
SkySingh04 Mar 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions .github/workflows/keploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Keploy Test Runner

on:
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
command:
description: 'Command to run the application'
required: true
working-directory:
description: 'Working directory'
required: true
default: '.'
delay:
description: 'Startup delay'
required: true
default: '10'
keploy-path:
description: 'Path to keploy'
required: true
default: './'
container-name:
description: 'Container name for docker compose'
required: false
build-delay:
description: 'Docker build delay'
default: '50s'

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Go
if: contains(inputs.command, 'go')
uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Setup Node.js
if: contains(inputs.command, 'node')
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Setup Java
if: contains(inputs.command, 'java') || contains(inputs.command, 'mvn')
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Setup Python
if: contains(inputs.command, 'python')
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install Keploy
shell: bash
run: |
curl --silent --location "https://github.com/keploy/keploy/releases/latest/download/keploy_linux_amd64.tar.gz" | tar xz -C /tmp
sudo mv /tmp/keploy /usr/local/bin/keploy
chmod +x /usr/local/bin/keploy

- name: Run Tests
id: keploy-test
shell: bash
env:
COMMAND: ${{ github.event.inputs.command }}
WORKING_DIR: ${{ github.event.inputs.working-directory }}
DELAY: ${{ github.event.inputs.delay }}
KEPLOY_PATH: ${{ github.event.inputs.keploy-path }}
CONTAINER_NAME: ${{ github.event.inputs.container-name }}
BUILD_DELAY: ${{ github.event.inputs.build-delay }}
run: |
cd "$WORKING_DIR"
go mod download
sudo -E keploy test -c "go run main.go" --delay "10" --path "."
grep -oE "COMPLETE TESTRUN SUMMARY\.\s+Total tests: [0-9]+" report.txt | sed -r "s/\x1B\[[0-9;]*[mGK]//g" > final_total_tests.out
grep -oE "COMPLETE TESTRUN SUMMARY\.\s+Total test passed: [0-9]+" report.txt | sed -r "s/\x1B\[[0-9;]*[mGK]//g" > final_total_passed.out
grep -oE "COMPLETE TESTRUN SUMMARY\.\s+Total test failed: [0-9]+" report.txt | sed -r "s/\x1B\[[0-9;]*[mGK]//g" > final_total_failed.out

echo 'KEPLOY_REPORT<<EOF' >> $GITHUB_OUTPUT
cat final_total_tests.out final_total_passed.out final_total_failed.out >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT

- name: Comment PR
if: success()
uses: actions/github-script@v6
env:
KEPLOY_REPORT: ${{ steps.keploy-test.outputs.KEPLOY_REPORT }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
if (!process.env.KEPLOY_REPORT) {
throw new Error('KEPLOY_REPORT not found');
}
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: process.env.KEPLOY_REPORT
});
20 changes: 20 additions & 0 deletions .github/workflows/keploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Run test-cases

on:
pull_request:
types: [opened, synchronize]

jobs:
my_job:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Keploy Report
uses: keploy/testgpt@main
with:
working-directory: ${{ github.workspace }}
delay: 10
command: node src/app.js
keploy-path: .
135 changes: 135 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
name: Lint Workflow

on:
workflow_dispatch:
pull_request:
branches:
- main
permissions:
contents: read
pull-requests: write
issues: write

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up environment variables
run: echo "WORKDIR=${{ github.workspace }}/${{ inputs.working-directory }}" >> $GITHUB_ENV

- name: Detect languages
id: language-detection
shell: bash
run: |
declare -A extensions=(
["go"]="go"
["js"]="javascript"
["ts"]="javascript"
["py"]="python"
["java"]="java"
)

LANGUAGES=""

# Find all files in the repository and extract unique file extensions
for file in $(find . -type f); do
echo $file
ext="${file##*.}"
if [[ -n "${extensions[$ext]}" ]]; then
LANGUAGES+="${extensions[$ext]} "
fi
done

# Get unique languages
UNIQUE_LANGS=$(echo "$LANGUAGES" | tr ' ' '\n' | sort -u | tr '\n' ' ')
echo "languages=$UNIQUE_LANGS" >> $GITHUB_ENV

- name: Install analysis tools
shell: bash
run: |
for lang in ${{ env.languages }}; do
case "$lang" in
go)
go install golang.org/x/lint/golint@latest
;;
javascript)
npm install -g eslint
npm install -D eslint-formatter-junit
;;
python)
pip install flake8
;;
esac
done

- name: Run Code Analysis
shell: bash
run: |
mkdir -p analysis-reports
cd $WORKDIR

for lang in ${{ env.languages }}; do
echo $lang
case "$lang" in
go)
golangci-lint run --out-format=github-actions ./... > analysis-reports/go-lint.txt || true
;;
javascript)
eslint . --config keploy-github-app-beta/eslint.config.js --format junit -o analysis-reports/js-lint.xml || true
;;
python)
which flake8 || pip install flake8

flake8 . --output-file=analysis-reports/py-lint.txt || true
;;
esac
done

- name: Combine Analysis Reports
shell: bash
run: |
mkdir -p analysis-reports
temp_file=$(mktemp) # Temporary file to avoid 'input file is output file' issue

for report in analysis-reports/*; do
if [ -f "$report" ]; then
echo "### $(basename "$report")" >> "$temp_file"
cat "$report" >> "$temp_file"
echo -e "\n---\n" >> "$temp_file"
fi
done

mv "$temp_file" analysis-reports/final-report.txt

- name: Upload Final Report as Artifact
uses: actions/upload-artifact@v4
with:
name: TestGPT-Analysis-Report
path: analysis-reports/final-report.txt
if-no-files-found: warn

- name: Read Full Lint Report
id: read_report
run: |
{
echo "REPORT<<EOF"
cat analysis-reports/final-report.txt
echo "EOF"
} >> "$GITHUB_ENV"

- name: Comment Full Lint Report on PR
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
## 🔍 Lint Scan Results
```
${{ env.REPORT }}
```
token: ${{ secrets.GITHUB_TOKEN }}


57 changes: 57 additions & 0 deletions .github/workflows/security.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Security Scan with Trivy

on:
workflow_dispatch:
pull_request:
branches:
- main

permissions:
contents: read
pull-requests: write
issues: write

jobs:
security-scan:
name: Run Trivy Security Scan
runs-on: ubuntu-latest

steps:
- name: Checkout PR Code
uses: actions/checkout@v4

- name: Run Trivy Scan
uses: aquasecurity/trivy-action@master
env:
TRIVY_DISABLE_VEX_NOTICE: true
with:
scan-type: "fs"
format: "table"
ignore-unfixed: true
output: trivy_report.txt

- name: Upload Trivy Report as Artifact
uses: actions/upload-artifact@v4
with:
name: trivy-security-report
path: trivy_report.txt

- name: Read Full Trivy Report
id: read_report
run: |
{
echo "REPORT<<EOF"
cat trivy_report.txt
echo "EOF"
} >> "$GITHUB_ENV"

- name: Comment Full Trivy Report on PR
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
## 🔍 Trivy Security Scan Results
```
${{ env.REPORT }}
```
token: ${{ secrets.GITHUB_TOKEN }}
12 changes: 12 additions & 0 deletions keploy-github-app-beta/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
node_modules
npm-debug.log
*.pem
!mock-cert.pem
.env
coverage
lib
scripts/*
/dist

myenv/

Loading