mirror of
https://github.com/FlipsideCrypto/rise-models.git
synced 2026-02-06 11:46:47 +00:00
Merge pull request #25 from FlipsideCrypto/add-slack-alerts
add-slack-alerts
This commit is contained in:
commit
6268489a52
26
.github/workflows/dbt_deploy_new_workflows.yml
vendored
26
.github/workflows/dbt_deploy_new_workflows.yml
vendored
@ -44,9 +44,27 @@ jobs:
|
||||
run: |
|
||||
make deploy_new_github_action DBT_TARGET=prod
|
||||
|
||||
notify-failure:
|
||||
needs: [run_dbt_jobs]
|
||||
notify:
|
||||
runs-on: ubuntu-latest
|
||||
needs: run_dbt_jobs
|
||||
if: failure()
|
||||
uses: FlipsideCrypto/fsc-evm/.github/workflows/slack_notify.yml@main
|
||||
secrets:
|
||||
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
|
||||
pip install -r requirements.txt
|
||||
dbt deps
|
||||
|
||||
- name: Send Slack notification
|
||||
run: python macros/python/slack_alert.py
|
||||
env:
|
||||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
||||
26
.github/workflows/dbt_docs_update.yml
vendored
26
.github/workflows/dbt_docs_update.yml
vendored
@ -75,9 +75,27 @@ jobs:
|
||||
run: |
|
||||
git push -f --set-upstream origin docs
|
||||
|
||||
notify-failure:
|
||||
needs: [run_dbt_jobs]
|
||||
notify:
|
||||
runs-on: ubuntu-latest
|
||||
needs: run_dbt_jobs
|
||||
if: failure()
|
||||
uses: FlipsideCrypto/fsc-evm/.github/workflows/slack_notify.yml@main
|
||||
secrets:
|
||||
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
|
||||
pip install -r requirements.txt
|
||||
dbt deps
|
||||
|
||||
- name: Send Slack notification
|
||||
run: python macros/python/slack_alert.py
|
||||
env:
|
||||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
||||
26
.github/workflows/dbt_integration_test.yml
vendored
26
.github/workflows/dbt_integration_test.yml
vendored
@ -33,9 +33,27 @@ jobs:
|
||||
warehouse: ${{ needs.prepare_vars.outputs.warehouse }}
|
||||
secrets: inherit
|
||||
|
||||
notify-failure:
|
||||
needs: [called_workflow_template]
|
||||
notify:
|
||||
runs-on: ubuntu-latest
|
||||
needs: run_dbt_jobs
|
||||
if: failure()
|
||||
uses: FlipsideCrypto/fsc-evm/.github/workflows/slack_notify.yml@main
|
||||
secrets:
|
||||
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
|
||||
pip install -r requirements.txt
|
||||
dbt deps
|
||||
|
||||
- name: Send Slack notification
|
||||
run: python macros/python/slack_alert.py
|
||||
env:
|
||||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
||||
26
.github/workflows/dbt_run_adhoc.yml
vendored
26
.github/workflows/dbt_run_adhoc.yml
vendored
@ -66,9 +66,27 @@ jobs:
|
||||
run: |
|
||||
${{ inputs.dbt_command }}
|
||||
|
||||
notify-failure:
|
||||
needs: [run_dbt_jobs]
|
||||
notify:
|
||||
runs-on: ubuntu-latest
|
||||
needs: run_dbt_jobs
|
||||
if: failure()
|
||||
uses: FlipsideCrypto/fsc-evm/.github/workflows/slack_notify.yml@main
|
||||
secrets:
|
||||
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
|
||||
pip install -r requirements.txt
|
||||
dbt deps
|
||||
|
||||
- name: Send Slack notification
|
||||
run: python macros/python/slack_alert.py
|
||||
env:
|
||||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
||||
52
.github/workflows/dbt_run_dev_refresh.yml
vendored
52
.github/workflows/dbt_run_dev_refresh.yml
vendored
@ -43,11 +43,29 @@ jobs:
|
||||
run: |
|
||||
dbt run-operation fsc_evm.run_sp_create_prod_clone
|
||||
|
||||
notify-failure:
|
||||
needs: [run_dbt_jobs_refresh]
|
||||
notify:
|
||||
runs-on: ubuntu-latest
|
||||
needs: run_dbt_jobs_refresh
|
||||
if: failure()
|
||||
uses: FlipsideCrypto/fsc-evm/.github/workflows/slack_notify.yml@main
|
||||
secrets:
|
||||
environment: workflow_dev
|
||||
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
|
||||
pip install -r requirements.txt
|
||||
dbt deps
|
||||
|
||||
- name: Send Slack notification
|
||||
run: python macros/python/slack_alert.py
|
||||
env:
|
||||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
||||
|
||||
run_dbt_jobs_udfs:
|
||||
@ -74,9 +92,27 @@ jobs:
|
||||
dbt run-operation fsc_utils.create_evm_streamline_udfs --vars '{"UPDATE_UDFS_AND_SPS":True}' -t dev
|
||||
dbt run -s livequery_models.deploy.core._live --vars '{"UPDATE_UDFS_AND_SPS":True}' -t dev
|
||||
|
||||
notify-failure2:
|
||||
needs: [run_dbt_jobs_udfs]
|
||||
notify:
|
||||
runs-on: ubuntu-latest
|
||||
needs: run_dbt_jobs_udfs
|
||||
if: failure()
|
||||
uses: FlipsideCrypto/fsc-evm/.github/workflows/slack_notify.yml@main
|
||||
secrets:
|
||||
environment: workflow_dev
|
||||
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
|
||||
pip install -r requirements.txt
|
||||
dbt deps
|
||||
|
||||
- name: Send Slack notification
|
||||
run: python macros/python/slack_alert.py
|
||||
env:
|
||||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
||||
26
.github/workflows/dbt_run_scheduled_main.yml
vendored
26
.github/workflows/dbt_run_scheduled_main.yml
vendored
@ -44,9 +44,27 @@ jobs:
|
||||
run: |
|
||||
dbt run -m "rise_models,tag:silver_testnet" "rise_models,tag:gold_testnet" "rise_models,tag:bronze_testnet"
|
||||
|
||||
notify-failure:
|
||||
needs: [run_dbt_jobs]
|
||||
notify:
|
||||
runs-on: ubuntu-latest
|
||||
needs: run_dbt_jobs
|
||||
if: failure()
|
||||
uses: FlipsideCrypto/fsc-evm/.github/workflows/slack_notify.yml@main
|
||||
secrets:
|
||||
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
|
||||
pip install -r requirements.txt
|
||||
dbt deps
|
||||
|
||||
- name: Send Slack notification
|
||||
run: python macros/python/slack_alert.py
|
||||
env:
|
||||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
||||
@ -48,9 +48,27 @@ jobs:
|
||||
run: |
|
||||
dbt test -m "rise_models,tag:chainhead"
|
||||
|
||||
notify-failure:
|
||||
needs: [run_dbt_jobs]
|
||||
notify:
|
||||
runs-on: ubuntu-latest
|
||||
needs: run_dbt_jobs
|
||||
if: failure()
|
||||
uses: FlipsideCrypto/fsc-evm/.github/workflows/slack_notify.yml@main
|
||||
secrets:
|
||||
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
|
||||
pip install -r requirements.txt
|
||||
dbt deps
|
||||
|
||||
- name: Send Slack notification
|
||||
run: python macros/python/slack_alert.py
|
||||
env:
|
||||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
||||
26
.github/workflows/dbt_run_streamline_history.yml
vendored
26
.github/workflows/dbt_run_streamline_history.yml
vendored
@ -44,9 +44,27 @@ jobs:
|
||||
run: |
|
||||
dbt run --vars '{"STREAMLINE_INVOKE_STREAMS":True}' -m "rise_models,tag:streamline_testnet_complete" "rise_models,tag:streamline_testnet_history"
|
||||
|
||||
notify-failure:
|
||||
needs: [run_dbt_jobs]
|
||||
notify:
|
||||
runs-on: ubuntu-latest
|
||||
needs: run_dbt_jobs
|
||||
if: failure()
|
||||
uses: FlipsideCrypto/fsc-evm/.github/workflows/slack_notify.yml@main
|
||||
secrets:
|
||||
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
|
||||
pip install -r requirements.txt
|
||||
dbt deps
|
||||
|
||||
- name: Send Slack notification
|
||||
run: python macros/python/slack_alert.py
|
||||
env:
|
||||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
||||
26
.github/workflows/dbt_test_daily.yml
vendored
26
.github/workflows/dbt_test_daily.yml
vendored
@ -48,9 +48,27 @@ jobs:
|
||||
run: |
|
||||
dbt test -m "fsc_evm,tag:daily_test"
|
||||
|
||||
notify-failure:
|
||||
needs: [run_dbt_jobs]
|
||||
notify:
|
||||
runs-on: ubuntu-latest
|
||||
needs: run_dbt_jobs
|
||||
if: failure()
|
||||
uses: FlipsideCrypto/fsc-evm/.github/workflows/slack_notify.yml@main
|
||||
secrets:
|
||||
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
|
||||
pip install -r requirements.txt
|
||||
dbt deps
|
||||
|
||||
- name: Send Slack notification
|
||||
run: python macros/python/slack_alert.py
|
||||
env:
|
||||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
||||
26
.github/workflows/dbt_test_intraday.yml
vendored
26
.github/workflows/dbt_test_intraday.yml
vendored
@ -48,9 +48,27 @@ jobs:
|
||||
run: |
|
||||
dbt test -m "fsc_evm,tag:recent_test"
|
||||
|
||||
notify-failure:
|
||||
needs: [run_dbt_jobs]
|
||||
notify:
|
||||
runs-on: ubuntu-latest
|
||||
needs: run_dbt_jobs
|
||||
if: failure()
|
||||
uses: FlipsideCrypto/fsc-evm/.github/workflows/slack_notify.yml@main
|
||||
secrets:
|
||||
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
|
||||
pip install -r requirements.txt
|
||||
dbt deps
|
||||
|
||||
- name: Send Slack notification
|
||||
run: python macros/python/slack_alert.py
|
||||
env:
|
||||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
||||
26
.github/workflows/dbt_test_monthly.yml
vendored
26
.github/workflows/dbt_test_monthly.yml
vendored
@ -48,9 +48,27 @@ jobs:
|
||||
run: |
|
||||
dbt test -m "fsc_evm,tag:full_test"
|
||||
|
||||
notify-failure:
|
||||
needs: [run_dbt_jobs]
|
||||
notify:
|
||||
runs-on: ubuntu-latest
|
||||
needs: run_dbt_jobs
|
||||
if: failure()
|
||||
uses: FlipsideCrypto/fsc-evm/.github/workflows/slack_notify.yml@main
|
||||
secrets:
|
||||
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
|
||||
pip install -r requirements.txt
|
||||
dbt deps
|
||||
|
||||
- name: Send Slack notification
|
||||
run: python macros/python/slack_alert.py
|
||||
env:
|
||||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
||||
74
macros/python/slack_alert.py
Normal file
74
macros/python/slack_alert.py
Normal 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("SLACK_WEBHOOK_URL")
|
||||
|
||||
if not webhook_url:
|
||||
print("ERROR: SLACK_WEBHOOK_URL environment variable is required")
|
||||
sys.exit(1)
|
||||
|
||||
send_alert(webhook_url)
|
||||
Loading…
Reference in New Issue
Block a user