Repository navigation
268 lines (232 loc) · 10.5 KB
/
Copy pathnitro-cli-e2e.yml
File metadata and controls
268 lines (232 loc) · 10.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
name: nitro-cli-e2e
on:
push:
branches:
- main
- main-version-*
paths:
- 'src/Nitro/CommandLine/**'
- 'src/Nitro/Common/**'
- '.github/workflows/nitro-cli-e2e.yml'
- 'global.json'
- 'src/Directory.Packages.props'
pull_request:
paths:
- 'src/Nitro/CommandLine/**'
- 'src/Nitro/Common/**'
- '.github/workflows/nitro-cli-e2e.yml'
- 'global.json'
- 'src/Directory.Packages.props'
workflow_dispatch:
permissions:
contents: read
pull-requests: write
concurrency:
group: nitro-cli-e2e-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
aot-publish-smoke:
runs-on: ubuntu-26.04
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install .NET
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
- name: Publish AOT self-contained binary (linux-x64)
run: |
dotnet publish src/Nitro/CommandLine/src/CommandLine \
-c Release \
-r linux-x64 \
-f net11.0 \
-o publish \
--self-contained \
-p:PublishAot=true \
-p:TargetFrameworks=net11.0 \
-p:RuntimeIdentifiers=linux-x64
- name: Smoke test the published binary
run: |
set -euo pipefail
nitro_bin="$(pwd)/publish/nitro"
"$nitro_bin" --version
work_dir="$(mktemp -d)"
cd "$work_dir"
"$nitro_bin" agent init
# Actor names are allocated, never invented: `agent login` mints one
# the way a harness without a session-start hook does. Only the
# commands that record an actor take --actor; the read-only ones
# below have no such option.
actor="$("$nitro_bin" agent login --output json \
| tr -d '\n' | sed -n 's/.*"actor"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p')"
if [ -z "$actor" ]; then
echo "::error::Could not parse an actor out of the login output." >&2
exit 1
fi
"$nitro_bin" agent tasks list
create_output="$("$nitro_bin" agent tasks create "AOT smoke test task" --actor "$actor")"
echo "$create_output"
task_id=$(printf '%s' "$create_output" | sed -n "s/.*'\([^']*\)'.*/\1/p")
if [ -z "$task_id" ]; then
echo "::error::Could not parse a task ID out of the create output above." >&2
exit 1
fi
"$nitro_bin" agent tasks show "$task_id"
# Widen the smoke past task CRUD: mail, memory and the agent
# registry each fall back to reflection Dapper when a call isn't
# AOT-interceptable, so exercise every store here too.
if ! "$nitro_bin" agent register --actor "$actor" --role planner; then
echo "::error::agent register --actor \"$actor\" --role planner failed." >&2
exit 1
fi
if ! list_output="$("$nitro_bin" agent list --output json)"; then
echo "::error::agent list --output json failed." >&2
exit 1
fi
echo "$list_output"
if ! printf '%s' "$list_output" | tr -d '\n' | grep -Eq \
"\"name\"[[:space:]]*:[[:space:]]*\"$actor\"[^}]*\"online\"[[:space:]]*:[[:space:]]*(true|false)"; then
echo "::error::agent list --output json did not report actor \"$actor\" with an online flag." >&2
exit 1
fi
if ! "$nitro_bin" agent mail send --to "$actor" --actor "$actor" \
--subject "AOT smoke" --body "hello"; then
echo "::error::agent mail send --to \"$actor\" --actor \"$actor\" --subject \"AOT smoke\" --body \"hello\" failed." >&2
exit 1
fi
if ! inbox_output="$("$nitro_bin" agent mail inbox --actor "$actor" --output json)"; then
echo "::error::agent mail inbox --actor \"$actor\" --output json failed." >&2
exit 1
fi
echo "$inbox_output"
message_count="$(printf '%s' "$inbox_output" | grep -c '"id"' || true)"
if [ "$message_count" -ne 1 ]; then
echo "::error::agent mail inbox --actor \"$actor\" --output json did not report exactly one message." >&2
exit 1
fi
if ! "$nitro_bin" agent memory save "AOT smoke memory" --type fact --actor "$actor"; then
echo "::error::agent memory save \"AOT smoke memory\" --type fact --actor \"$actor\" failed." >&2
exit 1
fi
if ! "$nitro_bin" agent memory context; then
echo "::error::agent memory context failed." >&2
exit 1
fi
if ! search_output="$("$nitro_bin" agent memory search "smoke" --output json)"; then
echo "::error::agent memory search \"smoke\" --output json failed." >&2
exit 1
fi
echo "$search_output"
if ! printf '%s' "$search_output" | grep -q '"id"'; then
echo "::error::agent memory search \"smoke\" --output json did not report any memories." >&2
exit 1
fi
if ! "$nitro_bin" agent tasks close "$task_id" --actor "$actor" --reason "smoke"; then
echo "::error::agent tasks close \"$task_id\" --actor \"$actor\" --reason \"smoke\" failed." >&2
exit 1
fi
record-and-verify:
runs-on: ubuntu-26.04
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install .NET
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
- name: Record + verify all flows
id: record
continue-on-error: true
run: ./src/Nitro/CommandLine/test/e2e/run.sh
- name: Upload snapshot artifacts
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: nitro-e2e-snapshots
path: |
src/Nitro/CommandLine/test/e2e/out/*.gif
src/Nitro/CommandLine/test/e2e/out/report/**
if-no-files-found: warn
- name: Comment changed snapshots on PR
if: always() && github.event_name == 'pull_request'
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
RUN_ID: ${{ github.run_id }}
with:
script: |
const { owner, repo } = context.repo;
const pr = context.payload.pull_request;
const prNum = pr.number;
const baseRef = pr.base.ref;
const MARKER = '<!-- nitro-e2e-snapshots -->';
const bust = `?run=${process.env.RUN_ID}`;
const rawBase = `https://raw.githubusercontent.com/${pr.base.repo.full_name}/${pr.base.sha}`;
const headFull = pr.head.repo && pr.head.repo.full_name;
const rawHead = headFull
? `https://raw.githubusercontent.com/${headFull}/${pr.head.sha}`
: null;
const files = await github.paginate(github.rest.pulls.listFiles,
{ owner, repo, pull_number: prNum, per_page: 100 });
const re = /^src\/Nitro\/CommandLine\/test\/e2e\/([^/]+)-flow\.gif$/;
const changed = [];
for (const f of files) {
const m = f.filename.match(re);
if (m) changed.push(
{ flow: m[1], status: f.status, path: f.filename, prev: f.previous_filename });
}
changed.sort((a, b) => a.flow.localeCompare(b.flow));
async function upsertComment(body) {
const { data: comments } = await github.rest.issues.listComments(
{ owner, repo, issue_number: prNum, per_page: 100 });
const existing = comments.find(c => c.body && c.body.includes(MARKER));
if (existing) {
await github.rest.issues.updateComment(
{ owner, repo, comment_id: existing.id, body });
} else {
await github.rest.issues.createComment(
{ owner, repo, issue_number: prNum, body });
}
}
if (changed.length === 0) {
try {
await upsertComment(
`${MARKER}\n✅ **Nitro CLI E2E snapshots**: no flow recordings changed vs \`${baseRef}\`.`);
} catch (e) {
core.warning(`comment failed (expected on forks): ${e}`);
}
return;
}
const img = url => `<img src="${url}${bust}" width="480" alt="recording">`;
const ICON = { added: '🆕', removed: '🗑️' };
const blocks = [];
for (const { flow, status, path, prev } of changed) {
const before = `${rawBase}/${prev || path}`;
const after = rawHead ? `${rawHead}/${path}` : null;
let inner;
if (status === 'added') {
inner = after ? `\n\n${img(after)}\n` : '\n\n_after unavailable_\n';
} else if (status === 'removed') {
inner = `\n\n${img(before)}\n`;
} else {
const afterCell = after ? img(after) : '<em>unavailable</em>';
inner =
`\n\n<table><tr><th>Before: <code>${baseRef}</code></th><th>After: this PR</th></tr>`
+ `<tr><td>${img(before)}</td><td>${afterCell}</td></tr></table>\n`;
}
blocks.push(
`<details><summary>${ICON[status] || '🔁'} ${flow}: ${status}</summary>${inner}</details>`);
}
const body = [
MARKER,
'### 🎬 Nitro CLI E2E snapshots changed',
'',
`These flow recordings differ from \`${baseRef}\` (added, removed, or modified). `
+ 'Expand each for the before/after.',
'',
...blocks,
'',
`<sub>Run ${process.env.RUN_ID} · full set in the <b>nitro-e2e-snapshots</b> artifact.</sub>`,
].join('\n');
try { await upsertComment(body); }
catch (e) { core.warning(`comment failed (expected on forks): ${e}`); }
- name: Fail if any flow drifted from its golden
if: always() && steps.record.outcome == 'failure'
run: |
echo "::error::E2E recordings drifted from their committed golden, review the nitro-e2e-snapshots artifact, then run ./src/Nitro/CommandLine/test/e2e/run.sh --update <flow> if intended." >&2
exit 1