From 43da6afbc9570e0f87243383288fbf7e44c88d66 Mon Sep 17 00:00:00 2001 From: Pantelis Sopasakis Date: Fri, 20 Mar 2026 17:47:12 +0000 Subject: [PATCH 1/4] update CI --- .github/workflows/ci.yml | 124 ++++++++++++++++++--------------------- ci/script.sh | 19 +++--- 2 files changed, 66 insertions(+), 77 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 33922b3b..eb79279b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,100 +1,92 @@ +name: Continuous integration + on: push: - branches: [ master ] + branches: [master] pull_request: -name: Continuous integration +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true jobs: - ci: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest] + ci_linux: + name: Linux + runs-on: ubuntu-latest + timeout-minutes: 45 env: DO_DOCKER: 0 steps: - - uses: actions/checkout@v2 - - uses: egor-tensin/setup-clang@v1 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v5 + + - uses: actions-rust-lang/setup-rust-toolchain@v1 with: - profile: minimal toolchain: stable - override: true - - uses: actions-rs/cargo@v1 - with: - command: test - - uses: actions/setup-python@v5 + target: arm-unknown-linux-gnueabihf + rustflags: "" + + - uses: actions/setup-python@v6 with: - python-version: '3.12' - architecture: 'x64' + python-version: "3.12" + architecture: "x64" + cache: "pip" + cache-dependency-path: open-codegen/setup.py + + - uses: egor-tensin/setup-clang@v1 + - name: Install ARM cross-compiler and C libraries run: | sudo apt-get update sudo apt-get install -y gcc-arm-linux-gnueabihf libc6-dev-armhf-cross - # If icasadi_rosenbrock or other deps need C++: - # sudo apt-get install -y g++-arm-linux-gnueabihf + + - name: Cargo tests + run: cargo test + - name: Cargo tests (RP and JEM) run: | cargo test --features rp cargo test --features jem + - name: Run tests (script.sh) - # Set environment variables for the cc crate env: CC_arm_unknown_linux_gnueabihf: arm-linux-gnueabihf-gcc AR_arm_unknown_linux_gnueabihf: arm-linux-gnueabihf-ar - # If C++ is involved and you installed g++-arm-linux-gnueabihf: - # CXX_arm_unknown_linux_gnueabihf: arm-linux-gnueabihf-g++ - run: | - bash ./ci/script.sh + run: bash ./ci/script.sh ci_macos: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [macos-latest] + name: macOS + runs-on: macos-latest + timeout-minutes: 45 env: DO_DOCKER: 0 + SKIP_RPI_TEST: 1 steps: - - uses: actions/checkout@v2 - - run: brew install llvm - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v5 + + - uses: actions-rust-lang/setup-rust-toolchain@v1 with: - profile: minimal toolchain: stable - override: true - - uses: actions-rs/cargo@v1 - with: - command: test - - uses: actions/setup-python@v5 + rustflags: "" + + - uses: actions/setup-python@v6 with: - python-version: '3.12' - - run: cargo test --features rp - - run: cargo test --features jem - - name: Install ARM cross-compiler toolchain (via Homebrew) + python-version: "3.12" + cache: "pip" + cache-dependency-path: open-codegen/setup.py + + - name: Install LLVM + run: brew install llvm + + - name: Cargo tests + run: cargo test + + - name: Cargo tests (RP and JEM) run: | - # Tap the repository that provides the cross-compiler - brew tap messense/macos-cross-toolchains - # Update brew to ensure the tap is recognized (can sometimes be needed) - brew update - # Install the full toolchain (includes gcc, binutils, sysroot) - # This specific formula provides the entire toolchain. - brew install arm-unknown-linux-gnueabihf - - # The above `brew install` might have linking conflicts if other partial - # toolchains were somehow pre-installed or installed by other steps. - # If it fails with link errors, you might need: - # brew link --overwrite arm-unknown-linux-gnueabihf - - # Verify the compiler is found - which arm-linux-gnueabihf-gcc || (echo "arm-linux-gnueabihf-gcc not found in PATH" && exit 1) + cargo test --features rp + cargo test --features jem + - name: Run tests (script.sh) - # Set environment variables for the cc crate and PyO3 (if needed) - env: - CC_arm_unknown_linux_gnueabihf: arm-linux-gnueabihf-gcc - AR_arm_unknown_linux_gnueabihf: arm-linux-gnueabihf-ar - # If you are building PyO3 bindings and need to specify Python libs from the sysroot: - # PYO3_CROSS_LIB_DIR: "/opt/homebrew/opt/arm-unknown-linux-gnueabihf/arm-unknown-linux-gnueabihf/sysroot/usr/lib" # Adjust path and Python version - # PYO3_CROSS_INCLUDE_DIR: "/opt/homebrew/opt/arm-unknown-linux-gnueabihf/arm-unknown-linux-gnueabihf/sysroot/usr/include/python3.x" # Adjust path and Python version - run: | - bash ./ci/script.sh + run: bash ./ci/script.sh diff --git a/ci/script.sh b/ci/script.sh index 35599d7e..ec207591 100755 --- a/ci/script.sh +++ b/ci/script.sh @@ -1,6 +1,8 @@ #!/bin/bash set -euxo pipefail +SKIP_RPI_TEST="${SKIP_RPI_TEST:-0}" + function run_clippy_test() { pushd $1 cargo clippy --all-targets --all-features @@ -29,31 +31,26 @@ regular_test() { cd open-codegen export PYTHONPATH=. - # --- install virtualenv - pip install virtualenv - # --- create virtualenv - virtualenv -p python3.12 venv + python -m venv venv # --- activate venv source venv/bin/activate # --- upgrade pip within venv - pip install --upgrade pip + python -m pip install --upgrade pip # --- install opengen - pip install . - - # --- rust dependencies - rustup update - rustup target add arm-unknown-linux-gnueabihf + python -m pip install . # --- run the tests export PYTHONPATH=. python -W ignore test/test_constraints.py -v python -W ignore test/test.py -v python -W ignore test/test_ocp.py -v - python -W ignore test/test_raspberry_pi.py -v + if [ "$SKIP_RPI_TEST" -eq 0 ]; then + python -W ignore test/test_raspberry_pi.py -v + fi # Run Clippy for generated optimizers From 62161aedeb273d61b927bec3c2210731c2ed17ef Mon Sep 17 00:00:00 2001 From: Pantelis Sopasakis Date: Fri, 20 Mar 2026 18:01:16 +0000 Subject: [PATCH 2/4] GA pipeline --- .github/workflows/ci.yml | 87 ++++++++++++++++++++++------------------ ci/script.sh | 30 +++++++------- 2 files changed, 64 insertions(+), 53 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eb79279b..022082d0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,35 +13,26 @@ concurrency: cancel-in-progress: true jobs: - ci_linux: - name: Linux - runs-on: ubuntu-latest + rust_tests: + name: Rust tests (${{ matrix.name }}) + runs-on: ${{ matrix.os }} timeout-minutes: 45 - env: - DO_DOCKER: 0 + strategy: + fail-fast: false + matrix: + include: + - name: Linux + os: ubuntu-latest + - name: macOS + os: macos-latest steps: - uses: actions/checkout@v5 - uses: actions-rust-lang/setup-rust-toolchain@v1 with: toolchain: stable - target: arm-unknown-linux-gnueabihf rustflags: "" - - uses: actions/setup-python@v6 - with: - python-version: "3.12" - architecture: "x64" - cache: "pip" - cache-dependency-path: open-codegen/setup.py - - - uses: egor-tensin/setup-clang@v1 - - - name: Install ARM cross-compiler and C libraries - run: | - sudo apt-get update - sudo apt-get install -y gcc-arm-linux-gnueabihf libc6-dev-armhf-cross - - name: Cargo tests run: cargo test @@ -50,25 +41,31 @@ jobs: cargo test --features rp cargo test --features jem - - name: Run tests (script.sh) - env: - CC_arm_unknown_linux_gnueabihf: arm-linux-gnueabihf-gcc - AR_arm_unknown_linux_gnueabihf: arm-linux-gnueabihf-ar - run: bash ./ci/script.sh - - ci_macos: - name: macOS - runs-on: macos-latest + python_tests: + name: Python tests (${{ matrix.name }}) + needs: rust_tests + runs-on: ${{ matrix.os }} timeout-minutes: 45 + strategy: + fail-fast: false + matrix: + include: + - name: Linux + os: ubuntu-latest + skip_rpi_test: 0 + - name: macOS + os: macos-latest + skip_rpi_test: 1 env: DO_DOCKER: 0 - SKIP_RPI_TEST: 1 + SKIP_RPI_TEST: ${{ matrix.skip_rpi_test }} steps: - uses: actions/checkout@v5 - uses: actions-rust-lang/setup-rust-toolchain@v1 with: toolchain: stable + components: clippy rustflags: "" - uses: actions/setup-python@v6 @@ -77,16 +74,30 @@ jobs: cache: "pip" cache-dependency-path: open-codegen/setup.py - - name: Install LLVM - run: brew install llvm + - uses: egor-tensin/setup-clang@v1 + if: runner.os == 'Linux' - - name: Cargo tests - run: cargo test + - name: Install Linux ARM target + if: runner.os == 'Linux' + run: rustup target add arm-unknown-linux-gnueabihf - - name: Cargo tests (RP and JEM) + - name: Install ARM cross-compiler and C libraries + if: runner.os == 'Linux' run: | - cargo test --features rp - cargo test --features jem + sudo apt-get update + sudo apt-get install -y gcc-arm-linux-gnueabihf libc6-dev-armhf-cross + + - name: Install LLVM + if: runner.os == 'macOS' + run: brew install llvm + + - name: Run Python tests and generated Clippy checks + if: runner.os == 'Linux' + env: + CC_arm_unknown_linux_gnueabihf: arm-linux-gnueabihf-gcc + AR_arm_unknown_linux_gnueabihf: arm-linux-gnueabihf-ar + run: bash ./ci/script.sh - - name: Run tests (script.sh) + - name: Run Python tests and generated Clippy checks + if: runner.os == 'macOS' run: bash ./ci/script.sh diff --git a/ci/script.sh b/ci/script.sh index ec207591..7f74e448 100755 --- a/ci/script.sh +++ b/ci/script.sh @@ -23,11 +23,21 @@ function run_clippy_test() { popd } -regular_test() { +generated_clippy_tests() { + cd .python_test_build + run_clippy_test "only_f1" + run_clippy_test "only_f2" + run_clippy_test "halfspace_optimizer" + run_clippy_test "parametric_f2" + run_clippy_test "plain" + run_clippy_test "python_bindings" + run_clippy_test "rosenbrock_ros" +} + +python_tests() { # Run Python tests # ------------------------------------ - # --- create virtual environment cd open-codegen export PYTHONPATH=. @@ -52,19 +62,9 @@ regular_test() { python -W ignore test/test_raspberry_pi.py -v fi - # Run Clippy for generated optimizers # ------------------------------------ - - cd .python_test_build - run_clippy_test "only_f1" - run_clippy_test "only_f2" - run_clippy_test "halfspace_optimizer" - run_clippy_test "parametric_f2" - run_clippy_test "plain" - run_clippy_test "python_bindings" - run_clippy_test "rosenbrock_ros" - + generated_clippy_tests } test_docker() { @@ -74,8 +74,8 @@ test_docker() { main() { if [ $DO_DOCKER -eq 0 ]; then - echo "Running regular tests" - regular_test + echo "Running Python and generated Clippy tests" + python_tests else echo "Building Docker image" test_docker From 97e9aecc9fe2c2b8bfeda824d167f6a403744ac8 Mon Sep 17 00:00:00 2001 From: Pantelis Sopasakis Date: Fri, 20 Mar 2026 18:13:49 +0000 Subject: [PATCH 3/4] split GA job into three parts --- .github/workflows/ci.yml | 40 +++++++++++++++++++++-- ci/script.sh | 68 ++++++++++++++++++++++++++-------------- 2 files changed, 83 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 022082d0..6517d212 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -96,8 +96,44 @@ jobs: env: CC_arm_unknown_linux_gnueabihf: arm-linux-gnueabihf-gcc AR_arm_unknown_linux_gnueabihf: arm-linux-gnueabihf-ar - run: bash ./ci/script.sh + run: bash ./ci/script.sh python-tests - name: Run Python tests and generated Clippy checks if: runner.os == 'macOS' - run: bash ./ci/script.sh + run: bash ./ci/script.sh python-tests + + ocp_tests: + name: OCP tests (${{ matrix.name }}) + needs: python_tests + runs-on: ${{ matrix.os }} + timeout-minutes: 45 + strategy: + fail-fast: false + matrix: + include: + - name: Linux + os: ubuntu-latest + - name: macOS + os: macos-latest + env: + DO_DOCKER: 0 + steps: + - uses: actions/checkout@v5 + + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: stable + rustflags: "" + + - uses: actions/setup-python@v6 + with: + python-version: "3.12" + cache: "pip" + cache-dependency-path: open-codegen/setup.py + + - name: Install LLVM + if: runner.os == 'macOS' + run: brew install llvm + + - name: Run OCP Python tests + run: bash ./ci/script.sh ocp-tests diff --git a/ci/script.sh b/ci/script.sh index 7f74e448..18f1f2b7 100755 --- a/ci/script.sh +++ b/ci/script.sh @@ -2,6 +2,7 @@ set -euxo pipefail SKIP_RPI_TEST="${SKIP_RPI_TEST:-0}" +TASK="${1:-all-python-tests}" function run_clippy_test() { pushd $1 @@ -23,8 +24,18 @@ function run_clippy_test() { popd } +setup_python_test_env() { + cd open-codegen + export PYTHONPATH=. + + python -m venv venv + source venv/bin/activate + python -m pip install --upgrade pip + python -m pip install . +} + generated_clippy_tests() { - cd .python_test_build + pushd .python_test_build run_clippy_test "only_f1" run_clippy_test "only_f2" run_clippy_test "halfspace_optimizer" @@ -32,32 +43,14 @@ generated_clippy_tests() { run_clippy_test "plain" run_clippy_test "python_bindings" run_clippy_test "rosenbrock_ros" + popd } -python_tests() { - # Run Python tests - # ------------------------------------ - - cd open-codegen +run_python_core_tests() { export PYTHONPATH=. - # --- create virtualenv - python -m venv venv - - # --- activate venv - source venv/bin/activate - - # --- upgrade pip within venv - python -m pip install --upgrade pip - - # --- install opengen - python -m pip install . - - # --- run the tests - export PYTHONPATH=. python -W ignore test/test_constraints.py -v python -W ignore test/test.py -v - python -W ignore test/test_ocp.py -v if [ "$SKIP_RPI_TEST" -eq 0 ]; then python -W ignore test/test_raspberry_pi.py -v fi @@ -67,6 +60,17 @@ python_tests() { generated_clippy_tests } +run_python_ocp_tests() { + export PYTHONPATH=. + python -W ignore test/test_ocp.py -v +} + +all_python_tests() { + setup_python_test_env + run_python_core_tests + run_python_ocp_tests +} + test_docker() { cd docker docker image build -t alphaville/open . @@ -74,8 +78,26 @@ test_docker() { main() { if [ $DO_DOCKER -eq 0 ]; then - echo "Running Python and generated Clippy tests" - python_tests + case "$TASK" in + python-tests) + echo "Running Python tests and generated Clippy tests" + setup_python_test_env + run_python_core_tests + ;; + ocp-tests) + echo "Running OCP Python tests" + setup_python_test_env + run_python_ocp_tests + ;; + all-python-tests) + echo "Running Python tests, generated Clippy tests, and OCP tests" + all_python_tests + ;; + *) + echo "Unknown task: $TASK" + exit 1 + ;; + esac else echo "Building Docker image" test_docker From b2e820592df42999837651916bdc906858b35a87 Mon Sep 17 00:00:00 2001 From: Pantelis Sopasakis Date: Fri, 20 Mar 2026 18:25:52 +0000 Subject: [PATCH 4/4] remove LLVM from OCP tests job --- .github/workflows/ci.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6517d212..982b2960 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -131,9 +131,5 @@ jobs: cache: "pip" cache-dependency-path: open-codegen/setup.py - - name: Install LLVM - if: runner.os == 'macOS' - run: brew install llvm - - name: Run OCP Python tests run: bash ./ci/script.sh ocp-tests