Skip to content

tests: added spread results commenter #1

tests: added spread results commenter

tests: added spread results commenter #1

on:
workflow_call:
inputs:
runs-on:
description: 'A tag to indicate which runner to use'
required: true
type: string
jobs:
report-spread-failures:
runs-on: ${{ inputs.runs-on }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download spread data
uses: actions/download-artifact@v4

Check failure on line 16 in .github/workflows/spread-results-reporter.yaml

View workflow run for this annotation

GitHub Actions / .github/workflows/spread-results-reporter.yaml

Invalid workflow file

You have an error in your yaml syntax on line 16
with:
pattern: spread-json-${{ github.run_id }}-${{ github.run_attempt }}-*
- name: Echo collected output
run: |
ls -la "${{ github.workspace }}/"
jq -s 'add' results*/*.json > consolidated-report.json
report="$(date)\n"
report+="## Failures:\n"
if [[ $(jq -r '.[] | select( .info_type == "Error" ) | select( .verb == "preparing" )' consolidated-report.json) ]]; then
report+="### Prepare:\n"
report+=$(jq -r '.[] | select( .info_type == "Error" ) | select( .verb == "preparing" ) .task' consolidated-report.json | while read line; do echo "- $line\n"; done)
fi
if [[ $(jq -r '.[] | select( .info_type == "Error" ) | select( .verb == "executing" )' consolidated-report.json) ]]; then
report+="### Executing:\n"
report+=$(jq -r '.[] | select( .info_type == "Error" ) | select( .verb == "executing" ) .task' consolidated-report.json | while read line; do echo "- $line\n"; done)
firesults-${{ github.run_id }}-${{ github.run_attempt }}-
if [[ $(jq -r '.[] | select( .info_type == "Error" ) | select( .verb == "restoring" )' consolidated-report.json) ]]; then
report+="### Restoring:\n"
report+=$(jq -r '.[] | select( .info_type == "Error" ) | select( .verb == "restoring" ) .task' consolidated-report.json | while read line; do echo "- $line\n"; done)
fi
echo "report=$report" >> $GITHUB_ENV
- name: Comment report to PR
if: ${{ github.event.number }}
run: |
if ! gh pr comment "${{ github.event.number }}" --report "$(echo -e $report)" --edit-last; then
gh pr comment "${{ github.event.number }}" --report "$(echo -e $report)"results-${{ github.run_id }}-${{ github.run_attempt }}-
fi
- name: Write report to test summary
echo -e "$report" >> $GITHUB_STEP_SUMMARY
- name: Delete artifacts
run: |
artifact_ids=$(gh api /repos/${{ github.repository }}/actions/artifacts | jq -r '.artifacts[] | select(.name|startswith("spread-json-${{ github.run_id }}-${{ github.run_attempt }}-")) | "\(.id)"')
for artifact_id in $artifact_ids; do
echo "planning to delete $artifact_id";
gh api -X delete /repos/${{ github.repository }}/actions/artifacts/$artifact_id
done