Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
43 changes: 43 additions & 0 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CI Tests

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

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

jobs:
test-with-summary:
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Run `poe test-with-summary` [Poe Command Processor]
uses: ./
with:
pr: ${{ github.event.pull_request.number }}
github-token: ${{ secrets.GITHUB_TOKEN }}
command: test-with-summary

test-without-summary:
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Run `poe test-without-summary` [Poe Command Processor]
uses: ./
with:
pr: ${{ github.event.pull_request.number }}
github-token: ${{ secrets.GITHUB_TOKEN }}
command: test-without-summary
54 changes: 51 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ runs:
echo "Resolved command: ${command}"
echo command="$command" >> $GITHUB_OUTPUT

- name: Create temp file for task output
id: create-temp-file
shell: bash
run: |
TEMP_FILE=$(mktemp)
echo "summary_file=$TEMP_FILE" >> $GITHUB_OUTPUT
echo "POE_SUMMARY_FILE=$TEMP_FILE" >> $GITHUB_ENV
echo "Created temporary file for task output: $TEMP_FILE"

- name: Get PR info
if: inputs.pr
id: pr-info
Expand Down Expand Up @@ -193,6 +202,31 @@ runs:
echo "------------------------------------"
echo "------------------------------------"

- name: Read task output from step summary
id: read-summary
if: always()
shell: bash
run: |
SUMMARY_FILE="${POE_SUMMARY_FILE:-$GITHUB_STEP_SUMMARY}"
if [ -f "$SUMMARY_FILE" ] && [ -s "$SUMMARY_FILE" ]; then
echo "Step summary file exists and is non-empty: $SUMMARY_FILE"
# Use multiline output syntax for GitHub Actions
{
echo "content<<EOF"
cat "$SUMMARY_FILE"
echo "EOF"
} >> $GITHUB_OUTPUT
echo "has_content=true" >> $GITHUB_OUTPUT

# Also write to GITHUB_STEP_SUMMARY for job summary visibility
if [ -n "$GITHUB_STEP_SUMMARY" ] && [ "$SUMMARY_FILE" != "$GITHUB_STEP_SUMMARY" ]; then
cat "$SUMMARY_FILE" >> "$GITHUB_STEP_SUMMARY"
fi
else
echo "No step summary content found"
echo "has_content=false" >> $GITHUB_OUTPUT
fi

- name: Auto commit changes
id: auto-commit
uses: stefanzweifel/git-auto-commit-action@v5
Expand All @@ -215,7 +249,7 @@ runs:
body: >
🤖 Auto-commit successful: ${{ steps.auto-commit.outputs.commit_hash }}

- name: Append no-op comment
- name: Append success comment with output
if: >
steps.comment-start.outputs.comment-id
uses: peter-evans/create-or-update-comment@v4
Expand All @@ -224,15 +258,29 @@ runs:
reactions: "+1"
body: |
> ${{ inputs.success-message || format(' 🟦 Poe command `{0}` completed successfully.', steps.resolve-command.outputs.command) }}
${{ steps.read-summary.outputs.has_content == 'true' && format('

<details><summary>✳️ Show/Hide Summary Output</summary>

{0}

</details>', steps.read-summary.outputs.content) || '' }}

- name: Append failure comment
if: failure() && steps.comment-start.outputs.comment-id
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.comment-start.outputs.comment-id }}
reactions: confused
body: >
${{ inputs.failure-message || format('❌ Poe command `{0}` failed. Please inspect the logs.', steps.resolve-command.outputs.command) }}
body: |
> ${{ inputs.failure-message || format('❌ Poe command `{0}` failed. Please inspect the logs.', steps.resolve-command.outputs.command) }}
${{ steps.read-summary.outputs.has_content == 'true' && format('

<details><summary>✴️ Show/Hide Summary Output</summary>

{0}

</details>', steps.read-summary.outputs.content) || '' }}

# Create a new PR if no PR was provided

Expand Down
22 changes: 22 additions & 0 deletions poe_tasks.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
[tasks]
test = "echo 'Dummy tests...'"
test-fail = "exit 1"

[tasks.test-with-summary]
shell = """
# Determine which file to write to (prefer POE_SUMMARY_FILE, fall back to GITHUB_STEP_SUMMARY)
OUTPUT_FILE="${POE_SUMMARY_FILE:-$GITHUB_STEP_SUMMARY}"

if [ -n "$OUTPUT_FILE" ]; then
echo '## Test Results' >> "$OUTPUT_FILE"
echo '' >> "$OUTPUT_FILE"
echo 'This is a test of the GITHUB_STEP_SUMMARY feature.' >> "$OUTPUT_FILE"
echo '' >> "$OUTPUT_FILE"
echo '- ✅ Item 1: Success' >> "$OUTPUT_FILE"
echo '- ✅ Item 2: Success' >> "$OUTPUT_FILE"
echo '- ✅ Item 3: Success' >> "$OUTPUT_FILE"
echo '' >> "$OUTPUT_FILE"
echo '**Status**: All tests passed! 🎉' >> "$OUTPUT_FILE"
fi
echo 'Test with summary completed'
"""

[tasks.test-without-summary]
shell = "echo 'Test without summary completed'"
Loading