Skip to content

Commit b24b4cd

Browse files
authored
Merge pull request #34 from nbigaouette/ci
CI: Multiple platforms
2 parents 32e9935 + 339ed85 commit b24b4cd

File tree

3 files changed

+149
-25
lines changed

3 files changed

+149
-25
lines changed

.github/workflows/general.yml

Lines changed: 124 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on: [pull_request]
44

55
env:
66
CARGO_TERM_COLOR: always
7+
RUST_LOG: onnxruntime=debug,onnxruntime-sys=debug
8+
RUST_BACKTRACE: 1
79

810
jobs:
911
fmt:
@@ -22,8 +24,8 @@ jobs:
2224
command: fmt
2325
args: --all -- --check
2426

25-
test:
26-
name: Test
27+
download:
28+
name: Download prebuilt ONNX Runtime archive from build.rs
2729
runs-on: ubuntu-latest
2830
steps:
2931
- uses: actions/checkout@v2
@@ -32,20 +34,131 @@ jobs:
3234
profile: minimal
3335
toolchain: stable
3436
override: true
35-
# We want to test using '--features model-fetching', but this is not possible yet.
36-
# See https://github.com/actions-rs/cargo/issues/86
37-
- uses: actions-rs/cargo@v1
38-
name: Test onnxruntime-sys
37+
- run: rustup target install x86_64-unknown-linux-gnu
38+
- run: rustup target install x86_64-apple-darwin
39+
- run: rustup target install i686-pc-windows-msvc
40+
- run: rustup target install x86_64-pc-windows-msvc
41+
# ******************************************************************
42+
- name: Download prebuilt archive (CPU, x86_64-unknown-linux-gnu)
43+
uses: actions-rs/cargo@v1
3944
with:
40-
command: test
41-
args: --package onnxruntime-sys
42-
- uses: actions-rs/cargo@v1
43-
name: Test onnxruntime
45+
command: build
46+
args: --target x86_64-unknown-linux-gnu
47+
- name: Verify prebuilt archive downloaded (CPU, x86_64-unknown-linux-gnu)
48+
run: ls -lh target/x86_64-unknown-linux-gnu/debug/build/onnxruntime-sys-*/out/onnxruntime-linux-x64-1.*.tgz
49+
# ******************************************************************
50+
- name: Download prebuilt archive (CPU, x86_64-apple-darwin)
51+
uses: actions-rs/cargo@v1
52+
with:
53+
command: build
54+
args: --target x86_64-apple-darwin
55+
- name: Verify prebuilt archive downloaded (CPU, x86_64-apple-darwin)
56+
run: ls -lh target/x86_64-apple-darwin/debug/build/onnxruntime-sys-*/out/onnxruntime-osx-x64-1.*.tgz
57+
# # ******************************************************************
58+
# - name: Download prebuilt archive (CPU, i686-pc-windows-msvc)
59+
# uses: actions-rs/cargo@v1
60+
# with:
61+
# command: build
62+
# args: --target i686-pc-windows-msvc
63+
# - name: Verify prebuilt archive downloaded (CPU, i686-pc-windows-msvc)
64+
# run: ls -lh target/i686-pc-windows-msvc/debug/build/onnxruntime-sys-*/out/onnxruntime-win-x86-1.*.zip
65+
# ******************************************************************
66+
- name: Download prebuilt archive (CPU, x86_64-pc-windows-msvc)
67+
uses: actions-rs/cargo@v1
68+
with:
69+
command: build
70+
args: --target x86_64-pc-windows-msvc
71+
- name: Verify prebuilt archive downloaded (CPU, x86_64-pc-windows-msvc)
72+
run: ls -lh target/x86_64-pc-windows-msvc/debug/build/onnxruntime-sys-*/out/onnxruntime-win-x64-1.*.zip
73+
# ******************************************************************
74+
- name: Download prebuilt archive (GPU, x86_64-unknown-linux-gnu)
75+
uses: actions-rs/cargo@v1
76+
env:
77+
ORT_USE_CUDA: "yes"
78+
with:
79+
command: build
80+
args: --target x86_64-unknown-linux-gnu
81+
- name: Verify prebuilt archive downloaded (GPU, x86_64-unknown-linux-gnu)
82+
run: ls -lh target/x86_64-unknown-linux-gnu/debug/build/onnxruntime-sys-*/out/onnxruntime-linux-x64-gpu-1.*.tgz
83+
# ******************************************************************
84+
- name: Download prebuilt archive (GPU, x86_64-pc-windows-msvc)
85+
uses: actions-rs/cargo@v1
4486
env:
45-
RUST_LOG: onnxruntime=debug
87+
ORT_USE_CUDA: "yes"
88+
with:
89+
command: build
90+
args: --target x86_64-pc-windows-msvc
91+
- name: Verify prebuilt archive downloaded (GPU, x86_64-pc-windows-msvc)
92+
run: ls -lh target/x86_64-pc-windows-msvc/debug/build/onnxruntime-sys-*/out/onnxruntime-win-x64-gpu-1.*.zip
93+
94+
test:
95+
name: Test Suite
96+
runs-on: ${{ matrix.os }}
97+
strategy:
98+
fail-fast: false
99+
matrix:
100+
build:
101+
- linux-gnu
102+
- macos
103+
- win-msvc
104+
include:
105+
- build: linux-gnu
106+
os: ubuntu-latest
107+
rust: stable
108+
target: x86_64-unknown-linux-gnu
109+
- build: macos
110+
os: macOS-latest
111+
rust: stable
112+
target: x86_64-apple-darwin
113+
# FIXME: Re-enable CI for Windows: https://github.com/nbigaouette/onnxruntime-rs/issues/43
114+
# - build: win-msvc
115+
# os: windows-2019
116+
# rust: stable
117+
# target: x86_64-pc-windows-msvc
118+
# - build: win-msvc
119+
# os: windows-2019
120+
# rust: stable
121+
# target: i686-pc-windows-msvc
122+
env:
123+
CARGO_BUILD_TARGET: ${{ matrix.target }}
124+
steps:
125+
- uses: actions/checkout@v2
126+
- name: Install Rust
127+
uses: actions-rs/toolchain@v1
128+
with:
129+
profile: minimal
130+
toolchain: ${{ matrix.rust }}
131+
target: ${{ matrix.target }}
132+
override: true
133+
- name: Install additional packages (macOS)
134+
if: contains(matrix.target, 'x86_64-apple-darwin')
135+
run: brew install libomp
136+
- name: Build (cargo build)
137+
uses: actions-rs/cargo@v1
138+
with:
139+
command: build
140+
args: --all
141+
- name: Build tests (cargo test)
142+
uses: actions-rs/cargo@v1
46143
with:
144+
command: test
145+
args: --no-run
146+
- name: Build onnxruntime with 'model-fetching' feature
147+
uses: actions-rs/cargo@v1
148+
with:
149+
command: build
47150
# Use --manifest-path instead of --package. See https://github.com/actions-rs/cargo/issues/86
151+
args: --manifest-path onnxruntime/Cargo.toml --features model-fetching
152+
- name: Test onnxruntime-sys
153+
uses: actions-rs/cargo@v1
154+
with:
48155
command: test
156+
args: --package onnxruntime-sys -- --test-threads=1 --nocapture
157+
- name: Test onnxruntime
158+
uses: actions-rs/cargo@v1
159+
with:
160+
command: test
161+
# Use --manifest-path instead of --package. See https://github.com/actions-rs/cargo/issues/86
49162
args: --manifest-path onnxruntime/Cargo.toml --features model-fetching -- --test-threads=1 --nocapture
50163

