chore: release v0.1.13 - 翻譯測試使用免費服務並修復測試

This commit is contained in:
Your Name 2026-01-23 12:43:16 +08:00
parent bed996e70b
commit bcaddc225c
5 changed files with 43 additions and 24 deletions

View file

@ -238,10 +238,11 @@ jobs:
retention-days: 7 retention-days: 7
# ============================================ # ============================================
# Job 4: Translation tests (optional, needs API keys) # Job 4: Translation tests (使用免費翻譯服務)
# 使用 Google/Bing 免費翻譯,不需要付費 API 金鑰
# ============================================ # ============================================
translation-tests: translation-tests:
name: Translation Tests name: Translation Tests (Free Services)
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
needs: build-test-image needs: build-test-image
if: ${{ github.event.inputs.run_translation_tests == 'true' || github.event_name == 'push' }} if: ${{ github.event.inputs.run_translation_tests == 'true' || github.event_name == 'push' }}
@ -262,21 +263,16 @@ jobs:
run: docker pull ${{ needs.build-test-image.outputs.image }} run: docker pull ${{ needs.build-test-image.outputs.image }}
- name: Run translation tests - name: Run translation tests
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
DEEPL_API_KEY: ${{ secrets.DEEPL_API_KEY }}
run: | run: |
echo "🌍 Running translation tests..." echo "🌍 Running translation tests (using free services: Google/Bing)..."
docker run --rm \ docker run --rm \
--name convertx-translation-test \ --name convertx-translation-test \
-v "${{ github.workspace }}/tests:/app/tests" \ -v "${{ github.workspace }}/tests:/app/tests" \
-v "${{ github.workspace }}/translation-results:/app/translation-results" \ -v "${{ github.workspace }}/translation-results:/app/translation-results" \
-e OPENAI_API_KEY="${OPENAI_API_KEY}" \
-e GOOGLE_API_KEY="${GOOGLE_API_KEY}" \
-e DEEPL_API_KEY="${DEEPL_API_KEY}" \
-e CI=true \ -e CI=true \
-e PDFMATHTRANSLATE_SERVICE=google \
-e BABELDOC_SERVICE=google \
--entrypoint /bin/bash \ --entrypoint /bin/bash \
${{ needs.build-test-image.outputs.image }} \ ${{ needs.build-test-image.outputs.image }} \
-c " -c "
@ -284,7 +280,7 @@ jobs:
cd /app cd /app
bun install --frozen-lockfile || bun install bun install --frozen-lockfile || bun install
echo '🌍 Running translation tests...' echo '🌍 Running translation tests with free services...'
bun test tests/e2e/translation.e2e.test.ts --timeout 600000 || true bun test tests/e2e/translation.e2e.test.ts --timeout 600000 || true
mkdir -p /app/translation-results mkdir -p /app/translation-results

View file

@ -1,5 +1,21 @@
# Changelog # Changelog
## [0.1.13](https://github.com/pi-docket/ConvertX-CN/releases/tag/v0.1.13) (2026-01-23)
工作流程優化與測試修復版本。
### 📦 CI/CD
- **翻譯測試優化**改用免費翻譯服務Google/Bing移除付費 API 金鑰依賴
- **自動化測試**:翻譯測試現在會在 push 時自動執行
### 🧪 Testing
- **Inkscape 測試修復**:更新測試以配合 xvfb-run 包裝器
- **format-matrix 測試修復**:修復超時參數中的 `sampled` 未定義錯誤
---
## [0.1.12](https://github.com/pi-docket/ConvertX-CN/releases/tag/v0.1.12) (2026-01-23) ## [0.1.12](https://github.com/pi-docket/ConvertX-CN/releases/tag/v0.1.12) (2026-01-23)
測試與品質強化版本,大幅提升 CI/CD 可靠性與測試覆蓋率。 測試與品質強化版本,大幅提升 CI/CD 可靠性與測試覆蓋率。

View file

