-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
disable git/gh ops if DEBUG env var is set
- Loading branch information
Showing
2 changed files
with
61 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ REPORT_DIR="/tmp" | |
REPORT_PATH="$REPORT_DIR/report.txt" | ||
MODIFIED_FILES_JSON="/tmp/modified-files.json" | ||
|
||
DEBUG=${DEBUG:-false} | ||
|
||
while [[ "$#" -gt 0 ]]; do | ||
case $1 in | ||
--pr-number) PR_NUMBER="$2"; shift ;; | ||
|
@@ -46,36 +48,39 @@ if [ "$PROJECT_LANGUAGE" == "python" ]; then | |
fi | ||
fi | ||
|
||
# Set up Git configuration | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Qodo Cover" | ||
|
||
# Download cover-agent-pro if not already downloaded | ||
if [ ! -f "$BINARY_PATH" ]; then | ||
echo "Downloading cover-agent-pro ${ACTION_REF}..." | ||
mkdir -p /tmp/bin | ||
wget -q -P /tmp/bin "https://github.com/qodo-ai/qodo-ci/releases/download/${ACTION_REF}/cover-agent-pro" >/dev/null | ||
chmod +x "$BINARY_PATH" | ||
fi | ||
# Skip git if in debug mode | ||
if ["$DEBUG" = "false"]; then | ||
# Set up Git configuration | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Qodo Cover" | ||
|
||
# Checkout the PR branch | ||
git fetch origin "$PR_REF" | ||
git checkout "$PR_REF" | ||
# Checkout the PR branch | ||
git fetch origin "$PR_REF" | ||
git checkout "$PR_REF" | ||
|
||
# Get the repository root | ||
REPO_ROOT=$(git rev-parse --show-toplevel) | ||
# Get the repository root | ||
REPO_ROOT=$(git rev-parse --show-toplevel) | ||
|
||
# Generate the modified files JSON using gh pr view, including only added or modified files | ||
echo "Generating modified files list..." | ||
gh pr view "$PR_NUMBER" --json files --jq '.files[].path' | \ | ||
jq -R -s 'split("\n")[:-1] | map("'"$REPO_ROOT"'/" + .)' > "$MODIFIED_FILES_JSON" | ||
# Generate the modified files JSON using gh pr view, including only added or modified files | ||
echo "Generating modified files list..." | ||
gh pr view "$PR_NUMBER" --json files --jq '.files[].path' | \ | ||
jq -R -s 'split("\n")[:-1] | map("'"$REPO_ROOT"'/" + .)' > "$MODIFIED_FILES_JSON" | ||
fi | ||
|
||
# Check if modified-files.json is empty | ||
if [ ! -s "$MODIFIED_FILES_JSON" ]; then | ||
echo "No added or modified files found in the PR. Exiting." | ||
exit 0 | ||
fi | ||
|
||
# Download cover-agent-pro if not already downloaded | ||
if [ ! -f "$BINARY_PATH" ]; then | ||
echo "Downloading cover-agent-pro ${ACTION_REF}..." | ||
mkdir -p /tmp/bin | ||
wget -q -P /tmp/bin "https://github.com/qodo-ai/qodo-ci/releases/download/${ACTION_REF}/cover-agent-pro" >/dev/null | ||
chmod +x "$BINARY_PATH" | ||
fi | ||
|
||
# Run cover-agent-pro in pr mode with the provided arguments | ||
"$BINARY_PATH" \ | ||
--mode "pr" \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ BINARY_PATH="/tmp/bin/cover-agent-pro" | |
REPORT_DIR="/tmp" | ||
REPORT_PATH="$REPORT_DIR/report.txt" | ||
|
||
DEBUG=${DEBUG:-false} | ||
|
||
while [[ "$#" -gt 0 ]]; do | ||
case $1 in | ||
--branch) BRANCH="$2"; shift ;; | ||
|
@@ -44,9 +46,16 @@ if [ "$PROJECT_LANGUAGE" == "python" ]; then | |
fi | ||
fi | ||
|
||
# Set up Git configuration | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Qodo Cover" | ||
# Skip git if in debug mode | ||
if ["$DEBUG" = "false"]; then | ||
# Set up Git configuration | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Qodo Cover" | ||
|
||
# Checkout the specified branch | ||
git fetch origin | ||
git checkout "$BRANCH" | ||
fi | ||
|
||
# Download cover-agent-pro if not already downloaded | ||
if [ ! -f "$BINARY_PATH" ]; then | ||
|
@@ -56,9 +65,6 @@ if [ ! -f "$BINARY_PATH" ]; then | |
chmod +x "$BINARY_PATH" | ||
fi | ||
|
||
# Checkout the specified branch | ||
git fetch origin | ||
git checkout "$BRANCH" | ||
|
||
# Run cover-agent-pro | ||
"$BINARY_PATH" \ | ||
|
@@ -73,27 +79,30 @@ git checkout "$BRANCH" | |
--run-each-test-separately "$RUN_EACH_TEST_SEPARATELY" \ | ||
--report-dir "$REPORT_DIR" | ||
|
||
# If new changes | ||
if [ -n "$(git status --porcelain)" ]; then | ||
TIMESTAMP=$(date +%s) | ||
BRANCH_NAME="qodo-ci-${BRANCH}-${TIMESTAMP}" | ||
# Skip git if in debug mode | ||
if ["$DEBUG" = "false"]; then | ||
# If new changes | ||
if [ -n "$(git status --porcelain)" ]; then | ||
TIMESTAMP=$(date +%s) | ||
BRANCH_NAME="qodo-ci-${BRANCH}-${TIMESTAMP}" | ||
|
||
if [ ! -f "$REPORT_PATH" ]; then | ||
echo "Error: Report file not found at $REPORT_PATH" | ||
exit 1 | ||
fi | ||
if [ ! -f "$REPORT_PATH" ]; then | ||
echo "Error: Report file not found at $REPORT_PATH" | ||
exit 1 | ||
fi | ||
|
||
REPORT_TEXT=$(cat "$REPORT_PATH") | ||
PR_BODY=$(jinja2 "$ACTION_PATH/templates/pr_body_template.j2" -D target_branch="$BRANCH" -D report="$REPORT_TEXT") | ||
|
||
REPORT_TEXT=$(cat "$REPORT_PATH") | ||
PR_BODY=$(jinja2 "$ACTION_PATH/templates/pr_body_template.j2" -D target_branch="$BRANCH" -D report="$REPORT_TEXT") | ||
|
||
git checkout -b "$BRANCH_NAME" | ||
git add . | ||
git commit -m "add tests" | ||
git push origin "$BRANCH_NAME" | ||
|
||
gh pr create \ | ||
--base "$BRANCH" \ | ||
--head "$BRANCH_NAME" \ | ||
--title "Qodo Cover Update: ${TIMESTAMP}" \ | ||
--body "$PR_BODY" | ||
git checkout -b "$BRANCH_NAME" | ||
git add . | ||
git commit -m "add tests" | ||
git push origin "$BRANCH_NAME" | ||
|
||
gh pr create \ | ||
--base "$BRANCH" \ | ||
--head "$BRANCH_NAME" \ | ||
--title "Qodo Cover Update: ${TIMESTAMP}" \ | ||
--body "$PR_BODY" | ||
fi | ||
fi |