From a952e491a56c6541a6009700b188806b7060db50 Mon Sep 17 00:00:00 2001 From: RAprogramm Date: Fri, 17 Oct 2025 11:45:17 +0700 Subject: [PATCH] Refactored CI to match working configuration from infra-metrics-insight-renderer. Changes: - Coverage job: removed id-token permission and test-results-action - Test job: added nextest with ci profile for MSRV, uploads test results - cargo-test action: added nextest-profile parameter for JUnit XML generation - Removed redundant JSON test report generation and artifact uploads - Simplified summary outputs for better clarity Benefits: - Coverage and test analytics properly separated - Token-based authentication only (no OIDC conflicts) - JUnit XML auto-generated via nextest ci profile - Cleaner job responsibilities and artifact management Test plan: - All 236 tests pass with nextest ci profile - JUnit XML generated at target/nextest/ci/junit.xml (43KB) - YAML validation successful Closes #213 --- .config/nextest.toml | 3 +- .github/actions/cargo-test/action.yml | 34 +++++++--- .github/workflows/reusable-ci.yml | 92 +++++++++------------------ README.md | 1 - 4 files changed, 57 insertions(+), 73 deletions(-) diff --git a/.config/nextest.toml b/.config/nextest.toml index 2b6a93c..191470a 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -19,9 +19,10 @@ slow-timeout = { period = "60s", terminate-after = 2 } retries = { backoff = "exponential", count = 2, delay = "1s" } # Fail fast disabled to see all failures fail-fast = false + # Enable JUnit XML output for Codecov Test Analytics [profile.ci.junit] -path = "target/nextest/ci/junit.xml" +path = "junit.xml" # Store output for failed tests only store-success-output = false store-failure-output = true diff --git a/.github/actions/cargo-test/action.yml b/.github/actions/cargo-test/action.yml index dad2867..9d7081d 100644 --- a/.github/actions/cargo-test/action.yml +++ b/.github/actions/cargo-test/action.yml @@ -20,6 +20,10 @@ inputs: description: "Additional arguments passed to cargo test" required: false default: "" + nextest-profile: + description: "Nextest profile to use (empty = use regular cargo test)" + required: false + default: "" runs: using: "composite" steps: @@ -30,19 +34,33 @@ runs: ALL_FEATURES: ${{ inputs.all-features }} NO_FAIL_FAST: ${{ inputs.no-fail-fast }} EXTRA_ARGS: ${{ inputs.extra-args }} + NEXTEST_PROFILE: ${{ inputs.nextest-profile }} run: | set -euo pipefail args=("--workspace") if [ "${ALL_FEATURES}" = "true" ]; then args+=("--all-features") fi - if [ "${NO_FAIL_FAST}" = "true" ]; then - args+=("--no-fail-fast") - fi - if [ -n "${EXTRA_ARGS}" ]; then - # shellcheck disable=SC2206 - extra_parts=(${EXTRA_ARGS}) - args+=("${extra_parts[@]}") + + if [ -n "${NEXTEST_PROFILE}" ]; then + # Use cargo-nextest with specified profile + args+=("--profile" "${NEXTEST_PROFILE}") + if [ -n "${EXTRA_ARGS}" ]; then + # shellcheck disable=SC2206 + extra_parts=(${EXTRA_ARGS}) + args+=("${extra_parts[@]}") + fi + cargo +"${TOOLCHAIN}" nextest run "${args[@]}" + else + # Use regular cargo test + if [ "${NO_FAIL_FAST}" = "true" ]; then + args+=("--no-fail-fast") + fi + if [ -n "${EXTRA_ARGS}" ]; then + # shellcheck disable=SC2206 + extra_parts=(${EXTRA_ARGS}) + args+=("${extra_parts[@]}") + fi + cargo +"${TOOLCHAIN}" test "${args[@]}" fi - cargo +"${TOOLCHAIN}" test "${args[@]}" diff --git a/.github/workflows/reusable-ci.yml b/.github/workflows/reusable-ci.yml index dd2e11d..0fea740 100644 --- a/.github/workflows/reusable-ci.yml +++ b/.github/workflows/reusable-ci.yml @@ -189,6 +189,12 @@ jobs: key: test-${{ matrix.rust }} save-if: ${{ github.ref == 'refs/heads/main' }} + - name: Install cargo-nextest + if: matrix.rust == needs.msrv.outputs.version + uses: taiki-e/install-action@v2 + with: + tool: cargo-nextest + - name: Verify lockfile is committed if: matrix.rust == needs.msrv.outputs.version shell: bash @@ -301,34 +307,34 @@ jobs: labels: ci, chore delete-branch: true - - name: Tests (${{ matrix.rust }}) + - name: Tests with nextest (${{ matrix.rust }}) + if: matrix.rust == needs.msrv.outputs.version uses: ./.github/actions/cargo-test with: toolchain: ${{ matrix.rust }} all-features: ${{ inputs.all-features }} + nextest-profile: ci - - name: Generate test report (JSON format) - if: always() - continue-on-error: true - shell: bash - run: | - cargo +${{ matrix.rust }} test --all-features --workspace --no-fail-fast -- \ - --format json -Z unstable-options --report-time > test-results-${{ matrix.rust }}.json || true + - name: Tests (${{ matrix.rust }}) + if: matrix.rust != needs.msrv.outputs.version + uses: ./.github/actions/cargo-test + with: + toolchain: ${{ matrix.rust }} + all-features: ${{ inputs.all-features }} - - name: Upload test results - if: always() - uses: actions/upload-artifact@v4 + - name: Upload test results to Codecov + if: matrix.rust == needs.msrv.outputs.version && !cancelled() + uses: codecov/test-results-action@v1 with: - name: test-results-${{ matrix.rust }} - path: test-results-${{ matrix.rust }}.json - retention-days: 30 + token: ${{ secrets.CODECOV_TOKEN }} - name: Add test summary if: always() && matrix.rust == needs.msrv.outputs.version run: | - echo "## Test Results (${{ matrix.rust }})" >> $GITHUB_STEP_SUMMARY - echo "Test artifacts uploaded with 30-day retention" >> $GITHUB_STEP_SUMMARY - echo "- Test report: \`test-results-${{ matrix.rust }}.json\`" >> $GITHUB_STEP_SUMMARY + echo "## Test Results" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "- JUnit XML: \`target/nextest/ci/junit.xml\`" >> $GITHUB_STEP_SUMMARY + echo "- [View Test Analytics](https://app.codecov.io/gh/RAprogramm/masterror/tests)" >> $GITHUB_STEP_SUMMARY - name: Auto-commit README changes (any branch) if: always() && matrix.rust == needs.msrv.outputs.version @@ -382,7 +388,6 @@ jobs: needs: [test, validate-codecov-yaml] permissions: contents: read - id-token: write steps: - uses: actions/checkout@v5 @@ -402,50 +407,16 @@ jobs: with: save-if: ${{ github.ref == 'refs/heads/main' }} - - name: Generate coverage for all tests + - name: Generate coverage with nextest run: | cargo llvm-cov nextest --all-features --workspace --lcov --output-path lcov.info - - name: Validate coverage file - run: | - set -euo pipefail - echo "=== Validating LCOV file ===" - if [ ! -f "lcov.info" ]; then - echo "ERROR: lcov.info not found" - exit 1 - fi - size=$(wc -c < "lcov.info") - lines=$(wc -l < "lcov.info") - echo "✓ lcov.info: ${size} bytes, ${lines} lines" - if [ "$size" -eq 0 ]; then - echo "ERROR: lcov.info is empty" - exit 1 - fi - echo "First 10 lines:" - head -10 "lcov.info" - - - name: Generate JUnit XML test results - if: success() || failure() - run: | - mkdir -p target/nextest/ci - cargo nextest run --all-features --workspace --profile ci --no-fail-fast || true - - - name: "Codecov: Upload coverage" + - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 with: + token: ${{ secrets.CODECOV_TOKEN }} files: ./lcov.info fail_ci_if_error: false - use_oidc: true - name: codecov-coverage - verbose: true - - - name: "Codecov: Upload test results" - if: success() || failure() - uses: codecov/test-results-action@v1 - with: - files: ./target/nextest/ci/junit.xml - use_oidc: true - name: codecov-test-results - name: Generate HTML coverage report run: cargo llvm-cov --all-features --workspace --html @@ -459,20 +430,15 @@ jobs: target/llvm-cov/html/ retention-days: 30 - - name: Add Codecov summary + - name: Add coverage summary run: | - echo "## Codecov Reports" >> $GITHUB_STEP_SUMMARY + echo "## Code Coverage Report" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY - echo "### Code Coverage" >> $GITHUB_STEP_SUMMARY echo "- LCOV report: \`lcov.info\`" >> $GITHUB_STEP_SUMMARY echo "- HTML report: \`target/llvm-cov/html/\`" >> $GITHUB_STEP_SUMMARY echo "- [View Coverage Dashboard](https://app.codecov.io/gh/RAprogramm/masterror)" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY - echo "### Test Analytics" >> $GITHUB_STEP_SUMMARY - echo "- JUnit XML: \`target/nextest/ci/junit.xml\`" >> $GITHUB_STEP_SUMMARY - echo "- [View Test Analytics](https://app.codecov.io/gh/RAprogramm/masterror/tests)" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "All artifacts uploaded with 30-day retention." >> $GITHUB_STEP_SUMMARY + echo "Coverage artifacts uploaded with 30-day retention." >> $GITHUB_STEP_SUMMARY benchmarks: runs-on: ubuntu-latest diff --git a/README.md b/README.md index 18e7a18..56065ab 100644 --- a/README.md +++ b/README.md @@ -489,4 +489,3 @@ assert_eq!(problem.grpc.expect("grpc").name, "UNAUTHENTICATED"); MSRV: **1.90** · License: **MIT OR Apache-2.0** · No `unsafe` -