ci: Fixed error count logic for test summary
This commit is contained in:
parent
572cc80577
commit
f2f75ae7b9
2 changed files with 64 additions and 6 deletions
29
.github/actions/test-summary/action.yml
vendored
29
.github/actions/test-summary/action.yml
vendored
|
|
@ -1,13 +1,24 @@
|
||||||
name: "Test Summary"
|
name: "Test Summary"
|
||||||
description: "Creates a markdown table from test results and uploads a summary file"
|
description: "Creates a markdown table from test results and uploads a summary file"
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
download-pattern:
|
||||||
|
description: "The pattern to download test result rows"
|
||||||
|
required: false
|
||||||
|
default: test-result-*
|
||||||
|
|
||||||
|
upload-name:
|
||||||
|
description: "The artifact upload name for the summary"
|
||||||
|
required: false
|
||||||
|
default: summary-tests
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
steps:
|
||||||
- name: Download test result rows
|
- name: Download test result rows
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
pattern: test-result-*
|
pattern: ${{ inputs.download-pattern }}
|
||||||
merge-multiple: true
|
merge-multiple: true
|
||||||
path: rows
|
path: rows
|
||||||
|
|
||||||
|
|
@ -44,24 +55,30 @@ runs:
|
||||||
|
|
||||||
table="${{ steps.markdown-table.outputs.markdown }}"
|
table="${{ steps.markdown-table.outputs.markdown }}"
|
||||||
if [ -z "$table" ]; then
|
if [ -z "$table" ]; then
|
||||||
echo "No test results found" > $GITHUB_STEP_SUMMARY
|
echo "No test results found" | tee $GITHUB_STEP_SUMMARY >&2
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
echo "$table" > $GITHUB_STEP_SUMMARY
|
echo "$table" > $GITHUB_STEP_SUMMARY
|
||||||
fi
|
fi
|
||||||
|
|
||||||
count=$(echo -n "$table" | grep -o "❌" | wc -l || echo 0)
|
count=$(echo "$table" | awk -v RS='' '{gsub(/[^❌]/, ""); print length}')
|
||||||
|
file="ci-summary.md"
|
||||||
|
|
||||||
if [ $count -gt 0 ]; then
|
if [ $count -gt 0 ]; then
|
||||||
file="ci-summary.md"
|
echo "❌🔬 Tests failed: $count" | tee $file
|
||||||
echo "❌🔬 Tests failed: $count" > $file
|
|
||||||
echo "file=$file" >> $GITHUB_OUTPUT
|
echo "file=$file" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
# For debugging; don't send success to CI summary (reduce noise).
|
||||||
|
echo > $file
|
||||||
|
echo "✅🔬 All tests passed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Upload CI summary
|
- name: Upload CI summary
|
||||||
if: steps.summary.outputs.file
|
if: steps.summary.outputs.file
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: summary-tests
|
name: ${{ inputs.upload-name }}
|
||||||
path: ${{ steps.summary.outputs.file }}
|
path: ${{ steps.summary.outputs.file }}
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
|
||||||
41
.github/workflows/test-actions.yml
vendored
Normal file
41
.github/workflows/test-actions.yml
vendored
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
name: Test actions
|
||||||
|
|
||||||
|
# Intended to only be run manually for testing actions in isolation.
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test-summary:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Test summary (${{ matrix.message.name }})
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
message:
|
||||||
|
- name: success
|
||||||
|
text: "|Success|✅|✅|"
|
||||||
|
expect: ""
|
||||||
|
- name: failure
|
||||||
|
text: "|Failure|❌|❌|"
|
||||||
|
expect: "❌🔬 Tests failed: 2"
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Generate
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "${{ matrix.message.text }}" > test-result.md
|
||||||
|
|
||||||
|
- name: Upload
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
path: test-result.md
|
||||||
|
name: test-result-${{ matrix.message.name }}
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
uses: ./.github/actions/test-summary
|
||||||
|
with:
|
||||||
|
download-pattern: test-result-${{ matrix.message.name }}
|
||||||
|
upload-name: summary-${{ matrix.message.name }}
|
||||||
Loading…
Reference in a new issue