Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
204 changes: 0 additions & 204 deletions .ci/Jenkinsfile

This file was deleted.

114 changes: 114 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: CI Examples

permissions:
contents: read

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
run-examples:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
conan-version: [release, develop]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install CMake
uses: jwlawson/actions-setup-cmake@v1.14
with:
cmake-version: "3.23"

- name: Install autotools (macOS)
if: runner.os == 'macOS'
run: brew install automake autoconf

- name: Install Conan
shell: bash
run: |
python -m pip install --upgrade pip
if [[ "${{ matrix.conan-version }}" == "develop" ]]; then
pip install -e git+https://github.com/conan-io/conan.git@develop2#egg=conan --upgrade
else
pip install conan --upgrade
fi
pip install meson
conan --version
conan profile detect --force

- name: Find and run examples
shell: bash
run: |
export PYTHONPATH="${{ github.workspace }}${PYTHONPATH:+:$PYTHONPATH}"

# Find all ci_test_example files
if [[ "${{ runner.os }}" == "Windows" ]]; then
EXAMPLES=$(find . -name "ci_test_example.*" -type f \( -name "*.py" -o -name "*.bat" \) | sort)
else
EXAMPLES=$(find . -name "ci_test_example.*" -type f \( -name "*.py" -o -name "*.sh" \) | sort)
fi

# Filter out examples that require specific versions or tools not available in CI
# FIXME: Bazel examples require specific Bazel versions (6.3.2, 7.1.2) that are not installed in GitHub Actions runners
EXAMPLES=$(echo "$EXAMPLES" | grep -v "bazeltoolchain" || true)
# FIXME: Cross-building examples require cross-compilation toolchains (e.g., arm-linux-gnueabihf-gcc-9) that are not installed in GitHub Actions runners
EXAMPLES=$(echo "$EXAMPLES" | grep -v "cross_building" || true)

# FIXME: Filter out tensorflow examples in PRs
IS_PR="${{ github.event_name == 'pull_request' }}"
if [[ "$IS_PR" == "true" ]]; then
EXAMPLES=$(echo "$EXAMPLES" | grep -v tensorflow || true)
fi

if [[ -z "$EXAMPLES" ]]; then
echo "No examples found to run"
exit 0
fi

echo "Examples to run:"
echo "$EXAMPLES"

# Run each example
set -e
while IFS= read -r example; do
if [[ -z "$example" ]]; then
continue
fi

example_normalized=$(echo "$example" | sed 's|\\|/|g')
example_dir=$(dirname "$example_normalized")
example_file=$(basename "$example_normalized")

# Start group for this example
echo "::group::Running example: $example_dir"

cd "${{ github.workspace }}/$example_dir" || exit 1

if [[ "$example_file" == *.py ]]; then
python "$example_file"
elif [[ "$example_file" == *.sh ]]; then
bash "$example_file"
elif [[ "$example_file" == *.bat ]]; then
if [[ "${{ runner.os }}" == "Windows" ]]; then
cmd //c "$example_file"
else
echo "Skipping .bat file on non-Windows platform"
fi
fi

cd "${{ github.workspace }}" || exit 1

# End group for this example
echo "::endgroup::"
done <<< "$EXAMPLES"
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
# Do a modification to one component, to verify it is used correctly
replace(os.path.join("greetings", "src", "bye.cpp"), "bye:", "adios:")
run("conan build greetings")
# Clean app build to ensure it uses the updated library
app_build_path = os.path.join("app", "build")
if os.path.exists(app_build_path):
shutil.rmtree(app_build_path)
cmd_out = run("conan build app")
assert cmd_out.count("hello: Release!") == 2
assert cmd_out.count("adios: Release!") == 1
2 changes: 1 addition & 1 deletion examples/cross_build/android/ndk_basic/ci_test_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
tools.android:ndk_path={}
"""

ndk_path = {"Darwin": "/opt/homebrew/share/android-ndk", "Linux": "/opt/android-ndk-r23c"}.get(platform.system())
ndk_path = os.environ.get("ANDROID_NDK") or os.environ.get("ANDROID_NDK_HOME")

if ndk_path:
profile = profile.format(ndk_path)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[requires]
zlib/1.2.13
zlib/1.3.1

[tool_requires]
cmake/3.25.3
Expand Down
21 changes: 5 additions & 16 deletions test/examples_tools.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import subprocess
import shutil
import sys
from contextlib import contextmanager
import time

Expand Down Expand Up @@ -49,7 +50,10 @@ def run(cmd, error=False):
output = ''

for line in iter(process.stdout.readline, ''):
print(line, end='', flush=True)
# Write directly to stdout to preserve GitHub Actions workflow commands
# This ensures ::group:: and ::endgroup:: are detected by GitHub Actions
sys.stdout.write(line)
sys.stdout.flush()
output += line

ret = process.wait()
Expand All @@ -64,18 +68,3 @@ def run(cmd, error=False):
raise Exception(f"Cmd succeeded (failure expected): {cmd}\n{output}")

return output


def replace(file_path, text, replace):
with open(file_path, "r") as f:
content = f.read()
content2 = content.replace(text, replace)
assert content != content2
with open(file_path, "w") as f:
f.write(content2)


def load(file_path):
with open(file_path, "r") as f:
content = f.read()
return content
Loading