Skip to content

Commit 2e89afb

Browse files
committed
ci: add Slack message comparison to output-comparison job
- Add [SLACK_MESSAGE_START/END] markers in createSlackPoster for CI mode - Capture full monitor output instead of sed filtering - Extract and diff Slack messages separately from full output - Set NODE_ENV=CI and --enableAlerting when running monitors
1 parent 650c363 commit 2e89afb

File tree

2 files changed

+63
-20
lines changed

2 files changed

+63
-20
lines changed

.github/workflows/ci.yml

Lines changed: 53 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -176,20 +176,17 @@ jobs:
176176
yarn workspace batch-poster-monitor build
177177
yarn workspace retryable-monitor build
178178
179-
# Run each monitor and extract summary output (from summary header to end)
179+
# Run each monitor with --enableAlerting (NODE_ENV=CI outputs slack messages without posting)
180180
echo "=== ASSERTION MONITOR ===" > ../target-output.txt
181-
timeout 180s yarn workspace assertion-monitor dev --configPath=../../config.ci.json 2>&1 | \
182-
sed -n '/Assertion Monitor Alert Summary/,$p; /Monitoring complete/p' >> ../target-output.txt || true
181+
NODE_ENV=CI timeout 300s yarn workspace assertion-monitor dev --configPath=../../config.ci.json --enableAlerting >> ../target-output.txt 2>&1 || true
183182
184183
echo "" >> ../target-output.txt
185184
echo "=== BATCH POSTER MONITOR ===" >> ../target-output.txt
186-
timeout 180s yarn workspace batch-poster-monitor dev --configPath=../../config.ci.json 2>&1 | \
187-
sed -n '/Batch poster monitor summary/,$p' >> ../target-output.txt || true
185+
NODE_ENV=CI timeout 300s yarn workspace batch-poster-monitor dev --configPath=../../config.ci.json --enableAlerting >> ../target-output.txt 2>&1 || true
188186
189187
echo "" >> ../target-output.txt
190188
echo "=== RETRYABLE MONITOR ===" >> ../target-output.txt
191-
timeout 180s yarn workspace retryable-monitor dev --configPath=../../config.ci.json 2>&1 | \
192-
sed -n '/No retryables found/p; /retryables requiring action/,$p' >> ../target-output.txt || true
189+
NODE_ENV=CI timeout 300s yarn workspace retryable-monitor dev --configPath=../../config.ci.json --enableAlerting >> ../target-output.txt 2>&1 || true
193190
continue-on-error: true
194191

195192
- name: Run monitors on PR branch
@@ -202,20 +199,17 @@ jobs:
202199
yarn workspace batch-poster-monitor build
203200
yarn workspace retryable-monitor build
204201
205-
# Run each monitor and extract summary output (from summary header to end)
202+
# Run each monitor with --enableAlerting (NODE_ENV=CI outputs slack messages without posting)
206203
echo "=== ASSERTION MONITOR ===" > ../pr-output.txt
207-
timeout 180s yarn workspace assertion-monitor dev --configPath=../../config.ci.json 2>&1 | \
208-
sed -n '/Assertion Monitor Alert Summary/,$p; /Monitoring complete/p' >> ../pr-output.txt || true
204+
NODE_ENV=CI timeout 300s yarn workspace assertion-monitor dev --configPath=../../config.ci.json --enableAlerting >> ../pr-output.txt 2>&1 || true
209205
210206
echo "" >> ../pr-output.txt
211207
echo "=== BATCH POSTER MONITOR ===" >> ../pr-output.txt
212-
timeout 180s yarn workspace batch-poster-monitor dev --configPath=../../config.ci.json 2>&1 | \
213-
sed -n '/Batch poster monitor summary/,$p' >> ../pr-output.txt || true
208+
NODE_ENV=CI timeout 300s yarn workspace batch-poster-monitor dev --configPath=../../config.ci.json --enableAlerting >> ../pr-output.txt 2>&1 || true
214209
215210
echo "" >> ../pr-output.txt
216211
echo "=== RETRYABLE MONITOR ===" >> ../pr-output.txt
217-
timeout 180s yarn workspace retryable-monitor dev --configPath=../../config.ci.json 2>&1 | \
218-
sed -n '/No retryables found/p; /retryables requiring action/,$p' >> ../pr-output.txt || true
212+
NODE_ENV=CI timeout 300s yarn workspace retryable-monitor dev --configPath=../../config.ci.json --enableAlerting >> ../pr-output.txt 2>&1 || true
219213
continue-on-error: true
220214

