Skip to content

Commit

Permalink
breaks out monitoring into into reusable workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
douglance committed Aug 15, 2024
1 parent 4484141 commit 2a7498d
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 43 deletions.
24 changes: 2 additions & 22 deletions .github/workflows/monitor-config.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,10 @@
{
"core": {
"generateCommand": "generateCoreChainsToMonitor",
"configFile": "__auto-generated-core-chains.json",
"slackTokens": {
"assertion": "CORE_CHAIN_ASSERTION_MONITORING_SLACK_TOKEN",
"batch-poster": "CORE_CHAIN_BATCH_POSTER_MONITORING_SLACK_TOKEN",
"retryable": "CORE_CHAIN_RETRYABLE_MONITORING_SLACK_TOKEN"
},
"slackChannels": {
"assertion": "CORE_CHAIN_ASSERTION_MONITORING_SLACK_CHANNEL",
"batch-poster": "CORE_CHAIN_BATCH_POSTER_MONITORING_SLACK_CHANNEL",
"retryable": "CORE_CHAIN_RETRYABLE_MONITORING_SLACK_CHANNEL"
}
"configFile": "__auto-generated-core-chains.json"
},
"orbit": {
"generateCommand": "generateOrbitChainsToMonitor",
"configFile": "__auto-generated-orbit-chains.json",
"slackTokens": {
"assertion": "ORBIT_CHAIN_ASSERTION_MONITORING_SLACK_TOKEN",
"batch-poster": "ORBIT_CHAIN_BATCH_POSTER_MONITORING_SLACK_TOKEN",
"retryable": "ORBIT_RETRYABLE_MONITORING_SLACK_TOKEN"
},
"slackChannels": {
"assertion": "ORBIT_CHAIN_ASSERTION_MONITORING_SLACK_CHANNEL",
"batch-poster": "ORBIT_CHAIN_BATCH_POSTER_MONITORING_SLACK_CHANNEL",
"retryable": "ORBIT_RETRYABLE_MONITORING_SLACK_CHANNEL"
}
"configFile": "__auto-generated-orbit-chains.json"
}
}
40 changes: 19 additions & 21 deletions .github/workflows/monitoring.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
name: Monitoring
name: Reusable Monitoring Workflow

on:
push:
workflow_dispatch:
schedule:
- cron: "0 */6 * * *" # Run every 6 hours
workflow_call:
inputs:
chain:
required: true
type: string
monitor:
required: true
type: string

env:
NEXT_PUBLIC_INFURA_KEY: ${{ secrets.NEXT_PUBLIC_INFURA_KEY }}
NOVA_MONITOR_RPC_URL: ${{ secrets.NOVA_MONITOR_RPC_URL }}
ARB_ONE_MONITOR_RPC_URL: ${{ secrets.ARB_ONE_MONITOR_RPC_URL }}
NODE_ENV: "CI"
RETRYABLE_MONITORING_SLACK_TOKEN: ${{ secrets.RETRYABLE_MONITORING_SLACK_TOKEN }}
RETRYABLE_MONITORING_SLACK_CHANNEL: ${{ secrets.RETRYABLE_MONITORING_SLACK_CHANNEL }}
BATCH_POSTER_MONITORING_SLACK_TOKEN: ${{ secrets.BATCH_POSTER_MONITORING_SLACK_TOKEN }}
BATCH_POSTER_MONITORING_SLACK_CHANNEL: ${{ secrets.BATCH_POSTER_MONITORING_SLACK_CHANNEL }}
ASSERTION_MONITORING_SLACK_TOKEN: ${{ secrets.ASSERTION_MONITORING_SLACK_TOKEN }}
ASSERTION_MONITORING_SLACK_CHANNEL: ${{ secrets.ASSERTION_MONITORING_SLACK_CHANNEL }}

jobs:
run-monitoring:
runs-on: ubuntu-latest
strategy:
matrix:
chain: [core, orbit]
monitor: [assertion, batch-poster, retryable]
steps:
- name: Checkout repositories
uses: actions/checkout@v4
Expand All @@ -43,25 +49,17 @@ jobs:
- name: Load configuration
id: config
run: |
CONFIG=$(cat .github/workflows/monitor-config.json | jq -r '.${{ matrix.chain }}')
CONFIG=$(cat .github/workflows/monitor-config.json | jq -r '.${{ inputs.chain }}')
echo "generate_command=$(echo $CONFIG | jq -r '.generateCommand')" >> $GITHUB_OUTPUT
echo "config_file=$(echo $CONFIG | jq -r '.configFile')" >> $GITHUB_OUTPUT
echo "slack_token=$(echo $CONFIG | jq -r '.slackTokens.${{ matrix.monitor }}')" >> $GITHUB_OUTPUT
echo "slack_channel=$(echo $CONFIG | jq -r '.slackChannels.${{ matrix.monitor }}')" >> $GITHUB_OUTPUT
- name: Generate chains JSON
run: yarn workspace arb-token-bridge-ui ${{ steps.config.outputs.generate_command }}
env:
BATCH_POSTER_MONITORING: ${{ matrix.monitor == 'batch-poster' }}
BATCH_POSTER_MONITORING: ${{ inputs.monitor == 'batch-poster' }}

- name: Copy chains JSON to Arbitrum Monitoring
run: cp ./packages/arb-token-bridge-ui/public/${{ steps.config.outputs.config_file }} ./arbitrum-monitoring/packages/${{ matrix.monitor }}-monitor/config.json
run: cp ./packages/arb-token-bridge-ui/public/${{ steps.config.outputs.config_file }} ./arbitrum-monitoring/packages/${{ inputs.monitor }}-monitor/config.json

- name: Run monitoring command
run: cd ./arbitrum-monitoring && yarn ${{ matrix.monitor }}-monitor --enableAlerting
env:
SLACK_TOKEN: ${{ secrets[steps.config.outputs.slack_token] }}
SLACK_CHANNEL: ${{ secrets[steps.config.outputs.slack_channel] }}

- name: Clean up
run: rm ./packages/arb-token-bridge-ui/public/${{ steps.config.outputs.config_file }}
run: cd ./arbitrum-monitoring && yarn ${{ inputs.monitor }}-monitor --enableAlerting
19 changes: 19 additions & 0 deletions .github/workflows/six-hour-monitoring.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 6-Hour Monitoring

on:
push:
workflow_dispatch:
schedule:
- cron: "0 */6 * * *" # Run every 6 hours

jobs:
run-monitoring:
strategy:
matrix:
chain: [core, orbit]
monitor: [assertion, batch-poster]
uses: ./.github/workflows/monitoring.yml
with:
chain: ${{ matrix.chain }}
monitor: ${{ matrix.monitor }}
secrets: inherit
18 changes: 18 additions & 0 deletions .github/workflows/twenty-four-hour-monitoring.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: 24-Hour Monitoring

on:
push:
workflow_dispatch:
schedule:
- cron: "0 0 * * *" # Run every 24 hours at midnight UTC

jobs:
run-retryable-monitoring:
strategy:
matrix:
chain: [core, orbit]
uses: ./.github/workflows/monitoring.yml
with:
chain: ${{ matrix.chain }}
monitor: retryable
secrets: inherit

0 comments on commit 2a7498d

Please sign in to comment.