Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
54 changes: 27 additions & 27 deletions .github/workflows/CLA.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
name: "CLA Assistant"
# name: "CLA Assistant"

on:
issue_comment:
types:
- "created"
pull_request_target:
types:
- "opened"
- "closed"
- "synchronize"
# on:
# issue_comment:
# types:
# - "created"
# pull_request_target:
# types:
# - "opened"
# - "closed"
# - "synchronize"

jobs:
cla-assistant:
runs-on: "ubuntu-latest"
steps:
- name: "CLA Assistant"
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target')
uses: "cla-assistant/github-action@v2.1.3-beta"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
PERSONAL_ACCESS_TOKEN: "${{ secrets.PRO_ACCESS_TOKEN }}"
with:
remote-organization-name: "keploy"
remote-repository-name: "keploy"
path-to-signatures: "etc/cla-signatures/signatures.json"
path-to-document: "https://github.com/keploy/keploy/tree/main/.github/CLA.md"
branch: "cla-signatures"
allowlist: "keploy-bot,renovate"
# jobs:
# cla-assistant:
# runs-on: "ubuntu-latest"
# steps:
# - name: "CLA Assistant"
# if: github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
# uses: "cla-assistant/github-action@v2.1.3-beta"
# env:
# GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
# PERSONAL_ACCESS_TOKEN: "${{ secrets.PRO_ACCESS_TOKEN }}"
# with:
# remote-organization-name: "keploy"
# remote-repository-name: "keploy"
# path-to-signatures: "etc/cla-signatures/signatures.json"
# path-to-document: "https://github.com/keploy/keploy/tree/main/.github/CLA.md"
# branch: "cla-signatures"
# allowlist: "keploy-bot,renovate"
140 changes: 140 additions & 0 deletions .github/workflows/keploy-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: Keploy Test & Lint

on:
pull_request:
branches: [ main ]

jobs:
keploy-test-and-lint:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Run Keploy TestGPT Action
id: keploy-test-report
uses: keploy/testGPT@main
with:
working-directory: ./ # Adjust if project structure differs
command: 'your-test-command-here' # Update this
keploy-path: ./ # Path where Keploy binary is installed
delay: 10



- name: Fetch PR Details
id: pr-details
uses: actions/github-script@v6
with:
github-token: ${{ github.token }}
script: |
const pr = context.payload.pull_request;
if (!pr) {
console.log("Not a PR event.");
return;
}
const prDetails = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr.number,
});
const changedFiles = await github.paginate(github.rest.pulls.listFiles, {
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr.number,
per_page: 100,
});
const filePaths = changedFiles.map(file => file.filename);
console.log("Changed Files:", filePaths);
const metadata = {
title: pr.title,
author: pr.user.login,
files: filePaths
};
console.log("PR Metadata:", metadata);

return metadata;



- name: Detect Programming Languages
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider moving the language detection and lint logic into reusable shell scripts instead of inline bash – it'll keep the workflow clean and easier to maintain.

id: lang-detect
run: |
echo "Detecting languages..."
files=$(echo '${{ steps.pr-details.outputs.result }}' | jq -r '.files[]')

touch languages.txt
for file in $files; do
ext="${file##*.}"
case "$ext" in
js|ts) echo "JavaScript" >> languages.txt ;;
go) echo "Go" >> languages.txt ;;
py) echo "Python" >> languages.txt ;;
*) echo "Unknown" >> languages.txt ;;
esac
done

echo "Languages detected:"
cat languages.txt
shell: bash

- name: Lint Changed Files
run: |
echo "Running linters..."
files=$(echo '${{ steps.pr-details.outputs.result }}' | jq -r '.files[]')
touch lint_report.txt

for file in $files; do
ext="${file##*.}"
if [[ "$ext" == "js" || "$ext" == "ts" ]]; then
echo "Linting $file with ESLint..." >> lint_report.txt
eslint "$file" >> lint_report.txt 2>&1 || echo "Errors in $file" >> lint_report.txt
elif [[ "$ext" == "go" ]]; then
echo "Linting $file with Golint..." >> lint_report.txt
golint "$file" >> lint_report.txt 2>&1
else
echo "No linter for $file" >> lint_report.txt
fi
done

cat lint_report.txt
shell: bash

- name: Comment Lint Results on PR
uses: actions/github-script@v6
with:
github-token: ${{ github.token }}
script: |
const fs = require('fs');
const lintReport = fs.readFileSync('lint_report.txt', 'utf8');
const pr = context.payload.pull_request;
if (!pr) {
console.log("No PR context.");
return;
}
github.rest.issues.createComment({
issue_number: pr.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `### 🧹 Lint Report:\n\`\`\`\n${lintReport}\n\`\`\``
});

- name: Comment Keploy Test Report on PR
uses: actions/github-script@v6
with:
github-token: ${{ github.token }}
script: |
const report = `${{ steps.keploy-test-report.outputs.KEPLOY_REPORT }}`;
if (!report) {
console.error('Error: KEPLOY_REPORT not found.');
return;
}
github.rest.issues.createComment({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: report
});
- name: Debug Context
run: echo "${{ toJson(github) }}"
29 changes: 29 additions & 0 deletions .github/workflows/testGpt-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# name: Test TestGPT Lint + Static Analysis

