Skip to content

Commit da64589

Browse files
committed
Enhance the body of the ticket with logs
1 parent d6df7a5 commit da64589

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

.github/workflows/check-new-library-versions-in-batch.yml

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ jobs:
6161
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6262
ISSUE_TITLE_PREFIX: "[Automation] Testing failed for library: "
6363
ISSUE_BODY_PREFIX: "Failure kind: "
64+
LOG_LINES: "300"
6465
strategy:
6566
fail-fast: false
6667
matrix:
@@ -135,6 +136,15 @@ jobs:
135136
# Extract failure type and failed version
136137
awk -F'[][]|:' '/^FAILED/ {print "failure_type="$2; print "failed_version="$4}' test_results.txt >> $GITHUB_OUTPUT
137138
139+
# Extract runner log URL
140+
echo "runner_log_url=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> $GITHUB_OUTPUT
141+
142+
# Extract log tail
143+
echo "log_tail<<EOF" >> $GITHUB_OUTPUT
144+
tail "-n${{ env.LOG_LINES }}" test_results.txt | head -c 900000 >> $GITHUB_OUTPUT
145+
echo "" >> $GITHUB_OUTPUT
146+
echo "EOF" >> $GITHUB_OUTPUT
147+
138148
- name: "✔️ New library versions are supported (with locks, waiting and retries)"
139149
if: steps.runtests.outputs.successful_versions != ''
140150
env:
@@ -188,21 +198,33 @@ jobs:
188198
run: |
189199
git config --local user.email "[email protected]"
190200
git config --local user.name "Github Actions"
191-
201+
192202
FAILED_VERSION="${{ steps.runtests.outputs.failed_version }}"
193203
REPO="${{ github.repository }}"
194204
TITLE="${{ env.ISSUE_TITLE_PREFIX }}${{ matrix.item.name }}:$FAILED_VERSION"
195-
BODY="${{ env.ISSUE_BODY_PREFIX }}${{ steps.runtests.outputs.failure_type }}"
205+
206+
BODY_FILE=$(mktemp)
207+
# Use single-quoted here-doc to disable any shell expansion of log content
208+
cat > "$BODY_FILE" <<'EOF'
209+
${{ env.ISSUE_BODY_PREFIX }}${{ steps.runtests.outputs.failure_type }}
210+
Runner log: ${{ steps.runtests.outputs.runner_log_url }}
211+
Last ${{ env.LOG_LINES }} lines of the log:
212+
```console
213+
${{ steps.runtests.outputs.log_tail }}
214+
```
215+
EOF
196216
197217
ISSUE_NUMBER=$(gh issue list --repo "$REPO" --state open --search "$TITLE" --json number,title --jq '.[] | select(.title == "'"$TITLE"'") | .number')
198218
if [ -n "$ISSUE_NUMBER" ]; then
199219
echo "Updating existing issue #$ISSUE_NUMBER"
200-
gh issue edit "$ISSUE_NUMBER" --repo "$REPO" --body "$BODY"
220+
gh issue edit "$ISSUE_NUMBER" --repo "$REPO" --body-file "$BODY_FILE"
201221
else
202222
echo "Creating new issue"
203-
gh issue create --repo "$REPO" --title "$TITLE" --body "$BODY"
223+
gh issue create --repo "$REPO" --title "$TITLE" --body-file "$BODY_FILE"
204224
fi
205225
226+
rm "$BODY_FILE"
227+
206228
process-results:
207229
name: "🧪 Process results"
208230
runs-on: ubuntu-22.04

0 commit comments

Comments
 (0)