From a2b4cddec8a0edb68f2dbce06040ebb8c927299a Mon Sep 17 00:00:00 2001 From: Piotr Korkus Date: Mon, 15 Dec 2025 14:01:08 +0100 Subject: [PATCH] cicd: add release workflow - execute UTs - store artifacts with test reports --- .github/workflows/release.yml | 107 ++++++++++++++++++++++++++++++++++ BUILD | 10 ++++ 2 files changed, 117 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..bd751d0 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,107 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* +name: Release Verification + +on: + release: + types: [created] + +jobs: + archive-report: + runs-on: ubuntu-latest + permissions: + contents: write # required to upload release assets + + steps: + - name: Checkout Repository + uses: actions/checkout@v4.2.2 + + - name: Install lcov + run: | + sudo apt-get update + sudo apt-get install -y lcov + + - name: Setup Bazel with shared caching + uses: bazel-contrib/setup-bazel@0.15.0 + with: + disk-cache: true + repository-cache: true + bazelisk-cache: true + + - name: Bazel info (discover paths) + id: bazel-info + run: | + echo "BAZEL_OUTPUT_BASE=$(bazel info output_base)" >> $GITHUB_ENV + echo "BAZEL_USER_ROOT=$(bazel info output_user_root)" >> $GITHUB_ENV + echo "BAZEL_REPO_CACHE=$(bazel info repository_cache)" >> $GITHUB_ENV + bazel info + + - name: Cache Bazel output base + uses: actions/cache@v4 + with: + path: | + ${{ env.BAZEL_OUTPUT_BASE }}/action_cache + ${{ env.BAZEL_OUTPUT_BASE }}/bazel-out + ${{ env.BAZEL_OUTPUT_BASE }}/external + ${{ env.BAZEL_OUTPUT_BASE }}/execroot + key: bazel-ob-v2-${{ runner.os }}-${{ hashFiles('.bazelversion', 'MODULE.bazel', 'MODULE.bazel.lock', '**/*.bzl', 'Cargo.lock') }} + restore-keys: | + bazel-ob-v2-${{ runner.os }}- + + - name: Build via Bazel + run: | + echo "Running: bazel build //..." + bazel build //... + + - name: Run Unit Tests via Bazel + run: | + echo "Running: bazel test //:unit_tests" + bazel test //:unit_tests + + - name: Run Unit Test with Coverage for Rust + run: | + # Run tests + bazel coverage //:unit_tests \ + --collect_code_coverage \ + --combined_report=lcov \ + --experimental_generate_llvm_lcov \ + --nocache_test_results \ + --nostamp + # Generate HTML report + genhtml "$(bazel info output_path)/_coverage/_coverage_report.dat" \ + -o=rust_coverage \ + --show-details \ + --legend \ + --function-coverage \ + --branch-coverage + + - name: Create archive of test report + run: | + mkdir -p artifacts + find bazel-testlogs/ -name 'test.xml' -print0 | xargs -0 -I{} cp --parents {} artifacts/ + cp -r rust_coverage artifacts/ + zip -r ${{ github.event.repository.name }}_coverage_report.zip artifacts/ + shell: bash + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ github.event.repository.name }}_coverage_report.zip + path: ${{ github.event.repository.name }}_coverage_report.zip + + - name: Upload release asset (attach ZIP to GitHub Release) + uses: softprops/action-gh-release@v2.5.0 + with: + files: ${{ github.event.repository.name }}_coverage_report.zip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/BUILD b/BUILD index cad414a..5e8240d 100644 --- a/BUILD +++ b/BUILD @@ -52,3 +52,13 @@ exports_files([ "clippy.toml", "MODULE.bazel", ]) + +test_suite( + name = "unit_tests", + tests = [ + "//feo-logger:libfeo_logger_rust_test", + "//feo-time:libfeo_time_cc_test", + "//feo-time:libfeo_time_test", + "//logd:liblogd_test", + ], +)