|
| 1 | +# ******************************************************************************* |
| 2 | +# Copyright (c) 2025 Contributors to the Eclipse Foundation |
| 3 | +# |
| 4 | +# See the NOTICE file(s) distributed with this work for additional |
| 5 | +# information regarding copyright ownership. |
| 6 | +# |
| 7 | +# This program and the accompanying materials are made available under the |
| 8 | +# terms of the Apache License Version 2.0 which is available at |
| 9 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# SPDX-License-Identifier: Apache-2.0 |
| 12 | +# ******************************************************************************* |
| 13 | +name: Release Verification |
| 14 | + |
| 15 | +on: |
| 16 | + release: |
| 17 | + types: [created] |
| 18 | + |
| 19 | +jobs: |
| 20 | + archive-report: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + permissions: |
| 23 | + contents: write # required to upload release assets |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Checkout Repository |
| 27 | + uses: actions/checkout@v4.2.2 |
| 28 | + |
| 29 | + - name: Install lcov |
| 30 | + run: | |
| 31 | + sudo apt-get update |
| 32 | + sudo apt-get install -y lcov |
| 33 | +
|
| 34 | + - name: Setup Bazel with shared caching |
| 35 | + uses: bazel-contrib/setup-bazel@0.15.0 |
| 36 | + with: |
| 37 | + disk-cache: true |
| 38 | + repository-cache: true |
| 39 | + bazelisk-cache: true |
| 40 | + |
| 41 | + - name: Bazel info (discover paths) |
| 42 | + id: bazel-info |
| 43 | + run: | |
| 44 | + echo "BAZEL_OUTPUT_BASE=$(bazel info output_base)" >> $GITHUB_ENV |
| 45 | + echo "BAZEL_USER_ROOT=$(bazel info output_user_root)" >> $GITHUB_ENV |
| 46 | + echo "BAZEL_REPO_CACHE=$(bazel info repository_cache)" >> $GITHUB_ENV |
| 47 | + bazel info |
| 48 | +
|
| 49 | + - name: Cache Bazel output base |
| 50 | + uses: actions/cache@v4 |
| 51 | + with: |
| 52 | + path: | |
| 53 | + ${{ env.BAZEL_OUTPUT_BASE }}/action_cache |
| 54 | + ${{ env.BAZEL_OUTPUT_BASE }}/bazel-out |
| 55 | + ${{ env.BAZEL_OUTPUT_BASE }}/external |
| 56 | + ${{ env.BAZEL_OUTPUT_BASE }}/execroot |
| 57 | + key: bazel-ob-v2-${{ runner.os }}-${{ hashFiles('.bazelversion', 'MODULE.bazel', 'MODULE.bazel.lock', '**/*.bzl', 'Cargo.lock') }} |
| 58 | + restore-keys: | |
| 59 | + bazel-ob-v2-${{ runner.os }}- |
| 60 | +
|
| 61 | + - name: Build via Bazel |
| 62 | + run: | |
| 63 | + echo "Running: bazel build //src/..." |
| 64 | + bazel build //src/... |
| 65 | +
|
| 66 | + - name: Run Unit Tests via Bazel |
| 67 | + run: | |
| 68 | + echo "Running: bazel test //:unit_tests" |
| 69 | + bazel test //:unit_tests |
| 70 | +
|
| 71 | + - name: Run Unit Test with Coverage for C++ |
| 72 | + run: | |
| 73 | + # Run tests |
| 74 | + "$(bazel info bazel-bin)/src/cpp/tests/test_kvs_cpp" |
| 75 | + # Collect coverage data |
| 76 | + lcov --capture \ |
| 77 | + --directory="$(bazel info bazel-bin)/src/cpp/" \ |
| 78 | + --output-file=cpp_coverage.info \ |
| 79 | + --gcov-tool="$(bazel info execution_root)/external/score_toolchains_gcc++gcc+gcc_toolchain_gcc/bin/x86_64-unknown-linux-gnu-gcov" \ |
| 80 | + --base-directory="$(bazel info workspace)" \ |
| 81 | + --branch-coverage \ |
| 82 | + --ignore-errors=mismatch \ |
| 83 | + --exclude="*/external/*" |
| 84 | + # Generate HTML report |
| 85 | + genhtml cpp_coverage.info \ |
| 86 | + -o=cpp_coverage \ |
| 87 | + --show-details \ |
| 88 | + --legend \ |
| 89 | + --function-coverage \ |
| 90 | + --branch-coverage |
| 91 | +
|
| 92 | + - name: Run Unit Test with Coverage for Rust |
| 93 | + run: | |
| 94 | + # Run tests |
| 95 | + bazel coverage //:unit_tests_rust \ |
| 96 | + --collect_code_coverage \ |
| 97 | + --combined_report=lcov \ |
| 98 | + --experimental_generate_llvm_lcov \ |
| 99 | + --nocache_test_results \ |
| 100 | + --nostamp |
| 101 | + # Generate HTML report |
| 102 | + genhtml "$(bazel info output_path)/_coverage/_coverage_report.dat" \ |
| 103 | + -o=rust_coverage \ |
| 104 | + --show-details \ |
| 105 | + --legend \ |
| 106 | + --function-coverage \ |
| 107 | + --branch-coverage |
| 108 | +
|
| 109 | + - name: Create archive of test report |
| 110 | + run: | |
| 111 | + mkdir -p artifacts |
| 112 | + find bazel-testlogs/src/ -name 'test.xml' -print0 | xargs -0 -I{} cp --parents {} artifacts/ |
| 113 | + cp -r cpp_coverage artifacts/ |
| 114 | + cp -r rust_coverage artifacts/ |
| 115 | + zip -r ${{ github.event.repository.name }}_coverage_report.zip artifacts/ |
| 116 | + shell: bash |
| 117 | + |
| 118 | + - name: Upload artifacts |
| 119 | + uses: actions/upload-artifact@v4 |
| 120 | + with: |
| 121 | + name: ${{ github.event.repository.name }}_coverage_report.zip |
| 122 | + path: ${{ github.event.repository.name }}_coverage_report.zip |
| 123 | + |
| 124 | + - name: Upload release asset (attach ZIP to GitHub Release) |
| 125 | + uses: softprops/action-gh-release@v2.5.0 |
| 126 | + with: |
| 127 | + files: ${{ github.event.repository.name }}_coverage_report.zip |
| 128 | + env: |
| 129 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments