Skip to content

Commit

Permalink
print github summary
Browse files Browse the repository at this point in the history
In the GitHub Actions tab a summary of ran job would be displayed if
enabled in inputs. Compose, arch, infra state and testresults are
available.

The github summary is enabled by default. User can disable it by setting
the create_github_summary input to false;

Moreover the user can insert 'key=value' value into this input. This way some
additional information can be propagated to the
GITHUB_STEP_SUMMARY variable as a column in a table.
  • Loading branch information
zmiklank committed Jan 10, 2023
1 parent f626437 commit 3e8634e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ See [Testing Farm docs](https://docs.testing-farm.io) for more information on su
| `update_pull_request_status` | Action will update pull request status. Default: true | true |
| `environment_settings` | Pass custom settings to the test environment. Default: {} | empty |
| `pr_head_sha` | SHA of the latest commit in PR. Used for communication with GitHub API. | $(git rev-parse HEAD) |
| `create_github_summary` | Create summary of the Testing Farm as GiHub Action job. Possible options: "false", "true", "key=value" | true |

## Example

Expand Down
32 changes: 32 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ inputs:
description: 'Action will update pull request status. Default: true'
required: false
default: 'true'
create_github_summary:
description: 'Action will create github summary. Possible options: "false", "true", "key=value"'
required: false
default: 'true'
arch:
description: 'Define an architecture for testing environment. Default: x86_64'
required: false
Expand Down Expand Up @@ -329,6 +333,34 @@ runs:
'\n[Full pipeline log](${{ steps.artifacts_url.outputs.url }}/${{ steps.sched_test.outputs.req_id }}/pipeline.log).'
})
- name: Create github summary
if: ${{ inputs.create_github_summary != 'false' }}
shell: bash
run: |
if [ -z "${{ steps.final_state.outputs.INFRA_STATE }}" ]; then
infra_state=OK
else
infra_state=Failed
fi
user_summary="${{ inputs.create_github_summary }}"
if [ "$user_summary" != 'true' ]; then
# In this case we expect key=value string inside
# 'create_github_summary' input.
# We obtain from it a table column and insert it to the GITHUB_STEP_SUMMARY.
user_key="${user_summary%%=*}|"
user_value="${user_summary##*=}|"
user_line="--|"
fi
tfaga_summary_header="Testing Farm as a GitHub Action summary:"
if ! cat "$GITHUB_STEP_SUMMARY" | grep "$tfaga_summary_header" > /dev/null; then
echo "$tfaga_summary_header" >> "$GITHUB_STEP_SUMMARY"
echo "| Compose | Arch | $user_key Infrastructure State | Test result | Link to logs |" >> "$GITHUB_STEP_SUMMARY"
echo "|---------|------| $user_line ----------------------|-------------|--------------|" >> "$GITHUB_STEP_SUMMARY"
fi
echo "|${{ inputs.compose }}|${{ inputs.arch }}| $user_value $infra_state |"\
" ${{ steps.final_state.outputs.FINAL_STATE }}|"\
"${{ steps.artifacts_url.outputs.url }}/${{ steps.sched_test.outputs.req_id }}|" >> "$GITHUB_STEP_SUMMARY"
- name: Exit with error in case of failure in test
shell: bash
run: |
Expand Down

0 comments on commit 3e8634e

Please sign in to comment.