Skip to content
Open
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
59 changes: 59 additions & 0 deletions .github/workflows/docker-smoke-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: "test: CI smoke test — Docker image builds and starts healthy"

on:
push:
branches:
- master
pull_request:

jobs:
docker-smoke-test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Build Docker image
run: docker build -t codex-proxy-test .

- name: Test default port 8080
run: |
docker run -d --name codex-test-8080 -p 8080:8080 codex-proxy-test
# Wait for healthcheck to pass (up to 30s)
timeout 30s bash -c 'until curl -s http://localhost:8080/health | grep -q "ok"; do sleep 1; done'
# Verify 200 OK from /health
STATUS=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/health)
if [ "$STATUS" -ne 200 ]; then
echo "Expected 200, got $STATUS"
exit 1
fi

- name: Cleanup default port container
run: |
docker stop codex-test-8080
docker rm codex-test-8080

- name: Test custom port 8090
run: |
# Create a modified config
mkdir -p /tmp/config
cp config/default.yaml /tmp/config/default.yaml
sed -i 's/port: 8080/port: 8090/' /tmp/config/default.yaml

# Run container with modified config mounted
docker run -d --name codex-test-8090 -p 8090:8090 -v /tmp/config/default.yaml:/app/config/default.yaml codex-proxy-test

# Wait for healthcheck to pass (up to 30s)
timeout 30s bash -c 'until curl -s http://localhost:8090/health | grep -q "ok"; do sleep 1; done'

# Verify 200 OK from /health
STATUS=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8090/health)
if [ "$STATUS" -ne 200 ]; then
echo "Expected 200, got $STATUS"
exit 1
fi

- name: Cleanup custom port container
run: |
docker stop codex-test-8090
docker rm codex-test-8090
46 changes: 46 additions & 0 deletions .github/workflows/electron-smoke-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: "test: CI smoke test — Electron app packages and launches"

on:
push:
branches:
- master
paths:
- 'packages/electron/**'
pull_request:
paths:
- 'packages/electron/**'

jobs:
electron-smoke-test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install root dependencies
run: npm ci

- name: Install Playwright & Chromium dependencies
run: npx playwright install --with-deps chromium

- name: Build root
run: npm run build

- name: Build Electron app
run: cd packages/electron && npm run build

- name: Prepare pack
run: cd packages/electron && node electron/prepare-pack.mjs

- name: Package with electron-builder
run: cd packages/electron && npx electron-builder --linux --dir

- name: Run Playwright test
run: xvfb-run -a npm run test -- packages/electron/__tests__/launch/smoke.test.ts
env:
CI: 'true'
28 changes: 28 additions & 0 deletions .github/workflows/web-smoke-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "test: CI smoke test — web frontend builds and serves"

on:
push:
branches:
- master
pull_request:

jobs:
web-smoke-test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install root dependencies
run: npm ci

- name: Build project
run: npm run build

- name: Run Web Smoke Test
run: npm test -- src/__tests__/web-smoke.test.ts
73 changes: 69 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions packages/electron/__tests__/launch/smoke.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
import { _electron, type ElectronApplication } from 'playwright';
import path from 'path';
import fs from 'fs';

// Define a directory for playwright user data
const USER_DATA_DIR = path.join(import.meta.dirname, '.test-user-data');

// Clean up user data dir before tests
if (fs.existsSync(USER_DATA_DIR)) {
fs.rmSync(USER_DATA_DIR, { recursive: true, force: true });
}

describe.runIf(process.env.CI || process.env.RUN_E2E_SMOKE)('Electron Smoke Test', () => {
let app: ElectronApplication;

beforeAll(async () => {
// Resolve the binary path for testing the packed output in directory mode.
// The instructions say "Package with npx electron-builder --linux --dir"
// The productName is "Codex Proxy". electron-builder usually produces an executable named after productName or name.

// In linux-unpacked, electron-builder lowercases and hyphenates the name if productName has spaces, or keeps it.
// Let's try "codex-proxy" as it is the name in package.json

let executablePath = path.join(import.meta.dirname, '../../release/linux-unpacked/codex-proxy');

const linuxUnpackedExe = path.join(import.meta.dirname, '../../release/linux-unpacked/@codex-proxyelectron');
if (fs.existsSync(linuxUnpackedExe)) {
executablePath = linuxUnpackedExe;
} else if (fs.existsSync(path.join(import.meta.dirname, '../../release/linux-unpacked/Codex Proxy'))) {
executablePath = path.join(import.meta.dirname, '../../release/linux-unpacked/Codex Proxy');
}

app = await _electron.launch({
executablePath,
args: ['--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage', '--user-data-dir=' + USER_DATA_DIR],
env: {
...process.env,
ELECTRON_ENABLE_LOGGING: '1',
DISABLE_NATIVE_TRANSPORT: '1', // Bypasses native transport errors during testing
},
});

app.process().stdout?.on('data', (data) => console.log(data.toString()));
app.process().stderr?.on('data', (data) => console.error(data.toString()));
});

afterAll(async () => {
if (app) {
await app.close();
}
// Clean up
if (fs.existsSync(USER_DATA_DIR)) {
fs.rmSync(USER_DATA_DIR, { recursive: true, force: true });
}
});

it('launches the app and opens the main window', async () => {
const window = await app.firstWindow();
expect(window).toBeTruthy();

// Check if window is visible and hasn't crashed
const title = await window.title();
expect(typeof title).toBe('string');
}, 60000);
});
4 changes: 3 additions & 1 deletion packages/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
"electron-updater": "^6.3.0"
},
"devDependencies": {
"@playwright/test": "^1.49.0",
"electron": "^35.7.5",
"electron-builder": "^26.0.0",
"esbuild": "^0.25.12"
"esbuild": "^0.25.12",
"playwright": "^1.49.0"
}
}
Loading
Loading