Fix Slack messages formatting on job failure (#4520)

This commit is contained in:
Silvano Cerza 2023-03-29 09:24:41 +02:00 committed by GitHub
parent 0dfa5d6ad7
commit 85ade5c878
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 102 additions and 484 deletions

View File

@ -0,0 +1,48 @@
{
"blocks": [
{
"type": "context",
"elements": [
{
"type": "image",
"image_url": "https://avatars.githubusercontent.com/u/${{ github.author_id }}?v=4",
"alt_text": "Actor"
},
{
"type": "mrkdwn",
"text": "*<https://github.com/${{ github.author }}|${{ github.actor }}>*"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Job ${{ github.job }} in workflow <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/workflow/|${{ github.workflow }}>"
}
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "Triggered by ${{ github.event_name }} for ${{ github.ref_type }} `${{ github.ref_name }}`"
}
]
},
{
"type": "context",
"elements": [
{
"type": "image",
"image_url": "https://github.githubassets.com/favicons/favicon.png",
"alt_text": "Github logo"
},
{
"type": "mrkdwn",
"text": "<https://github.com/${{ github.repository }}/|${{ github.repository }}> Run <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}/|#${{ github.run_number }} | Attempt #${{ github.run_attempt }}>"
}
]
}
]
}

View File

@ -52,27 +52,7 @@ jobs:
- uses: slackapi/slack-github-action@v1.23.0
if: failure() && github.ref == 'refs/heads/main'
with:
payload: |
{
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Click *<https://github.com/${{ env.GITHUB_REPOSITORY }}/actions/runs/${{ env.GITHUB_RUN_ID }}|here>* for more details "
}
}
]
}
payload-file-path: .github/config/failure-message-slack-payload.json
check-license-compliance-gpu:
if: ${{ !github.event.pull_request.head.repo.fork }}
@ -112,24 +92,4 @@ jobs:
- uses: slackapi/slack-github-action@v1.23.0
if: failure() && github.ref == 'refs/heads/main'
with:
payload: |
{
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Click *<https://github.com/${{ env.GITHUB_REPOSITORY }}/actions/runs/${{ env.GITHUB_RUN_ID }}|here>* for more details "
}
}
]
}
payload-file-path: .github/config/failure-message-slack-payload.json

View File

@ -21,51 +21,31 @@ env:
jobs:
tests:
name: Examples
runs-on: ubuntu-latest
services:
elasticsearch:
image: elasticsearch:7.17.6
env:
discovery.type: "single-node"
ES_JAVA_OPTS: "-Xms128m -Xmx256m"
ports:
- 9200:9200
name: Examples
runs-on: ubuntu-latest
services:
elasticsearch:
image: elasticsearch:7.17.6
env:
discovery.type: "single-node"
ES_JAVA_OPTS: "-Xms128m -Xmx256m"
ports:
- 9200:9200
steps:
- uses: actions/checkout@v3
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Haystack
run: pip install .[all]
- name: Install Haystack
run: pip install .[all]
- name: Run
run: pytest examples/
- name: Run
run: pytest examples/
- uses: slackapi/slack-github-action@v1.23.0
if: failure() && github.ref == 'refs/heads/main'
with:
payload: |
{
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Click *<https://github.com/${{ env.GITHUB_REPOSITORY }}/actions/runs/${{ env.GITHUB_RUN_ID }}|here>* for more details "
}
}
]
}
- uses: slackapi/slack-github-action@v1.23.0
if: failure() && github.ref == 'refs/heads/main'
with:
payload-file-path: .github/config/failure-message-slack-payload.json

View File

@ -66,27 +66,7 @@ jobs:
- uses: slackapi/slack-github-action@v1.23.0
if: failure() && github.ref == 'refs/heads/main'
with:
payload: |
{
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Click *<https://github.com/${{ env.GITHUB_REPOSITORY }}/actions/runs/${{ env.GITHUB_RUN_ID }}|here>* for more details "
}
}
]
}
payload-file-path: .github/config/failure-message-slack-payload.json
rest_api:
needs: black
@ -118,24 +98,4 @@ jobs:
- uses: slackapi/slack-github-action@v1.23.0
if: failure() && github.ref == 'refs/heads/main'
with:
payload: |
{
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Click *<https://github.com/${{ env.GITHUB_REPOSITORY }}/actions/runs/${{ env.GITHUB_RUN_ID }}|here>* for more details "
}
}
]
}
payload-file-path: .github/config/failure-message-slack-payload.json

