Skip to content

Commit 19f924e

Browse files
CopilotMossaka
andauthored
ci: use local awf build in smoke workflows (#388)
* Initial plan * ci: use local awf build for smoke workflows Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com> * ci: make smoke workflow postprocess resilient Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com> * ci: tighten smoke workflow postprocess replace Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com> * ci: make smoke postprocess indentation-aware Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com> * ci: validate local awf wrapper setup Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com> * ci: allow all roles for smoke workflows * ci: post-process smoke workflows to use local awf build --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com> Co-authored-by: Jiaxiao (mossaka) Zhou <duibao55328@gmail.com>
1 parent 5fc836e commit 19f924e

5 files changed

Lines changed: 132 additions & 90 deletions

File tree

.github/workflows/smoke-claude.lock.yml

Lines changed: 26 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/smoke-claude.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
---
22
description: Smoke test workflow that validates Claude engine functionality by reviewing recent PRs twice daily
3-
on:
3+
on:
44
schedule: every 12h
55
workflow_dispatch:
66
pull_request:
77
types: [opened, synchronize, reopened]
88
reaction: "heart"
9+
roles: all
910
permissions:
1011
contents: read
1112
issues: read

.github/workflows/smoke-copilot.lock.yml

Lines changed: 26 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/smoke-copilot.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
---
22
description: Smoke Copilot
3-
on:
3+
on:
44
schedule: every 12h
55
workflow_dispatch:
66
pull_request:
77
types: [opened, synchronize, reopened]
88
reaction: "eyes"
9+
roles: all
910
permissions:
1011
contents: read
1112
pull-requests: read
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/usr/bin/env node
2+
3+
import * as fs from 'fs';
4+
import * as path from 'path';
5+
6+
const repoRoot = path.resolve(__dirname, '../..');
7+
const workflowPaths = [
8+
path.join(repoRoot, '.github/workflows/smoke-copilot.lock.yml'),
9+
path.join(repoRoot, '.github/workflows/smoke-claude.lock.yml'),
10+
];
11+
12+
// Matches the install step with captured indentation:
13+
// - "Install awf binary" step at any indent level
14+
// - run command invoking install_awf_binary.sh with a version
15+
const installStepRegex =
16+
/^(\s*)- name: Install awf binary\n\1\s*run: bash \/opt\/gh-aw\/actions\/install_awf_binary\.sh v[0-9.]+\n/m;
17+
const installStepRegexGlobal = new RegExp(installStepRegex.source, 'gm');
18+
19+
function buildLocalInstallSteps(indent: string): string {
20+
const stepIndent = indent;
21+
const runIndent = `${indent} `;
22+
const scriptIndent = `${runIndent} `;
23+
24+
return [
25+
`${stepIndent}- name: Install awf dependencies`,
26+
`${runIndent}run: npm ci`,
27+
`${stepIndent}- name: Build awf`,
28+
`${runIndent}run: npm run build`,
29+
`${stepIndent}- name: Install awf binary (local)`,
30+
`${runIndent}run: |`,
31+
`${scriptIndent}WORKSPACE_PATH="${'${GITHUB_WORKSPACE:-$(pwd)}'}"`,
32+
`${scriptIndent}NODE_BIN="$(command -v node)"`,
33+
`${scriptIndent}if [ ! -d "$WORKSPACE_PATH" ]; then`,
34+
`${scriptIndent} echo "Workspace path not found: $WORKSPACE_PATH"`,
35+
`${scriptIndent} exit 1`,
36+
`${scriptIndent}fi`,
37+
`${scriptIndent}if [ ! -x "$NODE_BIN" ]; then`,
38+
`${scriptIndent} echo "Node binary not found: $NODE_BIN"`,
39+
`${scriptIndent} exit 1`,
40+
`${scriptIndent}fi`,
41+
`${scriptIndent}if [ ! -d "/usr/local/bin" ]; then`,
42+
`${scriptIndent} echo "/usr/local/bin is missing"`,
43+
`${scriptIndent} exit 1`,
44+
`${scriptIndent}fi`,
45+
`${scriptIndent}sudo tee /usr/local/bin/awf > /dev/null <<EOF`,
46+
`${scriptIndent}#!/bin/bash`,
47+
`${scriptIndent}exec "${'${NODE_BIN}'}" "${'${WORKSPACE_PATH}'}/dist/cli.js" "\\$@"`,
48+
`${scriptIndent}EOF`,
49+
`${scriptIndent}sudo chmod +x /usr/local/bin/awf`,
50+
].join('\n') + '\n';
51+
}
52+
53+
for (const workflowPath of workflowPaths) {
54+
const content = fs.readFileSync(workflowPath, 'utf-8');
55+
const matches = content.match(installStepRegexGlobal);
56+
57+
if (!matches || matches.length === 0) {
58+
console.log(`Skipping ${workflowPath}: no awf install step found.`);
59+
continue;
60+
}
61+
62+
if (matches.length !== 1) {
63+
throw new Error(
64+
`Expected exactly one awf install step in ${workflowPath}, found ${matches.length}. ` +
65+
'Ensure the workflow has a single "Install awf binary" step in the agent job.'
66+
);
67+
}
68+
69+
const updated = content.replace(
70+
installStepRegexGlobal,
71+
(_match, indent: string) => buildLocalInstallSteps(indent)
72+
);
73+
74+
fs.writeFileSync(workflowPath, updated);
75+
console.log(`Updated ${workflowPath}`);
76+
}

0 commit comments

Comments
 (0)