[CI] Use GitHub Actions for CI #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 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 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") | |
| echo "=========================================" | |
| echo "Running example: $example_dir" | |
| echo "=========================================" | |
| 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 | |
| done <<< "$EXAMPLES" |