mirror of
https://github.com/FlipsideCrypto/near-models.git
synced 2026-02-06 11:47:00 +00:00
Add comprehensive failure analysis system that replaces basic Slack notifications with Claude Code SDK-powered root cause analysis and actionable recommendations. Key Features: - Generic failure assessor using Claude Code SDK for intelligent analysis - Enhanced Slack integration with formatted failure reports - Repository-agnostic design using GitHub Actions context - Comprehensive logging and error handling - Metadata-only analysis when logs are unavailable Components Added: - python/failure_assessor.py: Main analysis script with Claude Code SDK integration - .claude/agents/workflow-failure-investigator.md: Specialized failure analysis agent - Enhanced python/slack_alert.py with analysis text support - Updated dbt_run_adhoc.yml workflow with failure assessor integration Technical Improvements: - Removed hardcoded repository references for portability - Added proper GitHub CLI repository context handling - Implemented fallback analysis for cases with missing logs - Added claude-code-sdk and requests to requirements.txt 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
107 lines
2.6 KiB
YAML
107 lines
2.6 KiB
YAML
name: dbt_run_adhoc
|
|
run-name: ${{ inputs.dbt_command }}
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
branches:
|
|
- "main"
|
|
inputs:
|
|
environment:
|
|
type: choice
|
|
description: DBT Run Environment
|
|
required: true
|
|
options:
|
|
- dev
|
|
- prod
|
|
default: dev
|
|
warehouse:
|
|
type: choice
|
|
description: Snowflake warehouse
|
|
required: true
|
|
options:
|
|
- DBT
|
|
- DBT_CLOUD
|
|
- DBT_EMERGENCY
|
|
default: DBT
|
|
dbt_command:
|
|
type: string
|
|
description: "DBT Run Command"
|
|
required: true
|
|
|
|
env:
|
|
USE_VARS: "${{ vars.USE_VARS }}"
|
|
DBT_PROFILES_DIR: "${{ vars.DBT_PROFILES_DIR }}"
|
|
DBT_VERSION: "${{ vars.DBT_VERSION }}"
|
|
ACCOUNT: "${{ vars.ACCOUNT }}"
|
|
ROLE: "${{ vars.ROLE }}"
|
|
USER: "${{ vars.USER }}"
|
|
PASSWORD: "${{ secrets.PASSWORD }}"
|
|
REGION: "${{ vars.REGION }}"
|
|
DATABASE: "${{ vars.DATABASE }}"
|
|
WAREHOUSE: "${{ inputs.warehouse }}"
|
|
SCHEMA: "${{ vars.SCHEMA }}"
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}
|
|
|
|
jobs:
|
|
run_dbt_jobs:
|
|
runs-on: ubuntu-latest
|
|
environment:
|
|
name: workflow_${{ inputs.environment }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- uses: actions/setup-python@v4
|
|
with:
|
|
python-version: "3.10"
|
|
|
|
- name: install dependencies
|
|
run: |
|
|
pip install -r requirements.txt
|
|
dbt deps
|
|
- name: Run DBT Jobs
|
|
run: |
|
|
${{ inputs.dbt_command }}
|
|
|
|
failure-assessor:
|
|
needs: [run_dbt_jobs]
|
|
if: failure()
|
|
runs-on: ubuntu-latest
|
|
environment: workflow_prod
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '18'
|
|
|
|
- name: Install Claude Code CLI
|
|
run: npm install -g @anthropic-ai/claude-code
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.11"
|
|
|
|
- name: Install Python dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install -r requirements.txt
|
|
|
|
- name: Run Failure Assessor
|
|
env:
|
|
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
GITHUB_REPOSITORY: ${{ github.repository }}
|
|
GITHUB_WORKFLOW: ${{ github.workflow }}
|
|
GITHUB_SERVER_URL: ${{ github.server_url }}
|
|
run: |
|
|
python python/failure_assessor.py \
|
|
--run-id "${{ github.run_id }}" \
|
|
--agent-file ".claude/agents/workflow-failure-investigator.md" \
|
|
--repo "${{ github.repository }}"
|