Skip to content

Commit 43da6af

Browse files
committed
update CI
1 parent be8a415 commit 43da6af

2 files changed

Lines changed: 66 additions & 77 deletions

File tree

.github/workflows/ci.yml

Lines changed: 58 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,92 @@
1+
name: Continuous integration
2+
13
on:
24
push:
3-
branches: [ master ]
5+
branches: [master]
46
pull_request:
57

6-
name: Continuous integration
8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
13+
cancel-in-progress: true
714

815
jobs:
9-
ci:
10-
runs-on: ${{ matrix.os }}
11-
strategy:
12-
matrix:
13-
os: [ubuntu-latest]
16+
ci_linux:
17+
name: Linux
18+
runs-on: ubuntu-latest
19+
timeout-minutes: 45
1420
env:
1521
DO_DOCKER: 0
1622
steps:
17-
- uses: actions/checkout@v2
18-
- uses: egor-tensin/setup-clang@v1
19-
- uses: actions-rs/toolchain@v1
23+
- uses: actions/checkout@v5
24+
25+
- uses: actions-rust-lang/setup-rust-toolchain@v1
2026
with:
21-
profile: minimal
2227
toolchain: stable
23-
override: true
24-
- uses: actions-rs/cargo@v1
25-
with:
26-
command: test
27-
- uses: actions/setup-python@v5
28+
target: arm-unknown-linux-gnueabihf
29+
rustflags: ""
30+
31+
- uses: actions/setup-python@v6
2832
with:
29-
python-version: '3.12'
30-
architecture: 'x64'
33+
python-version: "3.12"
34+
architecture: "x64"
35+
cache: "pip"
36+
cache-dependency-path: open-codegen/setup.py
37+
38+
- uses: egor-tensin/setup-clang@v1
39+
3140
- name: Install ARM cross-compiler and C libraries
3241
run: |
3342
sudo apt-get update
3443
sudo apt-get install -y gcc-arm-linux-gnueabihf libc6-dev-armhf-cross
35-
# If icasadi_rosenbrock or other deps need C++:
36-
# sudo apt-get install -y g++-arm-linux-gnueabihf
44+
45+
- name: Cargo tests
46+
run: cargo test
47+
3748
- name: Cargo tests (RP and JEM)
3849
run: |
3950
cargo test --features rp
4051
cargo test --features jem
52+
4153
- name: Run tests (script.sh)
42-
# Set environment variables for the cc crate
4354
env:
4455
CC_arm_unknown_linux_gnueabihf: arm-linux-gnueabihf-gcc
4556
AR_arm_unknown_linux_gnueabihf: arm-linux-gnueabihf-ar
46-
# If C++ is involved and you installed g++-arm-linux-gnueabihf:
47-
# CXX_arm_unknown_linux_gnueabihf: arm-linux-gnueabihf-g++
48-
run: |
49-
bash ./ci/script.sh
57+
run: bash ./ci/script.sh
5058

5159
ci_macos:
52-
runs-on: ${{ matrix.os }}
53-
strategy:
54-
matrix:
55-
os: [macos-latest]
60+
name: macOS
61+
runs-on: macos-latest
62+
timeout-minutes: 45
5663
env:
5764
DO_DOCKER: 0
65+
SKIP_RPI_TEST: 1
5866
steps:
59-
- uses: actions/checkout@v2
60-
- run: brew install llvm
61-
- uses: actions-rs/toolchain@v1
67+
- uses: actions/checkout@v5
68+
69+
- uses: actions-rust-lang/setup-rust-toolchain@v1
6270
with:
63-
profile: minimal
6471
toolchain: stable
65-
override: true
66-
- uses: actions-rs/cargo@v1
67-
with:
68-
command: test
69-
- uses: actions/setup-python@v5
72+
rustflags: ""
73+
74+
- uses: actions/setup-python@v6
7075
with:
71-
python-version: '3.12'
72-
- run: cargo test --features rp
73-
- run: cargo test --features jem
74-
- name: Install ARM cross-compiler toolchain (via Homebrew)
76+
python-version: "3.12"
77+
cache: "pip"
78+
cache-dependency-path: open-codegen/setup.py
79+
80+
- name: Install LLVM
81+
run: brew install llvm
82+
83+
- name: Cargo tests
84+
run: cargo test
85+
86+
- name: Cargo tests (RP and JEM)
7587
run: |
76-
# Tap the repository that provides the cross-compiler
77-
brew tap messense/macos-cross-toolchains
78-
# Update brew to ensure the tap is recognized (can sometimes be needed)
79-
brew update
80-
# Install the full toolchain (includes gcc, binutils, sysroot)
81-
# This specific formula provides the entire toolchain.
82-
brew install arm-unknown-linux-gnueabihf
83-
84-
# The above `brew install` might have linking conflicts if other partial
85-
# toolchains were somehow pre-installed or installed by other steps.
86-
# If it fails with link errors, you might need:
87-
# brew link --overwrite arm-unknown-linux-gnueabihf
88-
89-
# Verify the compiler is found
90-
which arm-linux-gnueabihf-gcc || (echo "arm-linux-gnueabihf-gcc not found in PATH" && exit 1)
88+
cargo test --features rp
89+
cargo test --features jem
90+
9191
- name: Run tests (script.sh)
92-
# Set environment variables for the cc crate and PyO3 (if needed)
93-
env:
94-
CC_arm_unknown_linux_gnueabihf: arm-linux-gnueabihf-gcc
95-
AR_arm_unknown_linux_gnueabihf: arm-linux-gnueabihf-ar
96-
# If you are building PyO3 bindings and need to specify Python libs from the sysroot:
97-
# PYO3_CROSS_LIB_DIR: "/opt/homebrew/opt/arm-unknown-linux-gnueabihf/arm-unknown-linux-gnueabihf/sysroot/usr/lib" # Adjust path and Python version
98-
# 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
99-
run: |
100-
bash ./ci/script.sh
92+
run: bash ./ci/script.sh

ci/script.sh

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/bash
22
set -euxo pipefail
33

4+
SKIP_RPI_TEST="${SKIP_RPI_TEST:-0}"
5+
46
function run_clippy_test() {
57
pushd $1
68
cargo clippy --all-targets --all-features
@@ -29,31 +31,26 @@ regular_test() {
2931
cd open-codegen
3032
export PYTHONPATH=.
3133

32-
# --- install virtualenv
33-
pip install virtualenv
34-
3534
# --- create virtualenv
36-
virtualenv -p python3.12 venv
35+
python -m venv venv
3736

3837
# --- activate venv
3938
source venv/bin/activate
4039

4140
# --- upgrade pip within venv
42-
pip install --upgrade pip
41+
python -m pip install --upgrade pip
4342

4443
# --- install opengen
45-
pip install .
46-
47-
# --- rust dependencies
48-
rustup update
49-
rustup target add arm-unknown-linux-gnueabihf
44+
python -m pip install .
5045

5146
# --- run the tests
5247
export PYTHONPATH=.
5348
python -W ignore test/test_constraints.py -v
5449
python -W ignore test/test.py -v
5550
python -W ignore test/test_ocp.py -v
56-
python -W ignore test/test_raspberry_pi.py -v
51+
if [ "$SKIP_RPI_TEST" -eq 0 ]; then
52+
python -W ignore test/test_raspberry_pi.py -v
53+
fi
5754

5855

5956
# Run Clippy for generated optimizers

0 commit comments

Comments
 (0)