Skip to content

Commit

Permalink
adding support for act to run workflows locally
Browse files Browse the repository at this point in the history
  • Loading branch information
qododavid committed Jan 28, 2025
1 parent 719f33f commit 331b7f3
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 30 deletions.
53 changes: 28 additions & 25 deletions .github/actions/qodo-cover-pr/scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ REPORT_DIR="/tmp"
REPORT_PATH="$REPORT_DIR/report.txt"
MODIFIED_FILES_JSON="/tmp/modified-files.json"

DEBUG=${DEBUG:-false}
LOCAL=${LOCAL:-false}

while [[ "$#" -gt 0 ]]; do
case $1 in
Expand Down Expand Up @@ -48,8 +48,8 @@ if [ "$PROJECT_LANGUAGE" == "python" ]; then
fi
fi

# Skip git if in debug mode
if ["$DEBUG" = "false"]; then
# Skip git if in local mode
if ["$LOCAL" = "false"]; then
# Set up Git configuration
git config --global user.email "[email protected]"
git config --global user.name "Qodo Cover"
Expand Down Expand Up @@ -96,27 +96,30 @@ fi
--report-dir "$REPORT_DIR" \
--modified-files-json "$MODIFIED_FILES_JSON"

# Handle any changes made by cover-agent-pro
if [ -n "$(git status --porcelain)" ]; then
TIMESTAMP=$(date +%s)
BRANCH_NAME="qodo-cover-${PR_NUMBER}-${TIMESTAMP}"

if [ ! -f "$REPORT_PATH" ]; then
echo "Error: Report file not found at $REPORT_PATH"
exit 1
# Skip git if in local mode
if ["$LOCAL" = "false"]; then
# Handle any changes made by cover-agent-pro
if [ -n "$(git status --porcelain)" ]; then
TIMESTAMP=$(date +%s)
BRANCH_NAME="qodo-cover-${PR_NUMBER}-${TIMESTAMP}"

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 pr_number="$PR_NUMBER" -D report="$REPORT_TEXT")

git checkout -b "$BRANCH_NAME"
git add .
git commit -m "Add tests to improve coverage"
git push origin "$BRANCH_NAME"

gh pr create \
--base "$PR_REF" \
--head "$BRANCH_NAME" \
--title "Qodo Cover Update: ${TIMESTAMP}" \
--body "$PR_BODY"
fi

REPORT_TEXT=$(cat "$REPORT_PATH")
PR_BODY=$(jinja2 "$ACTION_PATH/templates/pr_body_template.j2" -D pr_number="$PR_NUMBER" -D report="$REPORT_TEXT")

git checkout -b "$BRANCH_NAME"
git add .
git commit -m "Add tests to improve coverage"
git push origin "$BRANCH_NAME"

gh pr create \
--base "$PR_REF" \
--head "$BRANCH_NAME" \
--title "Qodo Cover Update: ${TIMESTAMP}" \
--body "$PR_BODY"
fi
10 changes: 5 additions & 5 deletions .github/actions/qodo-cover/scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ BINARY_PATH="/tmp/bin/cover-agent-pro"
REPORT_DIR="/tmp"
REPORT_PATH="$REPORT_DIR/report.txt"

DEBUG=${DEBUG:-false}
LOCAL=${LOCAL:-false}

while [[ "$#" -gt 0 ]]; do
case $1 in
Expand Down Expand Up @@ -46,8 +46,8 @@ if [ "$PROJECT_LANGUAGE" == "python" ]; then
fi
fi

# Skip git if in debug mode
if ["$DEBUG" = "false"]; then
# Skip git if in local mode
if ["$LOCAL" = "false"]; then
# Set up Git configuration
git config --global user.email "[email protected]"
git config --global user.name "Qodo Cover"
Expand Down Expand Up @@ -79,8 +79,8 @@ fi
--run-each-test-separately "$RUN_EACH_TEST_SEPARATELY" \
--report-dir "$REPORT_DIR"

# Skip git if in debug mode
if ["$DEBUG" = "false"]; then
# Skip git if in local mode
if ["$LOCAL" = "false"]; then
# If new changes
if [ -n "$(git status --porcelain)" ]; then
TIMESTAMP=$(date +%s)
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
qodo-ci.md
sink-config.yaml
sink.tmpl

0 comments on commit 331b7f3

Please sign in to comment.