View File

@ -80,27 +80,7 @@ jobs:
- uses: slackapi/slack-github-action@v1.23.0
if: failure() && github.ref == 'refs/heads/main'
with:
payload: |
{
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Click *<https://github.com/${{ env.GITHUB_REPOSITORY }}/actions/runs/${{ env.GITHUB_RUN_ID }}|here>* for more details "
}
}
]
}
payload-file-path: .github/config/failure-message-slack-payload.json
unit-tests:
name: Unit / ${{ matrix.topic }} / ${{ matrix.os }}
@ -134,27 +114,8 @@ jobs:
- uses: slackapi/slack-github-action@v1.23.0
if: failure() && github.ref == 'refs/heads/main'
with:
payload: |
{
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Click *<https://github.com/${{ env.GITHUB_REPOSITORY }}/actions/runs/${{ env.GITHUB_RUN_ID }}|here>* for more details "
}
}
]
}
payload-file-path: .github/config/failure-message-slack-payload.json
integration-tests-elasticsearch:
name: Integration / Elasticsearch / ${{ matrix.os }}
@ -190,27 +151,8 @@ jobs:
- uses: slackapi/slack-github-action@v1.23.0
if: failure() && github.ref == 'refs/heads/main'
with:
payload: |
{
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Click *<https://github.com/${{ env.GITHUB_REPOSITORY }}/actions/runs/${{ env.GITHUB_RUN_ID }}|here>* for more details "
}
}
]
}
payload-file-path: .github/config/failure-message-slack-payload.json
integration-tests-sql:
name: Integration / SQL / ${{ matrix.os }}
@ -238,27 +180,8 @@ jobs:
- uses: slackapi/slack-github-action@v1.23.0
if: failure() && github.ref == 'refs/heads/main'
with:
payload: |
{
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Click *<https://github.com/${{ env.GITHUB_REPOSITORY }}/actions/runs/${{ env.GITHUB_RUN_ID }}|here>* for more details "
}
}
]
}
payload-file-path: .github/config/failure-message-slack-payload.json
integration-tests-opensearch:
name: Integration / Opensearch / ${{ matrix.os }}
@ -294,27 +217,8 @@ jobs:
- uses: slackapi/slack-github-action@v1.23.0
if: failure() && github.ref == 'refs/heads/main'
with:
payload: |
{
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Click *<https://github.com/${{ env.GITHUB_REPOSITORY }}/actions/runs/${{ env.GITHUB_RUN_ID }}|here>* for more details "
}
}
]
}
payload-file-path: .github/config/failure-message-slack-payload.json
integration-tests-dc:
name: Integration / dC / ${{ matrix.os }}
@ -342,27 +246,8 @@ jobs:
- uses: slackapi/slack-github-action@v1.23.0
if: failure() && github.ref == 'refs/heads/main'
with:
payload: |
{
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Click *<https://github.com/${{ env.GITHUB_REPOSITORY }}/actions/runs/${{ env.GITHUB_RUN_ID }}|here>* for more details "
}
}
]
}
payload-file-path: .github/config/failure-message-slack-payload.json
integration-tests-faiss:
name: Integration / faiss / ${{ matrix.os }}
@ -390,27 +275,8 @@ jobs:
- uses: slackapi/slack-github-action@v1.23.0
if: failure() && github.ref == 'refs/heads/main'
with:
payload: |
{
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Click *<https://github.com/${{ env.GITHUB_REPOSITORY }}/actions/runs/${{ env.GITHUB_RUN_ID }}|here>* for more details "
}
}
]
}
payload-file-path: .github/config/failure-message-slack-payload.json
integration-tests-weaviate:
name: Integration / Weaviate / ${{ matrix.os }}
@ -448,27 +314,8 @@ jobs:
- uses: slackapi/slack-github-action@v1.23.0
if: failure() && github.ref == 'refs/heads/main'
with:
payload: |
{
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Click *<https://github.com/${{ env.GITHUB_REPOSITORY }}/actions/runs/${{ env.GITHUB_RUN_ID }}|here>* for more details "
}
}
]
}
payload-file-path: .github/config/failure-message-slack-payload.json
integration-tests-pinecone:
name: Integration / pinecone / ${{ matrix.os }}
@ -498,27 +345,7 @@ jobs:
- uses: slackapi/slack-github-action@v1.23.0
if: failure() && github.ref == 'refs/heads/main'
with:
payload: |
{
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Click *<https://github.com/${{ env.GITHUB_REPOSITORY }}/actions/runs/${{ env.GITHUB_RUN_ID }}|here>* for more details "
}
}
]
}
payload-file-path: .github/config/failure-message-slack-payload.json
integration-tests-milvus:
name: Integration / Milvus / ${{ matrix.os }}
@ -557,27 +384,7 @@ jobs:
- uses: slackapi/slack-github-action@v1.23.0
if: failure() && github.ref == 'refs/heads/main'
with:
payload: |
{
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Click *<https://github.com/${{ env.GITHUB_REPOSITORY }}/actions/runs/${{ env.GITHUB_RUN_ID }}|here>* for more details "
}
}
]
}
payload-file-path: .github/config/failure-message-slack-payload.json
integration-tests-memory:
name: Integration / memory / ${{ matrix.os }}
@ -605,27 +412,8 @@ jobs:
- uses: slackapi/slack-github-action@v1.23.0
if: failure() && github.ref == 'refs/heads/main'
with:
payload: |
{
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Click *<https://github.com/${{ env.GITHUB_REPOSITORY }}/actions/runs/${{ env.GITHUB_RUN_ID }}|here>* for more details "
}
}
]
}
payload-file-path: .github/config/failure-message-slack-payload.json
integration-tests-promptnode:
name: Integration / PromptNode / ${{ matrix.os }}
@ -653,27 +441,8 @@ jobs:
- uses: slackapi/slack-github-action@v1.23.0
if: failure() && github.ref == 'refs/heads/main'
with:
payload: |
{
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Click *<https://github.com/${{ env.GITHUB_REPOSITORY }}/actions/runs/${{ env.GITHUB_RUN_ID }}|here>* for more details "
}
}
]
}
payload-file-path: .github/config/failure-message-slack-payload.json
integration-tests-agents:
name: Integration / Agents / ${{ matrix.os }}
@ -701,27 +470,8 @@ jobs:
- uses: slackapi/slack-github-action@v1.23.0
if: failure() && github.ref == 'refs/heads/main'
with:
payload: |
{
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Click *<https://github.com/${{ env.GITHUB_REPOSITORY }}/actions/runs/${{ env.GITHUB_RUN_ID }}|here>* for more details "
}
}
]
}
payload-file-path: .github/config/failure-message-slack-payload.json
#
@ -769,27 +519,7 @@ jobs:
- uses: slackapi/slack-github-action@v1.23.0
if: failure() && github.ref == 'refs/heads/main'
with:
payload: |
{
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Click *<https://github.com/${{ env.GITHUB_REPOSITORY }}/actions/runs/${{ env.GITHUB_RUN_ID }}|here>* for more details "
}
}
]
}
payload-file-path: .github/config/failure-message-slack-payload.json
unit-tests-windows:
needs: black
@ -828,27 +558,7 @@ jobs:
- uses: slackapi/slack-github-action@v1.23.0
if: failure() && github.ref == 'refs/heads/main'
with:
payload: |
{
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Click *<https://github.com/${{ env.GITHUB_REPOSITORY }}/actions/runs/${{ env.GITHUB_RUN_ID }}|here>* for more details "
}
}
]
}
payload-file-path: .github/config/failure-message-slack-payload.json
integration-tests-linux:
needs:
@ -939,27 +649,7 @@ jobs:
- uses: slackapi/slack-github-action@v1.23.0
if: failure() && github.ref == 'refs/heads/main'
with:
payload: |
{
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Click *<https://github.com/${{ env.GITHUB_REPOSITORY }}/actions/runs/${{ env.GITHUB_RUN_ID }}|here>* for more details "
}
}
]
}
payload-file-path: .github/config/failure-message-slack-payload.json
integration-tests-windows:
needs:
@ -1012,27 +702,7 @@ jobs:
- uses: slackapi/slack-github-action@v1.23.0
if: failure() && github.ref == 'refs/heads/main'
with:
payload: |
{
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":x: Job ${{ env.GITHUB_JOB }} failed for ${{ github.ref_type }} ${{ github.ref_name }}",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Click *<https://github.com/${{ env.GITHUB_REPOSITORY }}/actions/runs/${{ env.GITHUB_RUN_ID }}|here>* for more details "
}
}
]
}
payload-file-path: .github/config/failure-message-slack-payload.json
catch-all:
name: Catch-all check