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
90 changes: 90 additions & 0 deletions .github/workflows/docker-smoke-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Docker Smoke Test

on:
push:
branches: [master]
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- 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 proxy-default -p 8080:8080 codex-proxy-test

echo "Waiting for container to become healthy..."
for i in {1..30}; do
STATUS=$(docker inspect --format='{{.State.Health.Status}}' proxy-default)
if [ "$STATUS" = "healthy" ]; then
echo "Container is healthy!"
break
fi
if [ "$STATUS" = "unhealthy" ]; then
echo "Container is unhealthy!"
docker logs proxy-default
exit 1
fi
sleep 1
done

if [ "$(docker inspect --format='{{.State.Health.Status}}' proxy-default)" != "healthy" ]; then
echo "Container failed to become healthy within 30s"
docker logs proxy-default
exit 1
fi

STATUS_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/health)
if [ "$STATUS_CODE" != "200" ]; then
echo "Expected 200 from /health, got $STATUS_CODE"
docker logs proxy-default
exit 1
fi

docker rm -f proxy-default

- name: Test custom port (8090)
run: |
mkdir -p custom-config
cp config/default.yaml custom-config/
sed -i 's/port: 8080/port: 8090/' custom-config/default.yaml

docker run -d --name proxy-custom \
-p 8090:8090 \
-v $(pwd)/custom-config/default.yaml:/app/config/default.yaml \
codex-proxy-test

echo "Waiting for container to become healthy..."
for i in {1..30}; do
STATUS=$(docker inspect --format='{{.State.Health.Status}}' proxy-custom)
if [ "$STATUS" = "healthy" ]; then
echo "Container is healthy!"
break
fi
if [ "$STATUS" = "unhealthy" ]; then
echo "Container is unhealthy!"
docker logs proxy-custom
exit 1
fi
sleep 1
done

if [ "$(docker inspect --format='{{.State.Health.Status}}' proxy-custom)" != "healthy" ]; then
echo "Container failed to become healthy within 30s"
docker logs proxy-custom
exit 1
fi

STATUS_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8090/health)
if [ "$STATUS_CODE" != "200" ]; then
echo "Expected 200 from /health on port 8090, got $STATUS_CODE"
docker logs proxy-custom
exit 1
fi

docker rm -f proxy-custom
42 changes: 42 additions & 0 deletions .github/workflows/electron-smoke-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Electron Smoke Test

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

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

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

- name: Install dependencies
run: npm ci

- name: Build root project
run: npm run build

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

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

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

- name: Package Electron app
run: cd packages/electron && npx electron-builder --linux --dir -c.publish=never

- name: Run Electron smoke test
run: cd packages/electron && xvfb-run npm run test -- launch/smoke.test.ts
26 changes: 26 additions & 0 deletions .github/workflows/web-smoke-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Web Smoke Test

on:
push:
branches: [master]
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

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

- name: Install dependencies
run: npm ci

- name: Build root project
run: npm run build

- name: Run Web smoke test
run: npm test -- src/__tests__/web-smoke.test.ts
56 changes: 52 additions & 4 deletions package-lock.json

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

34 changes: 34 additions & 0 deletions packages/electron/__tests__/launch/smoke.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { test, expect } from "vitest";
import { _electron as electron } from "playwright";
import fs from "node:fs";
import path from "node:path";

test("Electron app launches and window opens", async () => {
// Find the linux-unpacked directory
const releaseDir = path.join(import.meta.dirname, "../../release");
const unpackedDirs = fs.readdirSync(releaseDir).filter(dir => dir.endsWith("-unpacked"));

if (unpackedDirs.length === 0) {
throw new Error(`No unpacked directory found in ${releaseDir}`);
}

const unpackedDir = path.join(releaseDir, unpackedDirs[0]);
const executableName = "@codex-proxyelectron"; // electron-builder default for this name

// Actually look for the binary
const binaryCandidates = fs.readdirSync(unpackedDir).filter(f => !f.endsWith(".so") && !f.endsWith(".pak") && !f.endsWith(".bin") && !f.includes("."));
const executablePath = path.join(unpackedDir, binaryCandidates.find(c => c === executableName || c === "codex-proxy") || binaryCandidates[0]);

console.log(`Launching executable: ${executablePath}`);

const electronApp = await electron.launch({
executablePath,
args: ['--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage'],
});

const window = await electronApp.firstWindow();
const title = await window.title();
expect(title).toBeDefined();

await electronApp.close();
});
3 changes: 2 additions & 1 deletion packages/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"devDependencies": {
"electron": "^35.7.5",
"electron-builder": "^26.0.0",
"esbuild": "^0.25.12"
"esbuild": "^0.25.12",
"playwright": "^1.58.2"
}
}
51 changes: 51 additions & 0 deletions src/__tests__/web-smoke.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { test, expect, beforeAll, afterAll } from "vitest";
import { spawn, ChildProcess } from "node:child_process";
import fs from "node:fs";
import path from "node:path";

let serverProcess: ChildProcess;

beforeAll(async () => {
// Start server
const env = { ...process.env, PORT: "8081" };
const indexPath = path.join(import.meta.dirname, "../../dist/index.js");

serverProcess = spawn("node", [indexPath], { env, stdio: "inherit" });

// Wait a bit for server to start
await new Promise(resolve => setTimeout(resolve, 2000));
}, 10000);

afterAll(() => {
if (serverProcess) {
serverProcess.kill();
}
});

test("CSS assets have light and dark theme rules", () => {
const assetsDir = path.join(import.meta.dirname, "../../public/assets");
const files = fs.readdirSync(assetsDir);
const cssFiles = files.filter(f => f.endsWith(".css"));

expect(cssFiles.length).toBeGreaterThan(0);

let foundDarkTheme = false;

for (const cssFile of cssFiles) {
const cssContent = fs.readFileSync(path.join(assetsDir, cssFile), "utf-8");
if (cssContent.includes("@media (prefers-color-scheme: dark)") || cssContent.includes("dark:")) {
foundDarkTheme = true;
break;
}
}

expect(foundDarkTheme).toBe(true);
});

test("Server serves HTML with #app div", async () => {
const response = await fetch("http://localhost:8081/");
expect(response.status).toBe(200);

const html = await response.text();
expect(html).toContain('<div id="app"></div>');
});
Loading