This commit is contained in:
Austin 2025-04-22 11:44:44 -04:00 committed by GitHub
parent 43e5295ec7
commit 0832383734
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 162 additions and 5 deletions

View File

@ -44,3 +44,10 @@ jobs:
- name: Run DBT Jobs
run: |
dbt run --vars '{"STREAMLINE_INVOKE_STREAMS":True}' -m models/bronze/core "sei_models,tag:core" "sei_models,tag:streamline_decoded_logs_realtime" "sei_models,tag:streamline_decoded_logs_complete"
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
EVM_SLACK_WEBHOOK_URL: ${{ secrets.EVM_SLACK_WEBHOOK_URL }}

View File

@ -45,4 +45,11 @@ jobs:
dbt deps
- name: Run DBT Jobs
run: |
dbt run -m "sei_models,tag:noncore" models/bronze/bronze_api "sei_models,tag:curated" models/evm/bronze/api_udf/bronze_evm_api__contract_abis.sql --exclude models/bronze/bronze_api/bronze_api__get_seaswap_pools.sql
dbt run -m "sei_models,tag:noncore" models/bronze/bronze_api "sei_models,tag:curated" models/evm/bronze/api_udf/bronze_evm_api__contract_abis.sql --exclude models/bronze/bronze_api/bronze_api__get_seaswap_pools.sql
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
EVM_SLACK_WEBHOOK_URL: ${{ secrets.EVM_SLACK_WEBHOOK_URL }}

View File

@ -42,4 +42,11 @@ jobs:
- name: Update decoded logs
run: |
dbt run -m "sei_models,tag:gold_decoded_logs" "sei_models,tag:silver_decoded_logs" "sei_models,tag:bronze_decoded_logs"
dbt run -m "sei_models,tag:gold_decoded_logs" "sei_models,tag:silver_decoded_logs" "sei_models,tag:bronze_decoded_logs"
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
EVM_SLACK_WEBHOOK_URL: ${{ secrets.EVM_SLACK_WEBHOOK_URL }}

View File

@ -42,4 +42,11 @@ jobs:
- name: Kick off decoded logs history, if there are new ABIs from users
run: |
dbt run-operation run_decoded_logs_history
dbt run-operation run_decoded_logs_history
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
EVM_SLACK_WEBHOOK_URL: ${{ secrets.EVM_SLACK_WEBHOOK_URL }}

View File

@ -44,3 +44,10 @@ jobs:
- name: Run DBT Jobs
run: |
dbt run --vars '{"STREAMLINE_INVOKE_STREAMS":True}' -m "sei_models,tag:streamline_core_evm_complete" "sei_models,tag:streamline_core_evm_realtime"
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
EVM_SLACK_WEBHOOK_URL: ${{ secrets.EVM_SLACK_WEBHOOK_URL }}

View File

@ -44,3 +44,10 @@ jobs:
- name: Run DBT Jobs
run: |
dbt run --vars '{"STREAMLINE_INVOKE_STREAMS":True}' -m "sei_models,tag:streamline_core_evm_complete" "sei_models,tag:streamline_core_evm_history"
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
EVM_SLACK_WEBHOOK_URL: ${{ secrets.EVM_SLACK_WEBHOOK_URL }}

View File

@ -44,4 +44,11 @@ jobs:
dbt deps
- name: Run DBT Jobs
run: |
dbt test -m "sei_models,tag:full_evm_test"
dbt test -m "sei_models,tag:full_evm_test"
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
EVM_SLACK_WEBHOOK_URL: ${{ secrets.EVM_SLACK_WEBHOOK_URL }}

View File

@ -45,4 +45,11 @@ jobs:
dbt deps
- name: Run DBT Jobs
run: |
dbt test -m models/bronze/core "sei_models,tag:recent_evm_test"
dbt test -m models/bronze/core "sei_models,tag:recent_evm_test"
notify-failure:
needs: [run_dbt_jobs]
if: failure()
uses: ./.github/workflows/slack_notify.yml
secrets:
EVM_SLACK_WEBHOOK_URL: ${{ secrets.EVM_SLACK_WEBHOOK_URL }}

27
.github/workflows/slack_notify.yml vendored Normal file
View File

@ -0,0 +1,27 @@
name: Slack Notification
on:
workflow_call:
secrets:
EVM_SLACK_WEBHOOK_URL:
required: true
jobs:
notify:
runs-on: ubuntu-latest
environment: workflow_prod
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies
run: pip install requests
- name: Send Slack notification
run: python python/slack_alert.py
env:
EVM_SLACK_WEBHOOK_URL: ${{ secrets.EVM_SLACK_WEBHOOK_URL }}

74
python/slack_alert.py Normal file
View File

@ -0,0 +1,74 @@
import requests
import os
import sys
def create_message():
"""Creates a simple failure notification message with repo, workflow name, and URL"""
# Get GitHub environment variables
repository = os.environ.get('GITHUB_REPOSITORY', 'Unknown repository')
repo_name = repository.split('/')[-1] if '/' in repository else repository
workflow_name = os.environ.get('GITHUB_WORKFLOW', 'Unknown workflow')
run_id = os.environ.get('GITHUB_RUN_ID', '')
server_url = os.environ.get('GITHUB_SERVER_URL', 'https://github.com')
# Build the workflow URL
workflow_url = f"{server_url}/{repository}/actions/runs/{run_id}"
message_body = {
"text": f"Failure in {repo_name}",
"attachments": [
{
"color": "#f44336", # Red color for failures
"fields": [
{
"title": "Repository",
"value": repository,
"short": True
},
{
"title": "Workflow",
"value": workflow_name,
"short": True
}
],
"actions": [
{
"type": "button",
"text": "View Workflow Run",
"style": "primary",
"url": workflow_url
}
],
"footer": "GitHub Actions"
}
]
}
return message_body
def send_alert(webhook_url):
"""Sends a failure notification to Slack"""
message = create_message()
try:
response = requests.post(webhook_url, json=message)
if response.status_code == 200:
print("Successfully sent Slack notification")
else:
print(f"Failed to send Slack notification: {response.status_code} {response.text}")
sys.exit(1)
except Exception as e:
print(f"Error sending Slack notification: {str(e)}")
sys.exit(1)
if __name__ == '__main__':
webhook_url = os.environ.get("EVM_SLACK_WEBHOOK_URL")
if not webhook_url:
print("ERROR: EVM_SLACK_WEBHOOK_URL environment variable is required")
sys.exit(1)
send_alert(webhook_url)