51164
clippy:

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@ This project consist on two crates:
1616

1717
[Changelog](CHANGELOG.md)
1818

19+
The `build.rs` script supports downloading pre-built versions of the Microsoft ONNX Runtime,
20+
which provides the following targets:
21+
22+
CPU:
23+
24+
* Linux x86_64
25+
* macOS x86_64
26+
* Windows i686
27+
* Windows x86_64
28+
29+
GPU:
30+
31+
* Linux x86_64
32+
* Windows x86_64
33+
1934
---
2035

2136
**WARNING**:

onnxruntime-sys/build.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -178,21 +178,17 @@ fn prebuilt_archive_url() -> (PathBuf, String) {
178178
let arch = env::var("CARGO_CFG_TARGET_ARCH").expect("Unable to get TARGET_ARCH");
179179

180180
let gpu_str = match env::var(ORT_ENV_GPU) {
181-
Ok(cuda_env) => {
182-
match cuda_env.as_str() {
183-
"1" | "yes" | "Yes" | "YES" | "on" | "On" | "ON" => {
184-
match os.as_str() {
185-
"linux" | "windows" => "-gpu",
186-
os_str => panic!(
187-
"Use of CUDA was specified with `ORT_USE_CUDA` environment variable, but pre-built \
181+
Ok(cuda_env) => match cuda_env.to_lowercase().as_str() {
182+
"1" | "yes" | "true" | "on" => match os.as_str() {
183+
"linux" | "windows" => "-gpu",
184+
os_str => panic!(
185+
"Use of CUDA was specified with `{}` environment variable, but pre-built \
188186
binaries with CUDA are only available for Linux and Windows, not: {}.",
189-
os_str
190-
),
191-
}
192-
},
193-
_ => "",
194-
}
195-
}
187+
ORT_ENV_GPU, os_str
188+
),
189+
},
190+
_ => "",
191+
},
196192
Err(_) => "",
197193
};
198194

0 commit comments

Comments
 (0)