From ddac7c4c0084454d38fec4a4ada230609ad063c7 Mon Sep 17 00:00:00 2001 From: GitHub Copilot Date: Mon, 7 Jul 2025 21:19:15 +0000 Subject: [PATCH 1/2] feat(ci): add JUnit XML test results and Codecov test analysis integration - Update nextest configuration to generate JUnit XML for CI profile - Add test results upload to Codecov in GitHub Actions workflow - Configure both test and coverage jobs to upload test results - Update .gitignore to exclude JUnit XML files - Add JUnit XML documentation to testing guidelines Related to #12 Signed-off-by: CHEN, CHUN --- .config/nextest.toml | 6 ++++++ .../workflows/build-test-audit-coverage.yml | 18 +++++++++++++++++ .gitignore | 4 ++++ docs/testing-guidelines.md | 20 +++++++++++++++++++ 4 files changed, 48 insertions(+) diff --git a/.config/nextest.toml b/.config/nextest.toml index 89e92f0..b7284ed 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -30,6 +30,12 @@ test-threads = 4 failure-output = "final" status-level = "fail" +[profile.ci.junit] +# JUnit XML 輸出設定 - CI 環境專用 +path = "junit.xml" +store-success-output = true +store-failure-output = true + [profile.quick] # 快速測試設定 retries = 0 diff --git a/.github/workflows/build-test-audit-coverage.yml b/.github/workflows/build-test-audit-coverage.yml index c4eef53..632dca8 100644 --- a/.github/workflows/build-test-audit-coverage.yml +++ b/.github/workflows/build-test-audit-coverage.yml @@ -69,6 +69,15 @@ jobs: env: RUST_LOG: debug + # Upload test results to Codecov + - name: Upload test results to Codecov + if: ${{ always() }} + uses: codecov/test-results-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: target/nextest/ci/junit.xml + flags: ${{ matrix.os }} + security: name: Security Audit runs-on: ubuntu-latest @@ -116,3 +125,12 @@ jobs: with: files: lcov.info fail_ci_if_error: false + + # Upload test results to Codecov + - name: Upload test results to Codecov + if: ${{ always() }} + uses: codecov/test-results-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: target/nextest/ci/junit.xml + flags: coverage diff --git a/.gitignore b/.gitignore index dc373dd..8f23f23 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,7 @@ Thumbs.db # Environment variables .env *.log + +# JUnit XML test results +junit.xml +target/nextest/*/junit.xml diff --git a/docs/testing-guidelines.md b/docs/testing-guidelines.md index df388a1..39f3ee7 100644 --- a/docs/testing-guidelines.md +++ b/docs/testing-guidelines.md @@ -650,6 +650,26 @@ fn test_with_performance_monitoring() { } ``` +## JUnit XML 測試結果 + +### 配置說明 +專案使用 nextest 生成 JUnit XML 格式的測試結果,主要用於 CI 環境: + +```bash +# CI profile 會自動生成 JUnit XML +cargo nextest run --profile ci +``` + +### 輸出位置 +- JUnit XML 檔案: `target/nextest/ci/junit.xml` +- 包含所有測試(成功與失敗)的詳細輸出和堆疊追蹤 + +### Codecov 測試分析 +測試結果會自動上傳到 Codecov,提供: +- 測試運行時間分析 +- 失敗率統計 +- 不穩定測試識別 + ## Conclusion Following these guidelines ensures that SubX maintains high code quality, safety, and testability. The dependency injection architecture enables comprehensive testing without sacrificing safety or performance. From 8b46cc07f7151d01bafab3180f3ce92fcbd361d9 Mon Sep 17 00:00:00 2001 From: GitHub Copilot Date: Mon, 7 Jul 2025 21:45:15 +0000 Subject: [PATCH 2/2] docs: docs Translate JUnit XML test results to English - Translate the JUnit XML testing results section and its subsections (Configuration, Output Location, Codecov Test Analysis) from Chinese to English. Signed-off-by: CHEN, CHUN --- docs/testing-guidelines.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/testing-guidelines.md b/docs/testing-guidelines.md index 39f3ee7..bb3da18 100644 --- a/docs/testing-guidelines.md +++ b/docs/testing-guidelines.md @@ -650,25 +650,25 @@ fn test_with_performance_monitoring() { } ``` -## JUnit XML 測試結果 +## JUnit XML Test Results -### 配置說明 -專案使用 nextest 生成 JUnit XML 格式的測試結果,主要用於 CI 環境: +### Configuration +The project uses nextest to generate JUnit XML format test results, primarily for CI environments: ```bash -# CI profile 會自動生成 JUnit XML +# CI profile automatically generates JUnit XML cargo nextest run --profile ci ``` -### 輸出位置 -- JUnit XML 檔案: `target/nextest/ci/junit.xml` -- 包含所有測試(成功與失敗)的詳細輸出和堆疊追蹤 +### Output Location +- JUnit XML file: `target/nextest/ci/junit.xml` +- Contains detailed output and stack traces for all tests (successful and failed) -### Codecov 測試分析 -測試結果會自動上傳到 Codecov,提供: -- 測試運行時間分析 -- 失敗率統計 -- 不穩定測試識別 +### Codecov Test Analysis +Test results are automatically uploaded to Codecov, providing: +- Test execution time analysis +- Failure rate statistics +- Flaky test identification ## Conclusion