Skip to content

Commit 2ecd20a

Browse files
workflow to run staging-monitor against testnet deployment (#643)
* add workflow to run staging-monitor against testnet deployment * maintain old secret for endpoint * add environment flag to webhook body * change env to CamelCase
1 parent bc133a3 commit 2ecd20a

File tree

3 files changed

+89
-3
lines changed

3 files changed

+89
-3
lines changed

.github/workflows/staging-monitor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
SLACK_WEBHOOK_URL: ${{ secrets.STAGING_TEST_SLACK_WEBHOOK }}
7272
run: |
7373
cd staging-monitor
74-
nix develop -c go run ./cmd/send-slack -webhook-url="$SLACK_WEBHOOK_URL"
74+
nix develop -c go run ./cmd/send-slack -webhook-url="$SLACK_WEBHOOK_URL" -environment Staging
7575
7676
- name: Fail job if test failed
7777
if: always()
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: CCIP TON Testnet Monitor
2+
permissions:
3+
contents: read
4+
5+
on:
6+
schedule:
7+
# Runs at minute 0, 15, 30, and 45 of every hour
8+
- cron: "*/15 * * * *"
9+
10+
workflow_dispatch: # Manual trigger from GitHub Actions UI
11+
12+
pull_request:
13+
types: [opened, synchronize, reopened, labeled]
14+
branches:
15+
- main
16+
17+
jobs:
18+
ccip-monitor-tests:
19+
# Toggle via CCIP_TESTNET_MONITOR_ENABLED variable (set to 'false' to disable)
20+
# Manual triggers (workflow_dispatch) always run regardless of toggle
21+
if: |
22+
github.event_name == 'workflow_dispatch' ||
23+
(vars.CCIP_TESTNET_MONITOR_ENABLED != 'false' && (
24+
github.event_name == 'schedule' ||
25+
(github.event_name == 'pull_request' &&
26+
contains(github.event.pull_request.labels.*.name, 'run-testnet-monitor-test'))
27+
))
28+
runs-on: ubuntu-latest
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
test:
33+
# Note: add more tests here, see staging-monitor/cmd/run-test/main.go and staging-monitor/README.md
34+
- ton2evm-messaging
35+
- evm2ton-messaging
36+
env:
37+
TON_TESTNET_SELECTOR: ${{ vars.TON_TESTNET_SELECTOR }}
38+
ETHEREUM_TESTNET_SEPOLIA_SELECTOR: ${{ vars.ETHEREUM_TESTNET_SEPOLIA_SELECTOR }}
39+
TON_TESTNET_ROUTER: ${{ secrets.TON_TESTNET_ROUTER }}
40+
TON_TESTNET_FEE_QUOTER: ${{ secrets.TON_TESTNET_FEE_QUOTER }}
41+
TON_TESTNET_RECEIVER: ${{ secrets.TON_TESTNET_RECEIVER }}
42+
TON_TESTNET_WALLET_KEY: ${{ secrets.TON_TESTNET_WALLET_KEY }}
43+
TON_TESTNET_ENDPOINT: ${{ secrets.STAGING_TON_TESTNET_ENDPOINT }}
44+
ETHEREUM_TESTNET_SEPOLIA_ROUTER: ${{ secrets.ETHEREUM_TESTNET_SEPOLIA_ROUTER }}
45+
ETHEREUM_TESTNET_SEPOLIA_RECEIVER: ${{ secrets.ETHEREUM_TESTNET_SEPOLIA_RECEIVER }}
46+
ETHEREUM_TESTNET_SEPOLIA_WALLET_KEY: ${{ secrets.ETHEREUM_TESTNET_SEPOLIA_WALLET_KEY }}
47+
ETHEREUM_TESTNET_SEPOLIA_ENDPOINT: ${{ secrets.STAGING_ETHEREUM_TESTNET_SEPOLIA_ENDPOINT }}
48+
MESSAGE: "ccip-testnet-${{ github.run_id }}"
49+
RUN_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
50+
TRIGGER: "${{ github.event_name }}"
51+
WHEN: "${{ github.run_started_at }}" # ISO8601
52+
steps:
53+
- name: Check out code
54+
uses: actions/checkout@v5
55+
56+
- name: Install Nix
57+
uses: cachix/install-nix-action@02a151ada4993995686f9ed4f1be7cfbb229e56f # v31
58+
with:
59+
nix_path: nixpkgs=channel:nixos-unstable
60+
61+
- name: Run ${{ matrix.test }} test
62+
id: test
63+
continue-on-error: true
64+
run: |
65+
cd staging-monitor
66+
nix develop -c go run ./cmd/run-test -case ${{ matrix.test }}
67+
68+
- name: Send Slack notification
69+
if: always()
70+
env:
71+
SLACK_WEBHOOK_URL: ${{ secrets.STAGING_TEST_SLACK_WEBHOOK }}
72+
run: |
73+
cd staging-monitor
74+
nix develop -c go run ./cmd/send-slack -webhook-url="$SLACK_WEBHOOK_URL" -environment Prod-Testnet
75+
76+
- name: Fail job if test failed
77+
if: always()
78+
run: |
79+
cd staging-monitor
80+
STATUS=$(jq -r '.status' result.json)
81+
if [[ "$STATUS" != "success" ]]; then
82+
echo "Test failed with status: $STATUS"
83+
exit 1
84+
fi

staging-monitor/cmd/send-slack/main.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ func main() {
2020
// optional, defaults to "result.json"
2121
resultFile := flag.String("result-file", "result.json", "Path to read test result JSON from")
2222
webhookURL := flag.String("webhook-url", "", "Slack webhook URL (required)")
23+
environment := flag.String("environment", "", "Environment (e.g. testnet, staging)")
2324
flag.Parse()
2425

2526
if *webhookURL == "" {
@@ -33,7 +34,7 @@ func main() {
3334
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
3435
defer cancel()
3536

36-
if err := sendSlackNoti(ctx, *resultFile, *webhookURL); err != nil {
37+
if err := sendSlackNoti(ctx, *resultFile, *webhookURL, *environment); err != nil {
3738
fmt.Fprintf(os.Stderr, "%v\n", err)
3839
exitCode = 1
3940
}
@@ -45,7 +46,7 @@ func main() {
4546
os.Exit(exitCode)
4647
}
4748

48-
func sendSlackNoti(ctx context.Context, resultFile, webhookURL string) error {
49+
func sendSlackNoti(ctx context.Context, resultFile, webhookURL string, environment string) error {
4950
// get GitHub Actions context from environment
5051
runURL := os.Getenv("RUN_URL")
5152
trigger := os.Getenv("TRIGGER")
@@ -88,6 +89,7 @@ func sendSlackNoti(ctx context.Context, resultFile, webhookURL string) error {
8889
"trigger": trigger,
8990
"when": when,
9091
"error": result.Error,
92+
"environment": environment,
9193
}
9294

9395
jsonPayload, err := json.Marshal(payload)

0 commit comments

Comments
 (0)