# on:
# pull_request:
# types: [opened, synchronize, reopened]

# jobs:
# run-testgpt:
# runs-on: ubuntu-latest

# steps:
# - name: Checkout Code
# uses: actions/checkout@v2

# # 👇 Add this to test your custom TestGPT Action locally
# - name: Run Custom TestGPT Action
# uses: ./ # This refers to the action.yml in the root directory
# with:
# working-directory: ./
# keploy-path: ./
# command: "echo Hello from TestGPT!"

# # Optional: Show files changed in PR (testing GitHub API call)
# - name: Show Changed Files
# run: |
# echo "Fetching changed files..."
# curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
# https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files \
# | jq '.[].filename'
89 changes: 0 additions & 89 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,89 +0,0 @@
name: 'Keploy TestGPT'
description: "TestGPT is a GitHub Action designed to execute Keploy test cases and generate detailed test reports."
author: Sonichigo
branding:
icon: 'aperture'
color: 'orange'

inputs:
working-directory:
description: Relative path under $GITHUB_WORKSPACE where the repository was checked out
required: true
command:
description: Command to run the application
required: true
keploy-path:
description: Path to keploy
required: true
default: ./
delay:
description: Time to start application
required: true
default: 10
container-name:
description: Name of the container in case of "docker compose" command
build-delay:
description: Time to wait for docker container build
default: 50s

runs:
using: "composite"
steps:
- name: Setup GITHUB_PATH for script
run: |
echo "${{ github.action_path }}" >> $GITHUB_PATH
echo "${{ inputs.working-directory }}"
shell: bash
- name: Grant permissions
run: chmod +x ${GITHUB_ACTION_PATH}/install.sh
shell: bash
- id: keploy-test-report
name: Run Script
run: |
${GITHUB_ACTION_PATH}/install.sh > ${GITHUB_WORKSPACE}/${WORKDIR}/report.txt
cat ${GITHUB_WORKSPACE}/${WORKDIR}/report.txt

# Search for the complete testrun summary and extract total tests, total test passed, and total test failed data
grep -oE "COMPLETE TESTRUN SUMMARY\.\s+Total tests: [0-9]+" ${GITHUB_WORKSPACE}/${WORKDIR}/report.txt | sed -r "s/\x1B\[[0-9;]*[mGK]//g" > ${GITHUB_WORKSPACE}/${WORKDIR}/final_total_tests.out
grep -oE "COMPLETE TESTRUN SUMMARY\.\s+Total test passed: [0-9]+" ${GITHUB_WORKSPACE}/${WORKDIR}/report.txt | sed -r "s/\x1B\[[0-9;]*[mGK]//g" > ${GITHUB_WORKSPACE}/${WORKDIR}/final_total_passed.out
grep -oE "COMPLETE TESTRUN SUMMARY\.\s+Total test failed: [0-9]+" ${GITHUB_WORKSPACE}/${WORKDIR}/report.txt | sed -r "s/\x1B\[[0-9;]*[mGK]//g" > ${GITHUB_WORKSPACE}/${WORKDIR}/final_total_failed.out

# Combine the results into a single file and prepare output
cat ${GITHUB_WORKSPACE}/${WORKDIR}/final_total_tests.out ${GITHUB_WORKSPACE}/${WORKDIR}/final_total_passed.out ${GITHUB_WORKSPACE}/${WORKDIR}/final_total_failed.out > ${GITHUB_WORKSPACE}/${WORKDIR}/final.out
echo 'KEPLOY_REPORT<<EOF' > $GITHUB_OUTPUT
cat ${GITHUB_WORKSPACE}/${WORKDIR}/final.out >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
shell: bash
env:
WORKDIR: ${{ inputs.working-directory }}
DELAY: ${{ inputs.delay }}
COMMAND : ${{ inputs.command }}
KEPLOY_PATH: ${{inputs.keploy-path}}
- name: Check if report is generated
run: |
if [ -s ${GITHUB_WORKSPACE}/${WORKDIR}/final.out ]; then
echo "Report generated successfully."
else
echo "Error: Report not generated." >&2
exit 1
fi
shell: bash
- name: Comment on PR
if: success()
uses: actions/github-script@v6
env:
KEPLOY_REPORT: ${{ steps.keploy-test-report.outputs.KEPLOY_REPORT }}
with:
github-token: ${{ github.token }}
script: |
if (!process.env.KEPLOY_REPORT) {
console.error('Error: KEPLOY_REPORT not found.');
process.exit(1);
}
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: process.env.KEPLOY_REPORT
})
10 changes: 10 additions & 0 deletions dummy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const http = require('http');

const server = http.createServer((req, res) => {
res.write('Hello Keploy');
res.end();
});

server.listen(3000, () => {
console.log('Server running at http://localhost:3000/');
});
Loading