Skip to content

Commit

Permalink
Merge pull request #13 from nbigaouette/ci
Browse files Browse the repository at this point in the history
Add CI
  • Loading branch information
nbigaouette committed Aug 10, 2020
2 parents 89020e8 + c47372a commit 98a6c6d
Show file tree
Hide file tree
Showing 13 changed files with 13,888 additions and 22 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/audit-on-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Security audit
on:
push:
paths:
- "**/Cargo.toml"
- "**/Cargo.lock"
jobs:
security_audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
91 changes: 91 additions & 0 deletions .github/workflows/general.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Rust

on: [push, pull_request]

env:
CARGO_TERM_COLOR: always

jobs:
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: test

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add clippy
- uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings

coverage:
name: Code coverage
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Build (required to downloadd libonnxruntime)
uses: actions-rs/cargo@v1
with:
command: build
args: --package onnxruntime-sys

- name: Copy libonnxruntime.*.dylib to /usr/lib/
run: sudo cp -r target/debug/build/onnxruntime-sys-*/out/onnxruntime/onnxruntime-*/lib/libonnxruntime.* /usr/lib/

- name: Run cargo-tarpaulin
uses: actions-rs/tarpaulin@v0.1
with:
args: "--ignore-tests"

- name: Upload to codecov.io
uses: codecov/codecov-action@v1.0.2
with:
token: ${{secrets.CODECOV_TOKEN}}

- name: Archive code coverage results
uses: actions/upload-artifact@v1
with:
name: code-coverage-report
path: cobertura.xml
12 changes: 12 additions & 0 deletions .github/workflows/scheduled-audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Security audit
on:
schedule:
- cron: "0 0 * * *"
jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
[<img alt="github" src="https://img.shields.io/badge/github-nbigaouette/onnxruntime_rs-8da0cb?style=for-the-badge&labelColor=555555&logo=github" height="20">](https://github.com/nbigaouette/onnxruntime-rs)
[<img alt="crates.io" src="https://img.shields.io/crates/v/onnxruntime.svg?style=for-the-badge&color=fc8d62&logo=rust" height="20">](https://crates.io/crates/onnxruntime)
[<img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-onnxruntime-66c2a5?style=for-the-badge&labelColor=555555&logoColor=white&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K" height="20">](https://docs.rs/onnxruntime)
[<img alt="build status" src="https://img.shields.io/github/workflow/status/nbigaouette/onnxruntime/Rust/master?style=for-the-badge" height="20">](https://github.com/nbigaouette/onnxruntime/actions?query=branch%3Amaster)
[![codecov](https://codecov.io/gh/nbigaouette/onnxruntime-rs/branch/master/graph/badge.svg)](https://codecov.io/gh/nbigaouette/onnxruntime-rs)

This is an attempt at a Rust wrapper for
[Microsoft's ONNX Runtime](https://github.com/microsoft/onnxruntime) (version 1.3).
Expand Down
6 changes: 3 additions & 3 deletions onnxruntime-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
authors = ["Nicolas Bigaouette <nbigaouette@elementai.com>"]
edition = "2018"
name = "onnxruntime-sys"
version = "0.0.4"
version = "0.0.5"

description = "Unsafe wrapper around Microsoft's ONNX Runtime"
documentation = "https://docs.rs/onnxruntime-sys"
Expand All @@ -29,7 +29,7 @@ tar = "0.4"

[features]
# Disable build script; used by https://docs.rs
doc-only = []
disable-bindgen = []

[package.metadata.docs.rs]
features = ["doc-only"]
features = ["disable-bindgen"]
21 changes: 11 additions & 10 deletions onnxruntime-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,29 @@ use std::{
};

/// ONNX Runtime version
const ORT_VERSION: &'static str = "1.3.0";
const ORT_VERSION: &str = "1.3.0";

/// Base Url from which to download pre-built releases/
const ORT_RELEASE_BASE_URL: &'static str =
"https://github.com/microsoft/onnxruntime/releases/download";
const ORT_RELEASE_BASE_URL: &str = "https://github.com/microsoft/onnxruntime/releases/download";

/// Environment variable selecting which strategy to use for finding the library
/// Possibilities:
/// * "download": Download a pre-built library from upstream. This is the default if `ORT_STRATEGY` is not set.
/// * "system": Use installed library. Use `ORT_LIB_LOCATION` to point to proper location.
/// * "compile": Download source and compile (TODO).
const ORT_ENV_STRATEGY: &'static str = "ORT_STRATEGY";
const ORT_ENV_STRATEGY: &str = "ORT_STRATEGY";

/// Name of environment variable that, if present, contains the location of a pre-built library.
/// Only used if `ORT_STRATEGY=system`.
const ORT_ENV_SYSTEM_LIB_LOCATION: &'static str = "ORT_LIB_LOCATION";
const ORT_ENV_SYSTEM_LIB_LOCATION: &str = "ORT_LIB_LOCATION";
/// Name of environment variable that, if present, controls wether to use CUDA or not.
const ORT_ENV_GPU: &'static str = "ORT_USE_CUDA";
const ORT_ENV_GPU: &str = "ORT_USE_CUDA";

/// Subdirectory (of the 'target' directory) into which to extract the prebuilt library.
const ORT_PREBUILT_EXTRACT_DIR: &'static str = "onnxruntime";
const ORT_PREBUILT_EXTRACT_DIR: &str = "onnxruntime";

fn main() {
if !cfg!(feature = "doc-only") {
if !cfg!(feature = "disable-bindgen") {
let libort_install_dir = prepare_libort_dir();

let lib_dir = libort_install_dir.join("lib");
Expand Down Expand Up @@ -67,8 +66,10 @@ fn main() {
// Unwrap the Result and panic on failure.
.expect("Unable to generate bindings");

// Write the bindings to the $OUT_DIR/bindings.rs file.
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
// Write the bindings to (source controlled) src/generated/bindings.rs
let out_path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap())
.join("src")
.join("generated");
bindings
.write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings!");
Expand Down
Loading

0 comments on commit 98a6c6d

Please sign in to comment.