@ -1,6 +1,6 @@
{ {
"name": "convertx-frontend", "name": "convertx-frontend",
"version": "0.1.12", "version": "0.1.13",
"scripts": { "scripts": {
"dev": "bun run --watch src/index.tsx", "dev": "bun run --watch src/index.tsx",
"hot": "bun run --hot src/index.tsx", "hot": "bun run --hot src/index.tsx",

View file

@ -4,10 +4,10 @@ import type { ExecFileException } from "node:child_process";
import { ExecFileFn } from "../../src/converters/types"; import { ExecFileFn } from "../../src/converters/types";
// Inkscape 測試 // Inkscape 測試
// 使用 Inkscape 1.0+ 的 headless-safe 命令列語法: // 使用 xvfb-run 包裝 Inkscape 命令,確保在無 DISPLAY 環境下也能運作
// inkscape input.png --export-type=svg --export-filename=output.svg // xvfb-run -a --server-args="-screen 0 1024x768x24" inkscape input.svg --export-type=png --export-filename=output.png
test("convert uses correct headless-safe arguments", async () => { test("convert uses correct xvfb-run wrapped arguments", async () => {
let capturedCmd = ""; let capturedCmd = "";
let capturedArgs: string[] = []; let capturedArgs: string[] = [];
@ -23,8 +23,15 @@ test("convert uses correct headless-safe arguments", async () => {
await convert("input.svg", "svg", "png", "output.png", undefined, mockExecFile); await convert("input.svg", "svg", "png", "output.png", undefined, mockExecFile);
expect(capturedCmd).toBe("inkscape"); expect(capturedCmd).toBe("xvfb-run");
expect(capturedArgs).toEqual(["input.svg", "--export-type=png", "--export-filename=output.png"]); expect(capturedArgs).toEqual([
"-a",
"--server-args=-screen 0 1024x768x24",
"inkscape",
"input.svg",
"--export-type=png",
"--export-filename=output.png",
]);
}); });
test("convert resolves when inkscape succeeds", async () => { test("convert resolves when inkscape succeeds", async () => {
@ -33,7 +40,7 @@ test("convert resolves when inkscape succeeds", async () => {
_args: string[], _args: string[],
callback: (err: ExecFileException | null, stdout: string, stderr: string) => void, callback: (err: ExecFileException | null, stdout: string, stderr: string) => void,
) => { ) => {
if (cmd === "inkscape") { if (cmd === "xvfb-run") {
callback(null, "Conversion complete", ""); callback(null, "Conversion complete", "");
} }
}; };
@ -48,7 +55,7 @@ test("convert rejects when inkscape fails", async () => {
_args: string[], _args: string[],
callback: (err: ExecFileException | null, stdout: string, stderr: string) => void, callback: (err: ExecFileException | null, stdout: string, stderr: string) => void,
) => { ) => {
if (cmd === "inkscape") { if (cmd === "xvfb-run") {
callback(new Error("inkscape failed"), "", ""); callback(new Error("inkscape failed"), "", "");
} }
}; };
@ -72,7 +79,7 @@ test("convert logs stdout when present", async () => {
_args: string[], _args: string[],
callback: (err: ExecFileException | null, stdout: string, stderr: string) => void, callback: (err: ExecFileException | null, stdout: string, stderr: string) => void,
) => { ) => {
if (cmd === "inkscape") { if (cmd === "xvfb-run") {
callback(null, "Fake stdout", ""); callback(null, "Fake stdout", "");
} }
}; };
@ -97,7 +104,7 @@ test("convert logs stderr when present (non-fatal warning)", async () => {
_args: string[], _args: string[],
callback: (err: ExecFileException | null, stdout: string, stderr: string) => void, callback: (err: ExecFileException | null, stdout: string, stderr: string) => void,
) => { ) => {
if (cmd === "inkscape") { if (cmd === "xvfb-run") {
// Inkscape 經常輸出警告到 stderr但轉換仍成功 // Inkscape 經常輸出警告到 stderr但轉換仍成功
callback(null, "", "Some warning message"); callback(null, "", "Some warning message");
} }

View file

@ -537,7 +537,7 @@ describe("📊 格式轉換矩陣 Format Conversion Matrix", () => {
} }
} }
}, },
TIMEOUT * sampled.length, TIMEOUT * MAX_TESTS_PER_CONVERTER,
); );
}); });
} }
@ -634,7 +634,7 @@ describe("📊 格式轉換矩陣 Format Conversion Matrix", () => {
} }
} }
}, },
TIMEOUT * sampled.length, TIMEOUT * MAX_TESTS_PER_CONVERTER,
); );
}); });
} }
@ -714,7 +714,7 @@ describe("📊 格式轉換矩陣 Format Conversion Matrix", () => {
} }
} }
}, },
TIMEOUT * sampled.length, TIMEOUT * MAX_TESTS_PER_CONVERTER,
); );
}); });
} }