Skip to content

Commit c74be95

Browse files
authored
[CI] Use GitHub Actions for CI (#200)
* use GA * add PYTHONPATH * fix permissions * wip * wip * zlib does not build for clang 17 in macOS * install automake autoconf * wip * revert * group * wip * wip * clean * clean * wip * wip * wip * wip * wip * wip
1 parent 93bcdd6 commit c74be95

File tree

10 files changed

+142
-225
lines changed

10 files changed

+142
-225
lines changed

.ci/Jenkinsfile

Lines changed: 0 additions & 204 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: CI Examples
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
push:
8+
branches: [ main ]
9+
pull_request:
10+
branches: [ main ]
11+
12+
jobs:
13+
run-examples:
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os: [ubuntu-latest, macos-latest, windows-latest]
18+
conan-version: [release, develop]
19+
runs-on: ${{ matrix.os }}
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: "3.11"
27+
28+
- name: Install CMake
29+
uses: jwlawson/actions-setup-cmake@v1.14
30+
with:
31+
cmake-version: "3.23"
32+
33+
- name: Install autotools (macOS)
34+
if: runner.os == 'macOS'
35+
run: brew install automake autoconf
36+
37+
- name: Install Conan
38+
shell: bash
39+
run: |
40+
python -m pip install --upgrade pip
41+
if [[ "${{ matrix.conan-version }}" == "develop" ]]; then
42+
pip install -e git+https://github.com/conan-io/conan.git@develop2#egg=conan --upgrade
43+
else
44+
pip install conan --upgrade
45+
fi
46+
pip install meson
47+
conan --version
48+
conan profile detect --force
49+
50+
- name: Find and run examples
51+
shell: bash
52+
run: |
53+
export PYTHONPATH="${{ github.workspace }}${PYTHONPATH:+:$PYTHONPATH}"
54+
55+
# Find all ci_test_example files
56+
if [[ "${{ runner.os }}" == "Windows" ]]; then
57+
EXAMPLES=$(find . -name "ci_test_example.*" -type f \( -name "*.py" -o -name "*.bat" \) | sort)
58+
else
59+
EXAMPLES=$(find . -name "ci_test_example.*" -type f \( -name "*.py" -o -name "*.sh" \) | sort)
60+
fi
61+
62+
# Filter out examples that require specific versions or tools not available in CI
63+
# FIXME: Bazel examples require specific Bazel versions (6.3.2, 7.1.2) that are not installed in GitHub Actions runners
64+
EXAMPLES=$(echo "$EXAMPLES" | grep -v "bazeltoolchain" || true)
65+
# FIXME: Cross-building examples require cross-compilation toolchains (e.g., arm-linux-gnueabihf-gcc-9) that are not installed in GitHub Actions runners
66+
EXAMPLES=$(echo "$EXAMPLES" | grep -v "cross_building" || true)
67+
68+
# FIXME: Filter out tensorflow examples in PRs
69+
IS_PR="${{ github.event_name == 'pull_request' }}"
70+
if [[ "$IS_PR" == "true" ]]; then
71+
EXAMPLES=$(echo "$EXAMPLES" | grep -v tensorflow || true)
72+
fi
73+
74+
if [[ -z "$EXAMPLES" ]]; then
75+
echo "No examples found to run"
76+
exit 0
77+
fi
78+
79+
echo "Examples to run:"
80+
echo "$EXAMPLES"
81+
82+
# Run each example
83+
set -e
84+
while IFS= read -r example; do
85+
if [[ -z "$example" ]]; then
86+
continue
87+
fi
88+
89+
example_normalized=$(echo "$example" | sed 's|\\|/|g')
90+
example_dir=$(dirname "$example_normalized")
91+
example_file=$(basename "$example_normalized")
92+
93+
# Start group for this example
94+
echo "::group::Running example: $example_dir"
95+
96+
cd "${{ github.workspace }}/$example_dir" || exit 1
97+
98+
if [[ "$example_file" == *.py ]]; then
99+
python "$example_file"
100+
elif [[ "$example_file" == *.sh ]]; then
101+
bash "$example_file"
102+
elif [[ "$example_file" == *.bat ]]; then
103+
if [[ "${{ runner.os }}" == "Windows" ]]; then
104+
cmd //c "$example_file"
105+
else
106+
echo "Skipping .bat file on non-Windows platform"
107+
fi
108+
fi
109+
110+
cd "${{ github.workspace }}" || exit 1
111+
112+
# End group for this example
113+
echo "::endgroup::"
114+
done <<< "$EXAMPLES"

examples/conanfile/layout/editable_components/ci_test_example.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
# Do a modification to one component, to verify it is used correctly
2424
replace(os.path.join("greetings", "src", "bye.cpp"), "bye:", "adios:")
2525
run("conan build greetings")
26+
# Clean app build to ensure it uses the updated library
27+
app_build_path = os.path.join("app", "build")
28+
if os.path.exists(app_build_path):
29+
shutil.rmtree(app_build_path)
2630
cmd_out = run("conan build app")
2731
assert cmd_out.count("hello: Release!") == 2
2832
assert cmd_out.count("adios: Release!") == 1

examples/cross_build/android/ndk_basic/ci_test_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
tools.android:ndk_path={}
2424
"""
2525

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

2828
if ndk_path:
2929
profile = profile.format(ndk_path)

examples/extensions/deployers/development_deploy/conanfile.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[requires]
2-
zlib/1.2.13
2+
zlib/1.3.1
33

44
[tool_requires]
55
cmake/3.25.3

test/examples_tools.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import subprocess
33
import shutil
4+
import sys
45
from contextlib import contextmanager
56
import time
67

@@ -49,7 +50,10 @@ def run(cmd, error=False):
4950
output = ''
5051

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

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

6670
return output
67-
68-
69-
def replace(file_path, text, replace):
70-
with open(file_path, "r") as f:
71-
content = f.read()
72-
content2 = content.replace(text, replace)
73-
assert content != content2
74-
with open(file_path, "w") as f:
75-
f.write(content2)
76-
77-
78-
def load(file_path):
79-
with open(file_path, "r") as f:
80-
content = f.read()
81-
return content

0 commit comments

Comments
 (0)