-
Notifications
You must be signed in to change notification settings - Fork 631
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Share workflow failure alerting between ci.yml and pkgci.yml. (#19444)
Progress on #9305. Changes included: 1. Extracts the code for parsing the results of multiple jobs and optionally posting alerts to Discord from `ci.yml` into a new [reusable workflow](https://docs.github.com/en/actions/sharing-automations/reusing-workflows) in the `workflow_summary.yml` file. 2. Uses the new reusable workflow in `pkgci.yml`. 3. Renames to `summary` step to `ci_summary` and `pkgci_summary` to disambiguate "required checks". You'd think GitHub would use keys that aren't ambiguous for required checks but nooooope: ![image](https://github.com/user-attachments/assets/5c3665bc-7933-41d0-8d5a-c6ecf966a3b4)
- Loading branch information
Showing
4 changed files
with
103 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Copyright 2024 The IREE Authors | ||
# | ||
# Licensed under the Apache License v2.0 with LLVM Exceptions. | ||
# See https://llvm.org/LICENSE.txt for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
# Checks the result status of each job provided by 'jobs-json' and sends an | ||
# alert if at least one job failed. | ||
# | ||
# Usage: | ||
# ```yml | ||
# jobs: | ||
# job_1: | ||
# ... | ||
# job_2: | ||
# ... | ||
# my_summary: | ||
# if: always() | ||
# needs: | ||
# - job_1 | ||
# - job_2 | ||
# uses: ./.github/workflows/workflow_summary.yml | ||
# secrets: inherit | ||
# with: | ||
# jobs-json: ${{ toJson(needs) }} | ||
# ``` | ||
|
||
name: Workflow Summary | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
jobs-json: | ||
type: string | ||
description: The output of `toJson(needs)` | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
summary: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Getting failed jobs | ||
id: failed_jobs | ||
run: | | ||
echo '${{ inputs.jobs-json }}' | ||
FAILED_JOBS="$(echo '${{ inputs.jobs-json }}' \ | ||
| jq --raw-output \ | ||
'map_values(select(.result!="success" and .result!="skipped")) | keys | join(",")' \ | ||
)" | ||
echo "failed-jobs=${FAILED_JOBS}" >> $GITHUB_OUTPUT | ||
if [[ "${FAILED_JOBS}" != "" ]]; then | ||
echo "The following jobs failed: ${FAILED_JOBS}" | ||
exit 1 | ||
fi | ||
- name: Posting to Discord | ||
uses: sarisia/actions-status-discord@ce8cc68e4e626000136b3c702d049a154243e490 # v1.14.7 | ||
if: failure() && github.ref_name == 'main' && github.repository_owner == 'iree-org' | ||
with: | ||
webhook: ${{ secrets.DISCORD_WEBHOOK }} | ||
description: "The following jobs failed: ${{ steps.failed_jobs.outputs.failed-jobs }}" | ||
url: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters