From e441889f4172ef903e6177cbb945c7696deb5b42 Mon Sep 17 00:00:00 2001 From: ayu Date: Sun, 23 Mar 2025 13:03:26 +0530 Subject: [PATCH 01/31] feat: add PR linting, static analysis, and GitHub API integration Signed-off-by: ayu --- action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/action.yml b/action.yml index 4262137..9965bc3 100644 --- a/action.yml +++ b/action.yml @@ -69,6 +69,8 @@ runs: exit 1 fi shell: bash + + - name: Comment on PR if: success() uses: actions/github-script@v6 From 561f76aabe313f8bbe82fdcdc8793d8dc87555c4 Mon Sep 17 00:00:00 2001 From: ayu Date: Sun, 23 Mar 2025 13:20:00 +0530 Subject: [PATCH 02/31] test: trigger GitHub Action for linting Signed-off-by: ayu --- action.yml | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++--- dummy.js | 2 + 2 files changed, 113 insertions(+), 5 deletions(-) create mode 100644 dummy.js diff --git a/action.yml b/action.yml index 9965bc3..a5c5940 100644 --- a/action.yml +++ b/action.yml @@ -69,14 +69,120 @@ runs: exit 1 fi shell: bash + + -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; + result-encoding: json + +-name: Detect Programming Languages +id: lang-detect +run: | + echo "Detecting languages..." + files=$(echo '${{ steps.pr-details.outputs.result }}' | jq -r '.files[]') - - name: Comment on PR - if: success() - uses: actions/github-script@v6 - env: + 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 on PR + if: success() + uses: actions/github-script@v6 + env: KEPLOY_REPORT: ${{ steps.keploy-test-report.outputs.KEPLOY_REPORT }} - with: + with: github-token: ${{ github.token }} script: | if (!process.env.KEPLOY_REPORT) { diff --git a/dummy.js b/dummy.js new file mode 100644 index 0000000..44c2a0b --- /dev/null +++ b/dummy.js @@ -0,0 +1,2 @@ +// test dummy file +console.log("Hello TestGPT Lint"); \ No newline at end of file From 7c5f87b1d89a4d10cf7e86c8423ba8655742c4c4 Mon Sep 17 00:00:00 2001 From: ayu Date: Sun, 23 Mar 2025 13:27:50 +0530 Subject: [PATCH 03/31] test: trigger GitHub Action for linting Signed-off-by: ayu --- dummy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dummy.js b/dummy.js index 44c2a0b..d3e6382 100644 --- a/dummy.js +++ b/dummy.js @@ -1,2 +1,2 @@ // test dummy file -console.log("Hello TestGPT Lint"); \ No newline at end of file +console.log("Hi TestGPT Lint"); \ No newline at end of file From 7cfc47dfa18c9a0b7ebf2bd505b02658bc73cd6c Mon Sep 17 00:00:00 2001 From: ayu Date: Sun, 23 Mar 2025 13:29:56 +0530 Subject: [PATCH 04/31] test: trigger GitHub Action for linting Signed-off-by: ayu --- dummy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dummy.js b/dummy.js index d3e6382..021dad1 100644 --- a/dummy.js +++ b/dummy.js @@ -1,2 +1,2 @@ // test dummy file -console.log("Hi TestGPT Lint"); \ No newline at end of file +console.log("Hi Lint"); \ No newline at end of file From e34a49e1d1f2a11470719091534ec532377d7340 Mon Sep 17 00:00:00 2001 From: ayu Date: Sun, 23 Mar 2025 13:39:42 +0530 Subject: [PATCH 05/31] Add custom TestGPT workflow Signed-off-by: ayu --- .github/workflows/testGpt-workflow.yml | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/testGpt-workflow.yml diff --git a/.github/workflows/testGpt-workflow.yml b/.github/workflows/testGpt-workflow.yml new file mode 100644 index 0000000..eaa0014 --- /dev/null +++ b/.github/workflows/testGpt-workflow.yml @@ -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' From 049ee88502ccec98928c8f919f2fae4f3fd8c38f Mon Sep 17 00:00:00 2001 From: ayu Date: Sun, 23 Mar 2025 13:52:58 +0530 Subject: [PATCH 06/31] done Signed-off-by: ayu --- .github/workflows/testGpt-workflow.yml | 48 +++++++++++++------------- dummy.js | 2 +- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/.github/workflows/testGpt-workflow.yml b/.github/workflows/testGpt-workflow.yml index eaa0014..4d2a608 100644 --- a/.github/workflows/testGpt-workflow.yml +++ b/.github/workflows/testGpt-workflow.yml @@ -1,29 +1,29 @@ -name: Test TestGPT Lint + Static Analysis +# name: Test TestGPT Lint + Static Analysis -on: - pull_request: - types: [opened, synchronize, reopened] +# on: +# pull_request: +# types: [opened, synchronize, reopened] -jobs: - run-testgpt: - runs-on: ubuntu-latest +# jobs: +# run-testgpt: +# runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v2 +# 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!" +# # ๐Ÿ‘‡ 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' +# # 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' diff --git a/dummy.js b/dummy.js index 021dad1..1fe06f6 100644 --- a/dummy.js +++ b/dummy.js @@ -1,2 +1,2 @@ // test dummy file -console.log("Hi Lint"); \ No newline at end of file +console.log("Hi Lint test "); \ No newline at end of file From 963736ab71ecb2bf87ee38d848b6edc983668409 Mon Sep 17 00:00:00 2001 From: ayu Date: Sun, 23 Mar 2025 14:25:23 +0530 Subject: [PATCH 07/31] done Signed-off-by: ayu --- .github/workflows/CLA.yml | 2 +- dummy.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CLA.yml b/.github/workflows/CLA.yml index cd4e6bf..c4e47b6 100644 --- a/.github/workflows/CLA.yml +++ b/.github/workflows/CLA.yml @@ -15,7 +15,7 @@ jobs: 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') + 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 }}" diff --git a/dummy.js b/dummy.js index 1fe06f6..43aad04 100644 --- a/dummy.js +++ b/dummy.js @@ -1,2 +1,2 @@ // test dummy file -console.log("Hi Lint test "); \ No newline at end of file +console.log("Hi Lint "); \ No newline at end of file From 3104821c1017af68c33467ccdbd2c83e3961fa22 Mon Sep 17 00:00:00 2001 From: ayu Date: Sun, 23 Mar 2025 14:34:17 +0530 Subject: [PATCH 08/31] Disable CLA workflow in fork Signed-off-by: ayu --- .github/workflows/CLA.yml | 54 +++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/.github/workflows/CLA.yml b/.github/workflows/CLA.yml index c4e47b6..f5dd18e 100644 --- a/.github/workflows/CLA.yml +++ b/.github/workflows/CLA.yml @@ -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" \ No newline at end of file +# 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" \ No newline at end of file From b1feb67bf8ad0a965560a7b668b9256ae90784a9 Mon Sep 17 00:00:00 2001 From: ayu Date: Sun, 23 Mar 2025 15:00:44 +0530 Subject: [PATCH 09/31] done Signed-off-by: ayu --- .github/workflows/testGpt-workflow.yml | 48 +++++++++++++------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/.github/workflows/testGpt-workflow.yml b/.github/workflows/testGpt-workflow.yml index 4d2a608..eaa0014 100644 --- a/.github/workflows/testGpt-workflow.yml +++ b/.github/workflows/testGpt-workflow.yml @@ -1,29 +1,29 @@ -# name: Test TestGPT Lint + Static Analysis +name: Test TestGPT Lint + Static Analysis -# on: -# pull_request: -# types: [opened, synchronize, reopened] +on: + pull_request: + types: [opened, synchronize, reopened] -# jobs: -# run-testgpt: -# runs-on: ubuntu-latest +jobs: + run-testgpt: + runs-on: ubuntu-latest -# steps: -# - name: Checkout Code -# uses: actions/checkout@v2 + 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!" + # ๐Ÿ‘‡ 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' + # 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' From 294c35b182667dbff9df719526da1bb1ee9c9956 Mon Sep 17 00:00:00 2001 From: ayu Date: Sun, 23 Mar 2025 15:11:31 +0530 Subject: [PATCH 10/31] done Signed-off-by: ayu --- action.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index a5c5940..2a27538 100644 --- a/action.yml +++ b/action.yml @@ -70,7 +70,7 @@ runs: fi shell: bash - -name: Fetch PR Details + - name: Fetch PR Details id: pr-details uses: actions/github-script@v6 with: @@ -110,7 +110,7 @@ runs: result-encoding: json --name: Detect Programming Languages +- name: Detect Programming Languages id: lang-detect run: | echo "Detecting languages..." @@ -131,7 +131,7 @@ run: | cat languages.txt shell: bash --name: Lint Changed Files +- name: Lint Changed Files run: | echo "Running linters..." files=$(echo '${{ steps.pr-details.outputs.result }}' | jq -r '.files[]') @@ -154,7 +154,7 @@ run: | shell: bash --name: Comment Lint Results on PR +- name: Comment Lint Results on PR uses: actions/github-script@v6 with: github-token: ${{ github.token }} @@ -177,7 +177,7 @@ with: - -name: Comment on PR + - name: Comment on PR if: success() uses: actions/github-script@v6 env: From 7dba443ac26b31923822bd9a4c91da2002b0e447 Mon Sep 17 00:00:00 2001 From: ayu Date: Sun, 23 Mar 2025 15:19:46 +0530 Subject: [PATCH 11/31] d Signed-off-by: ayu --- .github/workflows/keploy-lint.yml | 135 ++++++++++++++++++++++++++++++ action.yml | 89 +------------------- 2 files changed, 137 insertions(+), 87 deletions(-) create mode 100644 .github/workflows/keploy-lint.yml diff --git a/.github/workflows/keploy-lint.yml b/.github/workflows/keploy-lint.yml new file mode 100644 index 0000000..21efbb7 --- /dev/null +++ b/.github/workflows/keploy-lint.yml @@ -0,0 +1,135 @@ +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 + uses: your-username/your-repo-name@main # Update this + with: + working-directory: ./ + command: 'your-start-command-here' + keploy-path: ./ + 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; + result-encoding: json + + - name: Detect Programming Languages + 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.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: report + }); diff --git a/action.yml b/action.yml index 2a27538..db3a13d 100644 --- a/action.yml +++ b/action.yml @@ -70,91 +70,8 @@ runs: fi shell: bash - - 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; - result-encoding: json - - -- name: Detect Programming Languages -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 + - name: Comment Lint Results on PR uses: actions/github-script@v6 with: github-token: ${{ github.token }} @@ -175,9 +92,7 @@ with: body: `### ๐Ÿงน Lint Report:\n\`\`\`\n${lintReport}\n\`\`\`` }); - - - - name: Comment on PR + - name: Comment on PR if: success() uses: actions/github-script@v6 env: From 70e8cd01c131df3081d9cd5a0a95d36e7ffa5f02 Mon Sep 17 00:00:00 2001 From: ayu Date: Sun, 23 Mar 2025 15:24:20 +0530 Subject: [PATCH 12/31] d Signed-off-by: ayu --- action.yml | 88 ++++++++++++++++-------------------------------------- 1 file changed, 25 insertions(+), 63 deletions(-) diff --git a/action.yml b/action.yml index db3a13d..7e8a74b 100644 --- a/action.yml +++ b/action.yml @@ -26,87 +26,49 @@ inputs: description: Time to wait for docker container build default: 50s +outputs: + KEPLOY_REPORT: + description: 'Summary report from Keploy tests' + value: ${{ steps.keploy-test-report.outputs.KEPLOY_REPORT }} + runs: using: "composite" steps: - name: Setup GITHUB_PATH for script run: | echo "${{ github.action_path }}" >> $GITHUB_PATH - echo "${{ inputs.working-directory }}" + echo "Working Directory: ${{ inputs.working-directory }}" shell: bash + - name: Grant permissions - run: chmod +x ${GITHUB_ACTION_PATH}/install.sh + 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 + name: Run Keploy Script and Generate Report + run: | + WORKDIR="${{ inputs.working-directory }}" + ${GITHUB_ACTION_PATH}/install.sh > "${GITHUB_WORKSPACE}/${WORKDIR}/report.txt" + cat "${GITHUB_WORKSPACE}/${WORKDIR}/report.txt" + + 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" - # 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 + 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" - # 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< $GITHUB_OUTPUT - cat ${GITHUB_WORKSPACE}/${WORKDIR}/final.out >> $GITHUB_OUTPUT - echo 'EOF' >> $GITHUB_OUTPUT - cat $GITHUB_OUTPUT + echo 'KEPLOY_REPORT<> $GITHUB_ENV + cat "${GITHUB_WORKSPACE}/${WORKDIR}/final.out" >> $GITHUB_ENV + echo 'EOF' >> $GITHUB_ENV 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 + WORKDIR="${{ inputs.working-directory }}" + 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 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 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 - }) From 876988aff7c663864e65f74b2762bf6c1394da6f Mon Sep 17 00:00:00 2001 From: ayu Date: Sun, 23 Mar 2025 15:33:50 +0530 Subject: [PATCH 13/31] done Signed-off-by: ayu --- .github/workflows/keploy-lint.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/keploy-lint.yml b/.github/workflows/keploy-lint.yml index 21efbb7..098378b 100644 --- a/.github/workflows/keploy-lint.yml +++ b/.github/workflows/keploy-lint.yml @@ -13,10 +13,11 @@ jobs: uses: actions/checkout@v3 - name: Run Keploy TestGPT Action - uses: your-username/your-repo-name@main # Update this + id: keploy-test-report + uses: AyushBurde/testGpt # Update this with: working-directory: ./ - command: 'your-start-command-here' + command: './myapp' keploy-path: ./ delay: 10 From 390650d0367378fb5ac1824e1ae41134afc15a61 Mon Sep 17 00:00:00 2001 From: ayu Date: Sun, 23 Mar 2025 15:45:57 +0530 Subject: [PATCH 14/31] done Signed-off-by: ayu --- .github/workflows/keploy-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/keploy-lint.yml b/.github/workflows/keploy-lint.yml index 098378b..de0aaf6 100644 --- a/.github/workflows/keploy-lint.yml +++ b/.github/workflows/keploy-lint.yml @@ -54,7 +54,7 @@ jobs: }; console.log("PR Metadata:", metadata); return metadata; - result-encoding: json + - name: Detect Programming Languages id: lang-detect From 66b233c6b857edd9eea668389a6429efe60e4149 Mon Sep 17 00:00:00 2001 From: ayu Date: Sun, 23 Mar 2025 23:51:54 +0530 Subject: [PATCH 15/31] d Signed-off-by: ayu --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index f998ddf..0032a34 100644 --- a/install.sh +++ b/install.sh @@ -55,6 +55,6 @@ elif [[ "$COMMAND" =~ .*"docker".* ]]; then sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" --buildDelay ${BUILD_DELAY} else - echo "Language not found" - echo 'Test Mode Shutting ๐ŸŽ‰' +echo "Language not found, but proceeding anyway." + fi \ No newline at end of file From 8310f2de46a33050b4035c51e45f128867400cdd Mon Sep 17 00:00:00 2001 From: ayu Date: Sun, 23 Mar 2025 23:55:50 +0530 Subject: [PATCH 16/31] f Signed-off-by: ayu --- install.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/install.sh b/install.sh index 0032a34..0aa554a 100644 --- a/install.sh +++ b/install.sh @@ -56,5 +56,3 @@ elif [[ "$COMMAND" =~ .*"docker".* ]]; then else echo "Language not found, but proceeding anyway." - -fi \ No newline at end of file From f08185abec971074b0844fc24db68bd94526930b Mon Sep 17 00:00:00 2001 From: ayu Date: Mon, 24 Mar 2025 00:06:17 +0530 Subject: [PATCH 17/31] done Signed-off-by: ayu --- install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/install.sh b/install.sh index 0aa554a..0032a34 100644 --- a/install.sh +++ b/install.sh @@ -56,3 +56,5 @@ elif [[ "$COMMAND" =~ .*"docker".* ]]; then else echo "Language not found, but proceeding anyway." + +fi \ No newline at end of file From e8020b406e28713cdb8888131026c35a5260536a Mon Sep 17 00:00:00 2001 From: ayu Date: Mon, 24 Mar 2025 00:21:35 +0530 Subject: [PATCH 18/31] d Signed-off-by: ayu --- .github/workflows/keploy-lint.yml | 2 +- install.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/keploy-lint.yml b/.github/workflows/keploy-lint.yml index de0aaf6..ec45434 100644 --- a/.github/workflows/keploy-lint.yml +++ b/.github/workflows/keploy-lint.yml @@ -17,7 +17,7 @@ jobs: uses: AyushBurde/testGpt # Update this with: working-directory: ./ - command: './myapp' + command: 'node dummy.js' keploy-path: ./ delay: 10 diff --git a/install.sh b/install.sh index 0032a34..ea86037 100644 --- a/install.sh +++ b/install.sh @@ -1,4 +1,5 @@ # Install Keploy binary using curl command +set -x curl --silent --location "https://github.com/keploy/keploy/releases/latest/download/keploy_linux_amd64.tar.gz" | tar xz -C /tmp echo "curl --silent --location 'https://github.com/keploy/keploy/releases/latest/download/keploy_linux_amd64.tar.gz' | tar xz -C /tmp" From cfbeb10e8305236a2720b9edbadcf0dd3b16ea32 Mon Sep 17 00:00:00 2001 From: ayu Date: Mon, 24 Mar 2025 00:25:31 +0530 Subject: [PATCH 19/31] d Signed-off-by: ayu --- .github/workflows/keploy-lint.yml | 2 +- .github/workflows/testGpt-workflow.yml | 48 +++++++++++++------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/.github/workflows/keploy-lint.yml b/.github/workflows/keploy-lint.yml index ec45434..7a8843f 100644 --- a/.github/workflows/keploy-lint.yml +++ b/.github/workflows/keploy-lint.yml @@ -14,7 +14,7 @@ jobs: - name: Run Keploy TestGPT Action id: keploy-test-report - uses: AyushBurde/testGpt # Update this + uses: AyushBurde/testGPT@main # Update this with: working-directory: ./ command: 'node dummy.js' diff --git a/.github/workflows/testGpt-workflow.yml b/.github/workflows/testGpt-workflow.yml index eaa0014..4d2a608 100644 --- a/.github/workflows/testGpt-workflow.yml +++ b/.github/workflows/testGpt-workflow.yml @@ -1,29 +1,29 @@ -name: Test TestGPT Lint + Static Analysis +# name: Test TestGPT Lint + Static Analysis -on: - pull_request: - types: [opened, synchronize, reopened] +# on: +# pull_request: +# types: [opened, synchronize, reopened] -jobs: - run-testgpt: - runs-on: ubuntu-latest +# jobs: +# run-testgpt: +# runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v2 +# 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!" +# # ๐Ÿ‘‡ 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' +# # 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' From a500ff67d6f39a480db59712e7f4f00d2dc85108 Mon Sep 17 00:00:00 2001 From: ayu Date: Mon, 24 Mar 2025 00:35:04 +0530 Subject: [PATCH 20/31] d Signed-off-by: ayu --- install.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/install.sh b/install.sh index ea86037..2c33762 100644 --- a/install.sh +++ b/install.sh @@ -18,6 +18,8 @@ if [[ "$COMMAND" =~ .*"go".* ]]; then echo "go is present." go mod download go build -o application + echo 'Record Mode Starting ๐ŸŽฅ' + sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" echo 'Test Mode Starting ๐ŸŽ‰' echo sudo -E keploy test -c "./application" --delay ${DELAY} --path "${KEPLOY_PATH}" sudo -E keploy test -c "./application" --delay ${DELAY} --path "${KEPLOY_PATH}" @@ -25,6 +27,8 @@ if [[ "$COMMAND" =~ .*"go".* ]]; then elif [[ "$COMMAND" =~ .*"node".* ]]; then echo "Node is present." npm install + echo 'Record Mode Starting ๐ŸŽฅ' +sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" echo 'Test Mode Starting ๐ŸŽ‰' echo sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" @@ -32,6 +36,8 @@ elif [[ "$COMMAND" =~ .*"node".* ]]; then elif [[ "$COMMAND" =~ .*"java".* ]] || [[ "$COMMAND" =~ .*"mvn".* ]]; then echo "Java is present." mvn clean install + echo 'Record Mode Starting ๐ŸŽฅ' +sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" echo 'Test Mode Starting ๐ŸŽ‰' echo sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" @@ -39,18 +45,24 @@ elif [[ "$COMMAND" =~ .*"java".* ]] || [[ "$COMMAND" =~ .*"mvn".* ]]; then elif [[ "$COMMAND" =~ .*"python".* ]] || [[ "$COMMAND" =~ .*"python3".* ]]; then echo "Python is present." pip install -r requirements.txt + echo 'Record Mode Starting ๐ŸŽฅ' +sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" echo 'Test Mode Starting ๐ŸŽ‰' echo sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" elif [[ "$COMMAND" =~ .*"docker-compose".* ]] || [[ "$COMMAND" =~ .*"docker compose".* ]]; then echo "Docker compose is present." + echo 'Record Mode Starting ๐ŸŽฅ' +sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" echo 'Test Mode Starting ๐ŸŽ‰' echo sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" --containerName "${CONTAINER_NAME}" --buildDelay ${BUILD_DELAY} sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" --containerName "${CONTAINER_NAME}" --buildDelay ${BUILD_DELAY} elif [[ "$COMMAND" =~ .*"docker".* ]]; then echo "Docker is present." + echo 'Record Mode Starting ๐ŸŽฅ' +sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" echo 'Test Mode Starting ๐ŸŽ‰' echo sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" --buildDelay ${BUILD_DELAY} sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" --buildDelay ${BUILD_DELAY} From fbb06efd81bf808df530f0d842a01e88dacc1faa Mon Sep 17 00:00:00 2001 From: ayu Date: Mon, 24 Mar 2025 00:43:31 +0530 Subject: [PATCH 21/31] Test: Updated dummy.js for Keploy testing Signed-off-by: ayu --- dummy.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dummy.js b/dummy.js index 43aad04..726c528 100644 --- a/dummy.js +++ b/dummy.js @@ -1,2 +1 @@ -// test dummy file -console.log("Hi Lint "); \ No newline at end of file +console.log("Hello from Dummy.js โ€” Testing Keploy!"); From d72ae44839f9e3ac4953022e92a1af52584ef0fd Mon Sep 17 00:00:00 2001 From: ayu Date: Mon, 24 Mar 2025 00:55:22 +0530 Subject: [PATCH 22/31] fd Signed-off-by: ayu --- dummy.js | 11 ++++++++++- install.sh | 12 ++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/dummy.js b/dummy.js index 726c528..be7e028 100644 --- a/dummy.js +++ b/dummy.js @@ -1 +1,10 @@ -console.log("Hello from Dummy.js โ€” Testing Keploy!"); +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/'); +}); diff --git a/install.sh b/install.sh index 2c33762..9fcddbe 100644 --- a/install.sh +++ b/install.sh @@ -18,6 +18,8 @@ if [[ "$COMMAND" =~ .*"go".* ]]; then echo "go is present." go mod download go build -o application + sleep 3 + curl 127.0.0.1:3000 echo 'Record Mode Starting ๐ŸŽฅ' sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" echo 'Test Mode Starting ๐ŸŽ‰' @@ -27,6 +29,8 @@ if [[ "$COMMAND" =~ .*"go".* ]]; then elif [[ "$COMMAND" =~ .*"node".* ]]; then echo "Node is present." npm install + sleep 3 + curl 127.0.0.1:3000 echo 'Record Mode Starting ๐ŸŽฅ' sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" echo 'Test Mode Starting ๐ŸŽ‰' @@ -36,6 +40,8 @@ sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" elif [[ "$COMMAND" =~ .*"java".* ]] || [[ "$COMMAND" =~ .*"mvn".* ]]; then echo "Java is present." mvn clean install + sleep 3 + curl 127.0.0.1:3000 echo 'Record Mode Starting ๐ŸŽฅ' sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" echo 'Test Mode Starting ๐ŸŽ‰' @@ -45,6 +51,8 @@ sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" elif [[ "$COMMAND" =~ .*"python".* ]] || [[ "$COMMAND" =~ .*"python3".* ]]; then echo "Python is present." pip install -r requirements.txt + sleep 3 + curl 127.0.0.1:3000 echo 'Record Mode Starting ๐ŸŽฅ' sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" echo 'Test Mode Starting ๐ŸŽ‰' @@ -53,6 +61,8 @@ sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" elif [[ "$COMMAND" =~ .*"docker-compose".* ]] || [[ "$COMMAND" =~ .*"docker compose".* ]]; then echo "Docker compose is present." + sleep 3 + curl 127.0.0.1:3000 echo 'Record Mode Starting ๐ŸŽฅ' sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" echo 'Test Mode Starting ๐ŸŽ‰' @@ -61,6 +71,8 @@ sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" elif [[ "$COMMAND" =~ .*"docker".* ]]; then echo "Docker is present." + sleep 3 + curl 127.0.0.1:3000 echo 'Record Mode Starting ๐ŸŽฅ' sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" echo 'Test Mode Starting ๐ŸŽ‰' From e5eeef8640d76cd94dc5ada64045ccbc2855a9d1 Mon Sep 17 00:00:00 2001 From: ayu Date: Mon, 24 Mar 2025 01:10:41 +0530 Subject: [PATCH 23/31] Added keploy record before test Signed-off-by: ayu --- install.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/install.sh b/install.sh index 9fcddbe..a71866c 100644 --- a/install.sh +++ b/install.sh @@ -18,6 +18,8 @@ if [[ "$COMMAND" =~ .*"go".* ]]; then echo "go is present." go mod download go build -o application + echo "Starting Server in Background" + ${COMMAND} & # this runs `node dummy.js` in the background sleep 3 curl 127.0.0.1:3000 echo 'Record Mode Starting ๐ŸŽฅ' @@ -29,6 +31,7 @@ if [[ "$COMMAND" =~ .*"go".* ]]; then elif [[ "$COMMAND" =~ .*"node".* ]]; then echo "Node is present." npm install + ${COMMAND} & sleep 3 curl 127.0.0.1:3000 echo 'Record Mode Starting ๐ŸŽฅ' @@ -40,6 +43,7 @@ sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" elif [[ "$COMMAND" =~ .*"java".* ]] || [[ "$COMMAND" =~ .*"mvn".* ]]; then echo "Java is present." mvn clean install + ${COMMAND} & sleep 3 curl 127.0.0.1:3000 echo 'Record Mode Starting ๐ŸŽฅ' @@ -51,6 +55,7 @@ sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" elif [[ "$COMMAND" =~ .*"python".* ]] || [[ "$COMMAND" =~ .*"python3".* ]]; then echo "Python is present." pip install -r requirements.txt + ${COMMAND} & sleep 3 curl 127.0.0.1:3000 echo 'Record Mode Starting ๐ŸŽฅ' @@ -61,6 +66,7 @@ sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" elif [[ "$COMMAND" =~ .*"docker-compose".* ]] || [[ "$COMMAND" =~ .*"docker compose".* ]]; then echo "Docker compose is present." + ${COMMAND} & sleep 3 curl 127.0.0.1:3000 echo 'Record Mode Starting ๐ŸŽฅ' @@ -71,6 +77,7 @@ sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" elif [[ "$COMMAND" =~ .*"docker".* ]]; then echo "Docker is present." + ${COMMAND} & sleep 3 curl 127.0.0.1:3000 echo 'Record Mode Starting ๐ŸŽฅ' From 55c367aff30813c3c5aff90e6e8b3995524d8eba Mon Sep 17 00:00:00 2001 From: ayu Date: Mon, 24 Mar 2025 13:04:51 +0530 Subject: [PATCH 24/31] done Signed-off-by: ayu --- .github/workflows/keploy-lint.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/keploy-lint.yml b/.github/workflows/keploy-lint.yml index 7a8843f..6d9530b 100644 --- a/.github/workflows/keploy-lint.yml +++ b/.github/workflows/keploy-lint.yml @@ -53,7 +53,11 @@ jobs: files: filePaths }; console.log("PR Metadata:", metadata); + return metadata; + result-encoding: string + outputs: + result: ${{ steps.pr-details.outputs.result }} - name: Detect Programming Languages @@ -129,8 +133,10 @@ jobs: return; } github.rest.issues.createComment({ - issue_number: context.issue.number, + issue_number: context.payload.pull_request.number, owner: context.repo.owner, repo: context.repo.repo, body: report }); + - name: Debug Context + run: echo "${{ toJson(github) }}" From 7a23c3434adf45d3ce277b249423b6b102347845 Mon Sep 17 00:00:00 2001 From: ayu Date: Mon, 24 Mar 2025 13:07:39 +0530 Subject: [PATCH 25/31] done Signed-off-by: ayu --- .github/workflows/keploy-lint.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/keploy-lint.yml b/.github/workflows/keploy-lint.yml index 6d9530b..519594c 100644 --- a/.github/workflows/keploy-lint.yml +++ b/.github/workflows/keploy-lint.yml @@ -55,9 +55,7 @@ jobs: console.log("PR Metadata:", metadata); return metadata; - result-encoding: string - outputs: - result: ${{ steps.pr-details.outputs.result }} + - name: Detect Programming Languages From 8d1fb27f9b20e000d71f19ad246affce5f6e4ddb Mon Sep 17 00:00:00 2001 From: ayu Date: Mon, 24 Mar 2025 13:13:34 +0530 Subject: [PATCH 26/31] d Signed-off-by: ayu --- dummy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dummy.js b/dummy.js index be7e028..cadf7a3 100644 --- a/dummy.js +++ b/dummy.js @@ -1,7 +1,7 @@ const http = require('http'); const server = http.createServer((req, res) => { - res.write('Hello Keploy!'); + res.write('Hello Keploy'); res.end(); }); From f6d1e033ca9128ab9da2ed1e041378d2bc33d582 Mon Sep 17 00:00:00 2001 From: ayu Date: Mon, 24 Mar 2025 13:18:51 +0530 Subject: [PATCH 27/31] done Signed-off-by: ayu --- install.sh | 137 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 93 insertions(+), 44 deletions(-) diff --git a/install.sh b/install.sh index a71866c..5a0e2f5 100644 --- a/install.sh +++ b/install.sh @@ -1,92 +1,141 @@ -# Install Keploy binary using curl command -set -x -curl --silent --location "https://github.com/keploy/keploy/releases/latest/download/keploy_linux_amd64.tar.gz" | tar xz -C /tmp -echo "curl --silent --location 'https://github.com/keploy/keploy/releases/latest/download/keploy_linux_amd64.tar.gz' | tar xz -C /tmp" +#!/bin/bash + +set -x # Debug mode +set -e # Exit on any command failure +# Install Keploy binary +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 - echo "Keploy installed successfully ๐ŸŽ‰" -cd ${GITHUB_WORKSPACE}/${WORKDIR} -echo "${GITHUB_WORKSPACE}/${WORKDIR}" -# Generate app binary -echo "ls" +# Validate required environment variables +if [ -z "$COMMAND" ]; then + echo "Error: COMMAND is not set." >&2 + exit 1 +fi + +if [ -z "$DELAY" ]; then + echo "Error: DELAY is not set." >&2 + exit 1 +fi + +if [ -z "$KEPLOY_PATH" ]; then + echo "Error: KEPLOY_PATH is not set." >&2 + exit 1 +fi + +if [ -z "$WORKDIR" ]; then + echo "Error: WORKDIR is not set." >&2 + exit 1 +fi + +APP_PORT=${APP_PORT:-3000} # Default to port 3000 if not set + +cd "${GITHUB_WORKSPACE}/${WORKDIR}" +echo "Working Directory: ${GITHUB_WORKSPACE}/${WORKDIR}" ls +# Function to check if the application is running +check_application_running() { + curl http://127.0.0.1:$APP_PORT || { + echo "Error: Application is not running on port $APP_PORT." >&2 + exit 1 + } +} + +# Function to check if test cases were recorded +check_test_cases_recorded() { + if [ ! -d "${KEPLOY_PATH}" ] || [ -z "$(ls -A "${KEPLOY_PATH}")" ]; then + echo "Error: No test cases found in ${KEPLOY_PATH}. Please ensure test cases are recorded." >&2 + exit 1 + fi +} + if [[ "$COMMAND" =~ .*"go".* ]]; then - echo "go is present." + echo "Go is present." go mod download go build -o application - echo "Starting Server in Background" - ${COMMAND} & # this runs `node dummy.js` in the background - sleep 3 - curl 127.0.0.1:3000 + echo "Starting Server in Background" + ${COMMAND} & + APP_PID=$! + trap "kill $APP_PID" EXIT + sleep 3 + check_application_running echo 'Record Mode Starting ๐ŸŽฅ' sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" + check_test_cases_recorded echo 'Test Mode Starting ๐ŸŽ‰' - echo sudo -E keploy test -c "./application" --delay ${DELAY} --path "${KEPLOY_PATH}" sudo -E keploy test -c "./application" --delay ${DELAY} --path "${KEPLOY_PATH}" elif [[ "$COMMAND" =~ .*"node".* ]]; then echo "Node is present." npm install - ${COMMAND} & - sleep 3 - curl 127.0.0.1:3000 + ${COMMAND} & + APP_PID=$! + trap "kill $APP_PID" EXIT + sleep 3 + check_application_running echo 'Record Mode Starting ๐ŸŽฅ' -sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" + sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" + check_test_cases_recorded echo 'Test Mode Starting ๐ŸŽ‰' - echo sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" -elif [[ "$COMMAND" =~ .*"java".* ]] || [[ "$COMMAND" =~ .*"mvn".* ]]; then +elif [[ "$COMMAND" =~ .*"java".* ]] || [[ "$COMMAND" =~ .*"mvn".* ]]; then echo "Java is present." mvn clean install - ${COMMAND} & - sleep 3 - curl 127.0.0.1:3000 + ${COMMAND} & + APP_PID=$! + trap "kill $APP_PID" EXIT + sleep 3 + check_application_running echo 'Record Mode Starting ๐ŸŽฅ' -sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" + sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" + check_test_cases_recorded echo 'Test Mode Starting ๐ŸŽ‰' - echo sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" elif [[ "$COMMAND" =~ .*"python".* ]] || [[ "$COMMAND" =~ .*"python3".* ]]; then echo "Python is present." pip install -r requirements.txt - ${COMMAND} & - sleep 3 - curl 127.0.0.1:3000 + ${COMMAND} & + APP_PID=$! + trap "kill $APP_PID" EXIT + sleep 3 + check_application_running echo 'Record Mode Starting ๐ŸŽฅ' -sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" + sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" + check_test_cases_recorded echo 'Test Mode Starting ๐ŸŽ‰' - echo sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" elif [[ "$COMMAND" =~ .*"docker-compose".* ]] || [[ "$COMMAND" =~ .*"docker compose".* ]]; then - echo "Docker compose is present." - ${COMMAND} & - sleep 3 - curl 127.0.0.1:3000 + echo "Docker Compose is present." + ${COMMAND} & + APP_PID=$! + trap "kill $APP_PID" EXIT + sleep 3 + check_application_running echo 'Record Mode Starting ๐ŸŽฅ' -sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" + sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" + check_test_cases_recorded echo 'Test Mode Starting ๐ŸŽ‰' - echo sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" --containerName "${CONTAINER_NAME}" --buildDelay ${BUILD_DELAY} sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" --containerName "${CONTAINER_NAME}" --buildDelay ${BUILD_DELAY} elif [[ "$COMMAND" =~ .*"docker".* ]]; then echo "Docker is present." - ${COMMAND} & - sleep 3 - curl 127.0.0.1:3000 + ${COMMAND} & + APP_PID=$! + trap "kill $APP_PID" EXIT + sleep 3 + check_application_running echo 'Record Mode Starting ๐ŸŽฅ' -sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" + sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" + check_test_cases_recorded echo 'Test Mode Starting ๐ŸŽ‰' - echo sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" --buildDelay ${BUILD_DELAY} sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" --buildDelay ${BUILD_DELAY} else -echo "Language not found, but proceeding anyway." - + echo "Language not found, but proceeding anyway." fi \ No newline at end of file From c74622a781cc3bd3015e14bf6fd6d1530c862f2e Mon Sep 17 00:00:00 2001 From: ayu Date: Mon, 24 Mar 2025 13:34:30 +0530 Subject: [PATCH 28/31] d Signed-off-by: ayu --- install.sh | 119 +++++++++-------------------------------------------- 1 file changed, 19 insertions(+), 100 deletions(-) diff --git a/install.sh b/install.sh index 5a0e2f5..f998ddf 100644 --- a/install.sh +++ b/install.sh @@ -1,141 +1,60 @@ -#!/bin/bash - -set -x # Debug mode -set -e # Exit on any command failure - -# Install Keploy binary +# Install Keploy binary using curl command curl --silent --location "https://github.com/keploy/keploy/releases/latest/download/keploy_linux_amd64.tar.gz" | tar xz -C /tmp +echo "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 -echo "Keploy installed successfully ๐ŸŽ‰" - -# Validate required environment variables -if [ -z "$COMMAND" ]; then - echo "Error: COMMAND is not set." >&2 - exit 1 -fi - -if [ -z "$DELAY" ]; then - echo "Error: DELAY is not set." >&2 - exit 1 -fi -if [ -z "$KEPLOY_PATH" ]; then - echo "Error: KEPLOY_PATH is not set." >&2 - exit 1 -fi - -if [ -z "$WORKDIR" ]; then - echo "Error: WORKDIR is not set." >&2 - exit 1 -fi - -APP_PORT=${APP_PORT:-3000} # Default to port 3000 if not set +echo "Keploy installed successfully ๐ŸŽ‰" -cd "${GITHUB_WORKSPACE}/${WORKDIR}" -echo "Working Directory: ${GITHUB_WORKSPACE}/${WORKDIR}" +cd ${GITHUB_WORKSPACE}/${WORKDIR} +echo "${GITHUB_WORKSPACE}/${WORKDIR}" +# Generate app binary +echo "ls" ls -# Function to check if the application is running -check_application_running() { - curl http://127.0.0.1:$APP_PORT || { - echo "Error: Application is not running on port $APP_PORT." >&2 - exit 1 - } -} - -# Function to check if test cases were recorded -check_test_cases_recorded() { - if [ ! -d "${KEPLOY_PATH}" ] || [ -z "$(ls -A "${KEPLOY_PATH}")" ]; then - echo "Error: No test cases found in ${KEPLOY_PATH}. Please ensure test cases are recorded." >&2 - exit 1 - fi -} - if [[ "$COMMAND" =~ .*"go".* ]]; then - echo "Go is present." + echo "go is present." go mod download go build -o application - echo "Starting Server in Background" - ${COMMAND} & - APP_PID=$! - trap "kill $APP_PID" EXIT - sleep 3 - check_application_running - echo 'Record Mode Starting ๐ŸŽฅ' - sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" - check_test_cases_recorded echo 'Test Mode Starting ๐ŸŽ‰' + echo sudo -E keploy test -c "./application" --delay ${DELAY} --path "${KEPLOY_PATH}" sudo -E keploy test -c "./application" --delay ${DELAY} --path "${KEPLOY_PATH}" elif [[ "$COMMAND" =~ .*"node".* ]]; then echo "Node is present." npm install - ${COMMAND} & - APP_PID=$! - trap "kill $APP_PID" EXIT - sleep 3 - check_application_running - echo 'Record Mode Starting ๐ŸŽฅ' - sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" - check_test_cases_recorded echo 'Test Mode Starting ๐ŸŽ‰' + echo sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" -elif [[ "$COMMAND" =~ .*"java".* ]] || [[ "$COMMAND" =~ .*"mvn".* ]]; then +elif [[ "$COMMAND" =~ .*"java".* ]] || [[ "$COMMAND" =~ .*"mvn".* ]]; then echo "Java is present." mvn clean install - ${COMMAND} & - APP_PID=$! - trap "kill $APP_PID" EXIT - sleep 3 - check_application_running - echo 'Record Mode Starting ๐ŸŽฅ' - sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" - check_test_cases_recorded echo 'Test Mode Starting ๐ŸŽ‰' + echo sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" elif [[ "$COMMAND" =~ .*"python".* ]] || [[ "$COMMAND" =~ .*"python3".* ]]; then echo "Python is present." pip install -r requirements.txt - ${COMMAND} & - APP_PID=$! - trap "kill $APP_PID" EXIT - sleep 3 - check_application_running - echo 'Record Mode Starting ๐ŸŽฅ' - sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" - check_test_cases_recorded echo 'Test Mode Starting ๐ŸŽ‰' + echo sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" elif [[ "$COMMAND" =~ .*"docker-compose".* ]] || [[ "$COMMAND" =~ .*"docker compose".* ]]; then - echo "Docker Compose is present." - ${COMMAND} & - APP_PID=$! - trap "kill $APP_PID" EXIT - sleep 3 - check_application_running - echo 'Record Mode Starting ๐ŸŽฅ' - sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" - check_test_cases_recorded + echo "Docker compose is present." echo 'Test Mode Starting ๐ŸŽ‰' + echo sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" --containerName "${CONTAINER_NAME}" --buildDelay ${BUILD_DELAY} sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" --containerName "${CONTAINER_NAME}" --buildDelay ${BUILD_DELAY} elif [[ "$COMMAND" =~ .*"docker".* ]]; then echo "Docker is present." - ${COMMAND} & - APP_PID=$! - trap "kill $APP_PID" EXIT - sleep 3 - check_application_running - echo 'Record Mode Starting ๐ŸŽฅ' - sudo -E keploy record -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" - check_test_cases_recorded echo 'Test Mode Starting ๐ŸŽ‰' + echo sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" --buildDelay ${BUILD_DELAY} sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" --buildDelay ${BUILD_DELAY} else - echo "Language not found, but proceeding anyway." + echo "Language not found" + echo 'Test Mode Shutting ๐ŸŽ‰' fi \ No newline at end of file From e1a8867fcbf7b0675df7dc0733287902dc89cd3c Mon Sep 17 00:00:00 2001 From: ayu Date: Mon, 24 Mar 2025 13:41:08 +0530 Subject: [PATCH 29/31] d Signed-off-by: ayu --- install.sh | 98 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 60 insertions(+), 38 deletions(-) diff --git a/install.sh b/install.sh index f998ddf..3f6ef7b 100644 --- a/install.sh +++ b/install.sh @@ -1,60 +1,82 @@ -# Install Keploy binary using curl command -curl --silent --location "https://github.com/keploy/keploy/releases/latest/download/keploy_linux_amd64.tar.gz" | tar xz -C /tmp -echo "curl --silent --location 'https://github.com/keploy/keploy/releases/latest/download/keploy_linux_amd64.tar.gz' | tar xz -C /tmp" +#!/bin/bash + +set -x +set -e +# Install Keploy +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 - echo "Keploy installed successfully ๐ŸŽ‰" -cd ${GITHUB_WORKSPACE}/${WORKDIR} -echo "${GITHUB_WORKSPACE}/${WORKDIR}" -# Generate app binary -echo "ls" +cd "${GITHUB_WORKSPACE}/${WORKDIR}" +echo "Working Directory: ${GITHUB_WORKSPACE}/${WORKDIR}" ls +# Install dependencies and build app if [[ "$COMMAND" =~ .*"go".* ]]; then - echo "go is present." + echo "Go detected." go mod download go build -o application - echo 'Test Mode Starting ๐ŸŽ‰' - echo sudo -E keploy test -c "./application" --delay ${DELAY} --path "${KEPLOY_PATH}" - sudo -E keploy test -c "./application" --delay ${DELAY} --path "${KEPLOY_PATH}" + APP_COMMAND="./application" elif [[ "$COMMAND" =~ .*"node".* ]]; then - echo "Node is present." + echo "Node detected." npm install - echo 'Test Mode Starting ๐ŸŽ‰' - echo sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" - sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" + APP_COMMAND="${COMMAND}" -elif [[ "$COMMAND" =~ .*"java".* ]] || [[ "$COMMAND" =~ .*"mvn".* ]]; then - echo "Java is present." +elif [[ "$COMMAND" =~ .*"java".* ]] || [[ "$COMMAND" =~ .*"mvn".* ]]; then + echo "Java detected." mvn clean install - echo 'Test Mode Starting ๐ŸŽ‰' - echo sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" - sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" + APP_COMMAND="${COMMAND}" elif [[ "$COMMAND" =~ .*"python".* ]] || [[ "$COMMAND" =~ .*"python3".* ]]; then - echo "Python is present." + echo "Python detected." pip install -r requirements.txt - echo 'Test Mode Starting ๐ŸŽ‰' - echo sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" - sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" + APP_COMMAND="${COMMAND}" -elif [[ "$COMMAND" =~ .*"docker-compose".* ]] || [[ "$COMMAND" =~ .*"docker compose".* ]]; then - echo "Docker compose is present." +else + echo "Unsupported language or Docker required. Skipping record." echo 'Test Mode Starting ๐ŸŽ‰' - echo sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" --containerName "${CONTAINER_NAME}" --buildDelay ${BUILD_DELAY} - sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" --containerName "${CONTAINER_NAME}" --buildDelay ${BUILD_DELAY} + sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" \ + ${CONTAINER_NAME:+--containerName "${CONTAINER_NAME}"} \ + ${BUILD_DELAY:+--buildDelay ${BUILD_DELAY}} + exit 0 +fi -elif [[ "$COMMAND" =~ .*"docker".* ]]; then - echo "Docker is present." - echo 'Test Mode Starting ๐ŸŽ‰' - echo sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" --buildDelay ${BUILD_DELAY} - sudo -E keploy test -c "${COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" --buildDelay ${BUILD_DELAY} +# Start app in background +${APP_COMMAND} & +APP_PID=$! +trap "kill $APP_PID" EXIT +sleep 3 -else - echo "Language not found" - echo 'Test Mode Shutting ๐ŸŽ‰' -fi \ No newline at end of file +# Check if app is running +curl http://127.0.0.1:${APP_PORT:-3000} || { + echo "App not responding on port ${APP_PORT:-3000}." + kill $APP_PID + exit 1 +} + +# Record with Keploy +echo "Recording testcases with Keploy ๐ŸŽฅ" +sudo -E keploy record -c "${APP_COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" > keploy_record.log 2>&1 & +RECORD_PID=$! +sleep 5 + +# Send requests during recording +for i in {1..3}; do + curl http://127.0.0.1:${APP_PORT:-3000} || echo "Request $i failed" + sleep 1 +done + +wait $RECORD_PID + +# Check if test-sets are recorded +if [ ! -d "${KEPLOY_PATH}" ] || [ -z "$(ls -A "${KEPLOY_PATH}")" ]; then + echo " No test-sets found in ${KEPLOY_PATH}. Recording failed." + exit 1 +fi + +# Test with Keploy +echo "Running tests with Keploy ๐ŸŽฏ" +sudo -E keploy test -c "${APP_COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" From b523f6c42079f7211852d05f656743c3a242f9a9 Mon Sep 17 00:00:00 2001 From: ayu Date: Mon, 24 Mar 2025 13:51:00 +0530 Subject: [PATCH 30/31] d Signed-off-by: ayu --- install.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 3f6ef7b..bb6595a 100644 --- a/install.sh +++ b/install.sh @@ -71,9 +71,24 @@ done wait $RECORD_PID -# Check if test-sets are recorded +# Retry recording if no test-sets are found if [ ! -d "${KEPLOY_PATH}" ] || [ -z "$(ls -A "${KEPLOY_PATH}")" ]; then - echo " No test-sets found in ${KEPLOY_PATH}. Recording failed." + echo "No test-sets found in ${KEPLOY_PATH}. Retrying recording..." + sudo -E keploy record -c "${APP_COMMAND}" --delay ${DELAY} --path "${KEPLOY_PATH}" > keploy_record_retry.log 2>&1 & + RECORD_PID=$! + sleep 5 + + for i in {1..3}; do + curl http://127.0.0.1:${APP_PORT:-3000} || echo "Retry request $i failed" + sleep 1 + end + + wait $RECORD_PID +fi + +# Final check if test-sets are recorded +if [ ! -d "${KEPLOY_PATH}" ] || [ -z "$(ls -A "${KEPLOY_PATH}")" ]; then + echo "No test-sets found in ${KEPLOY_PATH} after retry. Recording failed." exit 1 fi From 7197e986bcfbe483e6c31ccdf44e3a50e434506b Mon Sep 17 00:00:00 2001 From: ayu Date: Mon, 24 Mar 2025 14:49:37 +0530 Subject: [PATCH 31/31] d Signed-off-by: ayu --- .github/workflows/keploy-lint.yml | 8 ++-- action.yml | 74 ------------------------------- 2 files changed, 4 insertions(+), 78 deletions(-) diff --git a/.github/workflows/keploy-lint.yml b/.github/workflows/keploy-lint.yml index 519594c..175e515 100644 --- a/.github/workflows/keploy-lint.yml +++ b/.github/workflows/keploy-lint.yml @@ -14,11 +14,11 @@ jobs: - name: Run Keploy TestGPT Action id: keploy-test-report - uses: AyushBurde/testGPT@main # Update this + uses: keploy/testGPT@main with: - working-directory: ./ - command: 'node dummy.js' - keploy-path: ./ + working-directory: ./ # Adjust if project structure differs + command: 'your-test-command-here' # Update this + keploy-path: ./ # Path where Keploy binary is installed delay: 10 diff --git a/action.yml b/action.yml index 7e8a74b..e69de29 100644 --- a/action.yml +++ b/action.yml @@ -1,74 +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 - -outputs: - KEPLOY_REPORT: - description: 'Summary report from Keploy tests' - value: ${{ steps.keploy-test-report.outputs.KEPLOY_REPORT }} - -runs: - using: "composite" - steps: - - name: Setup GITHUB_PATH for script - run: | - echo "${{ github.action_path }}" >> $GITHUB_PATH - echo "Working Directory: ${{ inputs.working-directory }}" - shell: bash - - - name: Grant permissions - run: chmod +x "${{ github.action_path }}/install.sh" - shell: bash - - - id: keploy-test-report - name: Run Keploy Script and Generate Report - run: | - WORKDIR="${{ inputs.working-directory }}" - ${GITHUB_ACTION_PATH}/install.sh > "${GITHUB_WORKSPACE}/${WORKDIR}/report.txt" - cat "${GITHUB_WORKSPACE}/${WORKDIR}/report.txt" - - 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" - - 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<> $GITHUB_ENV - cat "${GITHUB_WORKSPACE}/${WORKDIR}/final.out" >> $GITHUB_ENV - echo 'EOF' >> $GITHUB_ENV - shell: bash - - - name: Check if report is generated - run: | - WORKDIR="${{ inputs.working-directory }}" - if [ -s "${GITHUB_WORKSPACE}/${WORKDIR}/final.out" ]; then - echo "Report generated successfully." - else - echo "Error: Report not generated." >&2 - exit 1 - fi - shell: bash