diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3d17ae2ca2..59a5860506 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1003,3 +1003,21 @@ jobs: | python ${GITHUB_WORKSPACE}/trace-context/test/test.py http://localhost:30000/test TraceContextTest AdvancedTest curl http://localhost:30000/stop + + verify-examples: + name: Verify Examples + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + - name: Setup Environment for Examples + run: | + sudo apt-get update + sudo -E ./ci/setup_ci_environment.sh + sudo apt-get update && sudo apt-get install -y cmake + - name: Run Examples Verification Script + run: | + chmod +x ci/verify_examples.sh + ./ci/verify_examples.sh + diff --git a/CHANGELOG.md b/CHANGELOG.md index 7028d53118..d50901d073 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,10 @@ Increment the: ## [Unreleased] +* [CI] Added .sh file to run baselisk and Cmake tests + +* [CI] Added verify examples job to CI workflow to run verify_examples.sh + * [SDK] Add tracer scope configurator [#3137](https://github.com/open-telemetry/opentelemetry-cpp/pull/3137) diff --git a/ci/verify_examples.sh b/ci/verify_examples.sh new file mode 100644 index 0000000000..51a18c3420 --- /dev/null +++ b/ci/verify_examples.sh @@ -0,0 +1,29 @@ +#!/bin/bash + + +set -e + +echo "Running Bazel tests for examples..." +# Ensure Bazelisk is installed or available +sudo apt-get update +sudo apt-get install -y bazelisk +bazelisk test //examples/... + +echo "Running CMake tests for examples..." +sudo apt-get update +sudo apt-get install -y cmake + +# Loop over each subdirectory in examples and run CMake tests if a CMakeLists.txt exists. +for d in examples/*/ ; do + if [ -f "$d/CMakeLists.txt" ]; then + echo "Building CMake project in $d" + mkdir -p "$d/build" + pushd "$d/build" + cmake .. + cmake --build . + ctest --output-on-failure + popd + else + echo "Skipping $d as no CMakeLists.txt found." + fi +done