Skip to content

Integrate daily pipeline health GitHub Action with Discord failure alerts #2

Integrate daily pipeline health GitHub Action with Discord failure alerts

Integrate daily pipeline health GitHub Action with Discord failure alerts #2

name: Test Tutorial Pipelines
on:
schedule:
# Run daily at 9 AM UTC
- cron: "0 9 * * *"
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
workflow_dispatch:
jobs:
test-pipelines:
runs-on: ubuntu-latest
strategy:
matrix:
pipeline:
- { name: "Hello World", path: "pipelines/helloWorld", file: "hello_pipeline.py" }
- { name: "Caching", path: "pipelines/caching", file: "cache_pipeline.py" }
- { name: "Fan Out", path: "pipelines/fanOut", file: "fan_pipeline.py" }
- { name: "Metadata", path: "pipelines/metadata", file: "meta_pipeline.py" }
- { name: "Parameters", path: "pipelines/parameters", file: "param_pipeline.py" }
- { name: "Retries", path: "pipelines/retries", file: "robust_pipeline.py" }
- { name: "Step I/O", path: "pipelines/stepIO", file: "io_pipeline.py" }
- { name: "Tagging", path: "pipelines/tagging", file: "tagged_pipeline.py" }
- { name: "Visualizations", path: "pipelines/visualizations", file: "viz_pipeline.py" }
- { name: "YAML Config", path: "pipelines/yamlConfig", file: "yaml_pipeline.py" }
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
# Install latest ZenML version
pip install zenml[server] --upgrade
# Install project dependencies
pip install -r requirements.txt
- name: Initialize ZenML
run: |
zenml init
zenml integration install discord -y
- name: Set up Discord alerter (if secrets available)
env:
DISCORD_TOKEN_SRE: ${{ secrets.DISCORD_TOKEN_SRE }}
DISCORD_SRE_CHANNEL_ID: ${{ secrets.DISCORD_SRE_CHANNEL_ID }}
if: ${{ env.DISCORD_TOKEN_SRE != '' && env.DISCORD_SRE_CHANNEL_ID != '' }}
run: |
# Create Discord secret
zenml secret create discord_secret --discord_token="${DISCORD_TOKEN_SRE}" || true
# Register Discord alerter
zenml alerter register discord_alerter \
--flavor=discord \
--discord_token="${DISCORD_TOKEN_SRE}" \
--default_discord_channel_id="${DISCORD_SRE_CHANNEL_ID}" || true
# Add to default stack
zenml stack update default -al discord_alerter || true
- name: Run ${{ matrix.pipeline.name }} Pipeline
id: run_pipeline
working-directory: ${{ matrix.pipeline.path }}
continue-on-error: true
run: |
echo "Running ${{ matrix.pipeline.name }} pipeline..."
python ${{ matrix.pipeline.file }}
- name: Check pipeline result
if: steps.run_pipeline.outcome == 'failure'
run: |
echo "Pipeline ${{ matrix.pipeline.name }} failed!"
exit 1
notify-discord:
needs: test-pipelines
runs-on: ubuntu-latest
if: ${{ failure() }}
steps:
- name: Send Discord notification on failure
uses: Ilshidur/action-discord@master
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_SRE }}
with:
args: |
🚨 **Pipeline Test Failure Alert** 🚨
**Repository:** ${{ github.repository }}
**Branch:** ${{ github.ref_name }}
**Workflow:** ${{ github.workflow }}
**Run:** ${{ github.run_id }}
Some tutorial pipelines failed to run with the latest ZenML version.
**Details:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
Please investigate and fix the failing pipelines.
@here #sre-alerts