Skip to content

Commit

Permalink
ci: Initial test
Browse files Browse the repository at this point in the history
Signed-off-by: Mihail Mihov <[email protected]>
  • Loading branch information
mishomihov00 committed Nov 25, 2024
1 parent 11f5f17 commit a7e3621
Showing 1 changed file with 115 additions and 0 deletions.
115 changes: 115 additions & 0 deletions .github/workflows/xts-collect-failed-run-logs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
##
# Copyright (C) 2023-2024 Hedera Hashgraph, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##

name: "XTS: Collect Failed Run Logs"
on:
workflow_dispatch:
inputs:
workflow_id:
description: "ID of the workflow run to collect logs from (example: #123456789)"
required: true

defaults:
run:
shell: bash

jobs:
collect-logs:
name: Collect Failed Run Logs
runs-on: network-node-linux-medium
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit

- name: Get run ID from run number
env:
GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
id: run_id
run: |
RUN_ID=$(gh api -H "Accept: application/vnd.github+json" \
/repos/hashgraph/hedera-services/actions/workflows/zxcron-extended-test-suite.yaml/runs \
--jq '.workflow_runs[] | select(.run_number == ${{ inputs.workflow_id }}) | .id')
echo "::set-output name=value::$RUN_ID"
- name: Checkout Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: '0'
ref: develop
token: ${{ secrets.GH_ACCESS_TOKEN }}

- name: Get run logs
env:
GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
run: gh run view ${{ steps.run_id.outputs.value }} --log >> failed-run.log

- name: Upload log as artifact
id: upload-log
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
path: failed-run.log

- name: Report failure
if: ${{ !cancelled() && failure() && always() }}
uses: slackapi/slack-github-action@6c661ce58804a1a20f6dc5fbee7f0381b469e001 # v1.25.0
env:
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CITR_WEBHOOK }}
with:
payload: |
{
"attachments": [
{
"color": "#7647cd",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":grey_exclamation: Hedera Services - New XTS logs available",
"emoji": true
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Workflow ID*: ${{ inputs.workflow_id }}"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Workflow URL*: https://github.com/hashgraph/hedera-services/actions/runs/${{ steps.run_id.outputs.value }}"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Log file download URL*: ${{ steps.upload-log.outputs.artifact-url }}"
}
}
]
}
]
}

0 comments on commit a7e3621

Please sign in to comment.