Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions scripts/ci/postprocess-smoke-workflows.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ const SESSION_STATE_DIR = '/tmp/gh-aw/sandbox/agent/session-state';

const sessionStateDirInjectionRegex =
/--audit-dir \/tmp\/gh-aw\/sandbox\/firewall\/audit(?! --session-state-dir)/g;
const legacyApiProxyLogsDirRegex =
/\/tmp\/gh-aw\/sandbox\/firewall\/logs\/api-proxy(?!-logs)/g;

const copySessionStateStepRegex =
/^(\s+)- name: Copy Copilot session state files to logs\n\1 if: always\(\)\n\1 continue-on-error: true\n\1 run: bash "\$\{RUNNER_TEMP\}\/gh-aw\/actions\/copy_copilot_session_state\.sh"\n/m;
Expand Down Expand Up @@ -357,6 +359,31 @@ describe('sessionStateDirInjectionRegex', () => {
});
});

describe('legacyApiProxyLogsDirRegex', () => {
beforeEach(() => {
legacyApiProxyLogsDirRegex.lastIndex = 0;
});

it('should match legacy api-proxy log directory path', () => {
const input = 'LOG_DIR="/tmp/gh-aw/sandbox/firewall/logs/api-proxy"';
expect(legacyApiProxyLogsDirRegex.test(input)).toBe(true);
});

it('should replace legacy path with api-proxy-logs path', () => {
const input = 'LOG_DIR="/tmp/gh-aw/sandbox/firewall/logs/api-proxy"';
const result = input.replace(
legacyApiProxyLogsDirRegex,
'/tmp/gh-aw/sandbox/firewall/logs/api-proxy-logs'
);
expect(result).toContain('/tmp/gh-aw/sandbox/firewall/logs/api-proxy-logs');
});

it('should not match already-updated api-proxy-logs path', () => {
const input = 'LOG_DIR="/tmp/gh-aw/sandbox/firewall/logs/api-proxy-logs"';
expect(legacyApiProxyLogsDirRegex.test(input)).toBe(false);
});
});

describe('copySessionStateStepRegex', () => {
const ORIGINAL_STEP =
' - name: Copy Copilot session state files to logs\n' +
Expand Down
15 changes: 15 additions & 0 deletions scripts/ci/postprocess-smoke-workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ const standaloneSkipPullRegex = /--skip-pull(?!\s+--build-local)/g;
const sessionStateDirInjectionRegex =
/--audit-dir \/tmp\/gh-aw\/sandbox\/firewall\/audit(?! --session-state-dir)/g;
const SESSION_STATE_DIR = '/tmp/gh-aw/sandbox/agent/session-state';
const legacyApiProxyLogsDirRegex =
/\/tmp\/gh-aw\/sandbox\/firewall\/logs\/api-proxy(?!-logs)/g;

// NOTE: Claude Code is intentionally NOT given --ignore-scripts because its
// postinstall script downloads the platform-specific native binary. Without it,
Expand Down Expand Up @@ -443,6 +445,19 @@ for (const workflowPath of workflowPaths) {
console.log(` --session-state-dir already present (or no awf invocation found)`);
}

// Normalize legacy api-proxy log directory paths to the current logs folder.
const legacyApiProxyLogDirMatches = content.match(legacyApiProxyLogsDirRegex);
if (legacyApiProxyLogDirMatches) {
content = content.replace(
legacyApiProxyLogsDirRegex,
'/tmp/gh-aw/sandbox/firewall/logs/api-proxy-logs'
);
modified = true;
console.log(
` Updated ${legacyApiProxyLogDirMatches.length} legacy api-proxy log path reference(s)`
);
}

// Claude Code: no --ignore-scripts injection (needs postinstall for native binary)

// Replace the "Copy Copilot session state files to logs" step with an inline
Expand Down
Loading