221215
- name: Show captured output
@@ -226,34 +220,74 @@ jobs:
226220
echo "=== PR BRANCH OUTPUT ==="
227221
cat pr-output.txt
228222
223+
- name: Extract Slack messages
224+
run: |
225+
# Extract content between [SLACK_MESSAGE_START] and [SLACK_MESSAGE_END] markers
226+
extract_slack_messages() {
227+
sed -n '/\[SLACK_MESSAGE_START\]/,/\[SLACK_MESSAGE_END\]/p' | grep -v '\[SLACK_MESSAGE_'
228+
}
229+
230+
cat target-output.txt | extract_slack_messages > target-slack.txt || true
231+
cat pr-output.txt | extract_slack_messages > pr-slack.txt || true
232+
233+
echo "=== TARGET SLACK MESSAGES ==="
234+
cat target-slack.txt
235+
echo ""
236+
echo "=== PR SLACK MESSAGES ==="
237+
cat pr-slack.txt
238+
229239
- name: Normalize outputs and generate diff
230240
run: |
231241
# Normalize dynamic values (block numbers, addresses) for comparison
232242
normalize() {
233243
sed -E 's/[0-9]{7,}/BLOCK_NUM/g; s/[0-9]+n\b/BIGINT/g; s/0x[a-fA-F0-9]{40}/ADDR/g'
234244
}
235245
246+
# Normalize full output
236247
cat target-output.txt | normalize > target-normalized.txt
237248
cat pr-output.txt | normalize > pr-normalized.txt
238249
239-
# Generate unified diff (ignore exit code since diff returns 1 when files differ)
250+
# Normalize slack messages
251+
cat target-slack.txt | normalize > target-slack-normalized.txt
252+
cat pr-slack.txt | normalize > pr-slack-normalized.txt
253+
254+
# Generate unified diffs (ignore exit code since diff returns 1 when files differ)
240255
diff -u target-normalized.txt pr-normalized.txt > output-diff.txt || true
256+
diff -u target-slack-normalized.txt pr-slack-normalized.txt > slack-diff.txt || true
241257
242258
- name: Post comment
243259
uses: actions/github-script@v7
244260
with:
245261
script: |
246262
const fs = require('fs');
247263
248-
const diffOutput = fs.existsSync('output-diff.txt')
264+
const outputDiff = fs.existsSync('output-diff.txt')
249265
? fs.readFileSync('output-diff.txt', 'utf8').trim()
250266
: '';
251267
252-
const hasChanges = diffOutput.length > 0;
268+
const slackDiff = fs.existsSync('slack-diff.txt')
269+
? fs.readFileSync('slack-diff.txt', 'utf8').trim()
270+
: '';
271+
272+
const hasOutputChanges = outputDiff.length > 0;
273+
const hasSlackChanges = slackDiff.length > 0;
253274
254275
let body = '';
255-
if (hasChanges) {
256-
body = '### ⚠️ Monitor Output Changes\n\n```diff\n' + diffOutput + '\n```';
276+
277+
if (hasOutputChanges || hasSlackChanges) {
278+
body = '### ⚠️ Monitor Output Changes\n\n';
279+
280+
if (hasSlackChanges) {
281+
body += '#### Slack Message Changes\n```diff\n' + slackDiff + '\n```\n\n';
282+
} else {
283+
body += '#### ✅ Slack Messages: No Changes\n\n';
284+
}
285+
286+
if (hasOutputChanges) {
287+
body += '<details>\n<summary>Full Output Changes</summary>\n\n```diff\n' + outputDiff + '\n```\n</details>';
288+
} else {
289+
body += '#### ✅ Full Output: No Changes';
290+
}
257291
} else {
258292
body = '### ✅ Monitor Output: No Changes';
259293
}

packages/utils/createSlackPoster.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,23 @@ export const createSlackPoster = ({
88
channelEnvVar: string
99
}) => {
1010
return ({ message }: { message: string }) => {
11+
// In CI mode, output the message with markers for extraction (skip actual posting)
12+
if (process.env.NODE_ENV === 'CI') {
13+
if (message !== 'success') {
14+
console.log('[SLACK_MESSAGE_START]')
15+
console.log(message)
16+
console.log('[SLACK_MESSAGE_END]')
17+
}
18+
return
19+
}
20+
1121
const slackToken = process.env[tokenEnvVar]
1222
const slackChannel = process.env[channelEnvVar]
1323

1424
if (!slackToken) throw new Error('Slack token is required.')
1525
if (!slackChannel) throw new Error('Slack channel is required.')
1626

1727
if (process.env.NODE_ENV === 'DEV') return
18-
if (process.env.NODE_ENV === 'CI' && message === 'success') return
1928

2029
return postSlackMessage({
2130
slackToken,

0 commit comments

Comments
 (0)