From f8d96fa0c67e19254e9fba50a40d572501688ac2 Mon Sep 17 00:00:00 2001 From: Awar Abdulkarim <48431495+NotAwar@users.noreply.github.com> Date: Sun, 23 Feb 2025 18:43:08 +0100 Subject: [PATCH 1/8] feat: Create verify-examples.yml --- .github/verify-examples.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/verify-examples.yml diff --git a/.github/verify-examples.yml b/.github/verify-examples.yml new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/.github/verify-examples.yml @@ -0,0 +1 @@ + From 98e9a74bf5e36ab17edbb98ec5beadb869bc4c1c Mon Sep 17 00:00:00 2001 From: NotAwar Date: Sun, 23 Feb 2025 18:53:57 +0100 Subject: [PATCH 2/8] feat: create initial workflow --- .github/verify-examples.yml | 1 - .github/workflows/verify-examples.yml | 54 +++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) delete mode 100644 .github/verify-examples.yml create mode 100644 .github/workflows/verify-examples.yml diff --git a/.github/verify-examples.yml b/.github/verify-examples.yml deleted file mode 100644 index 8b13789179..0000000000 --- a/.github/verify-examples.yml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/.github/workflows/verify-examples.yml b/.github/workflows/verify-examples.yml new file mode 100644 index 0000000000..9ac2c06792 --- /dev/null +++ b/.github/workflows/verify-examples.yml @@ -0,0 +1,54 @@ +name: verify examples workflow + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + bazel-tests: + name: Bazel Tests + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Install Bazel + run: | + sudo apt-get update + sudo apt-get install -y bazel + + - name: Run Bazel tests + run: | + # Assumes BUILD files are configured under examples/ + bazel test //examples/... + + cmake-tests: + name: CMake Tests + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Install CMake + run: | + sudo apt-get update + sudo apt-get install -y cmake + + - name: Build and Test CMake Examples + run: | + # Loop over all immediate subdirectories under examples/ + 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 || exit 1 + popd + else + echo "Skipping $d as no CMakeLists.txt found." + fi + done From ce9957dd85f3e63b7c0ebbf76c9e8e6d95ebf7d1 Mon Sep 17 00:00:00 2001 From: NotAwar Date: Sun, 23 Feb 2025 18:55:20 +0100 Subject: [PATCH 3/8] fix: clarify workflow permissions --- .github/workflows/verify-examples.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/verify-examples.yml b/.github/workflows/verify-examples.yml index 9ac2c06792..f1003c1a28 100644 --- a/.github/workflows/verify-examples.yml +++ b/.github/workflows/verify-examples.yml @@ -10,6 +10,8 @@ jobs: bazel-tests: name: Bazel Tests runs-on: ubuntu-latest + permissions: + contents: read steps: - name: Checkout Code uses: actions/checkout@v3 @@ -27,6 +29,8 @@ jobs: cmake-tests: name: CMake Tests runs-on: ubuntu-latest + permissions: + contents: read steps: - name: Checkout Code uses: actions/checkout@v3 From d9163c8407f3aedb645637648dd9c90b6ee2bf77 Mon Sep 17 00:00:00 2001 From: NotAwar Date: Sun, 23 Feb 2025 18:58:04 +0100 Subject: [PATCH 4/8] fix: update wf --- .github/workflows/verify-examples.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/verify-examples.yml b/.github/workflows/verify-examples.yml index f1003c1a28..de1b33a4a3 100644 --- a/.github/workflows/verify-examples.yml +++ b/.github/workflows/verify-examples.yml @@ -6,12 +6,15 @@ on: pull_request: branches: [ main ] +permissions: + contents: read + jobs: bazel-tests: name: Bazel Tests runs-on: ubuntu-latest permissions: - contents: read + contents: read steps: - name: Checkout Code uses: actions/checkout@v3 @@ -30,7 +33,7 @@ jobs: name: CMake Tests runs-on: ubuntu-latest permissions: - contents: read + contents: read steps: - name: Checkout Code uses: actions/checkout@v3 From dc0fda08d2dda74b5a7ca3cbacaf406fe19e1142 Mon Sep 17 00:00:00 2001 From: NotAwar Date: Sun, 23 Feb 2025 19:17:47 +0100 Subject: [PATCH 5/8] fix: redid to match logic --- .github/workflows/ci.yml | 18 ++++++++ .github/workflows/verify-examples.yml | 61 --------------------------- ci/do_ci_verify_examples.sh | 29 +++++++++++++ 3 files changed, 47 insertions(+), 61 deletions(-) delete mode 100644 .github/workflows/verify-examples.yml create mode 100644 ci/do_ci_verify_examples.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3d17ae2ca2..9ea5d6dcb4 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/do_ci_verify_examples.sh + ./ci/do_ci_verify_examples.sh + diff --git a/.github/workflows/verify-examples.yml b/.github/workflows/verify-examples.yml deleted file mode 100644 index de1b33a4a3..0000000000 --- a/.github/workflows/verify-examples.yml +++ /dev/null @@ -1,61 +0,0 @@ -name: verify examples workflow - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -permissions: - contents: read - -jobs: - bazel-tests: - name: Bazel Tests - runs-on: ubuntu-latest - permissions: - contents: read - steps: - - name: Checkout Code - uses: actions/checkout@v3 - - - name: Install Bazel - run: | - sudo apt-get update - sudo apt-get install -y bazel - - - name: Run Bazel tests - run: | - # Assumes BUILD files are configured under examples/ - bazel test //examples/... - - cmake-tests: - name: CMake Tests - runs-on: ubuntu-latest - permissions: - contents: read - steps: - - name: Checkout Code - uses: actions/checkout@v3 - - - name: Install CMake - run: | - sudo apt-get update - sudo apt-get install -y cmake - - - name: Build and Test CMake Examples - run: | - # Loop over all immediate subdirectories under examples/ - 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 || exit 1 - popd - else - echo "Skipping $d as no CMakeLists.txt found." - fi - done diff --git a/ci/do_ci_verify_examples.sh b/ci/do_ci_verify_examples.sh new file mode 100644 index 0000000000..51a18c3420 --- /dev/null +++ b/ci/do_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 From 4a4cd404dbd34e91ad12d7b1029256fc88c8567e Mon Sep 17 00:00:00 2001 From: Awar Abdulkarim <48431495+NotAwar@users.noreply.github.com> Date: Sun, 23 Feb 2025 19:26:57 +0100 Subject: [PATCH 6/8] fix: Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7028d53118..ef716565d5 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 + * [SDK] Add tracer scope configurator [#3137](https://github.com/open-telemetry/opentelemetry-cpp/pull/3137) From 396d9a7bb9962bf20317513883d038a1515b79f4 Mon Sep 17 00:00:00 2001 From: Awar Abdulkarim <48431495+NotAwar@users.noreply.github.com> Date: Sun, 23 Feb 2025 19:27:38 +0100 Subject: [PATCH 7/8] fix: Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef716565d5..d50901d073 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ Increment the: * [CI] Added .sh file to run baselisk and Cmake tests -* [CI] Added verify examples job to CI workflow to run +* [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) From 464396113915307815b272475f07e6e41f3a1e7c Mon Sep 17 00:00:00 2001 From: NotAwar Date: Sun, 23 Feb 2025 19:28:46 +0100 Subject: [PATCH 8/8] fix: renamed files --- .github/workflows/ci.yml | 4 ++-- ci/{do_ci_verify_examples.sh => verify_examples.sh} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename ci/{do_ci_verify_examples.sh => verify_examples.sh} (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ea5d6dcb4..59a5860506 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1018,6 +1018,6 @@ jobs: sudo apt-get update && sudo apt-get install -y cmake - name: Run Examples Verification Script run: | - chmod +x ci/do_ci_verify_examples.sh - ./ci/do_ci_verify_examples.sh + chmod +x ci/verify_examples.sh + ./ci/verify_examples.sh diff --git a/ci/do_ci_verify_examples.sh b/ci/verify_examples.sh similarity index 100% rename from ci/do_ci_verify_examples.sh rename to ci/verify_examples.sh