Merge pull request #13 from basile-henry/cargo-actions
Setup cargo actions
This commit is contained in:
commit
d49c77f42d
27
.github/scripts/setup-env.sh
vendored
Executable file
27
.github/scripts/setup-env.sh
vendored
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -xe
|
||||||
|
|
||||||
|
##################################################
|
||||||
|
# Install llvm-config on Ubuntu
|
||||||
|
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y llvm-dev
|
||||||
|
|
||||||
|
##################################################
|
||||||
|
# Install onnxruntime
|
||||||
|
|
||||||
|
ONNXRUNTIME_VERSION=${ONNXRUNTIME_VERSION:-1.2.0}
|
||||||
|
|
||||||
|
ONNXRUNTIME_RELEASE="onnxruntime-linux-x64-${ONNXRUNTIME_VERSION}"
|
||||||
|
ONNXRUNTIME_RELEASE_URL="https://github.com/microsoft/onnxruntime/releases/download/v${ONNXRUNTIME_VERSION}/${ONNXRUNTIME_RELEASE}.tgz"
|
||||||
|
|
||||||
|
curl -L "$ONNXRUNTIME_RELEASE_URL" --output "$ONNXRUNTIME_RELEASE.tgz"
|
||||||
|
|
||||||
|
tar -xzf "$ONNXRUNTIME_RELEASE.tgz" "$ONNXRUNTIME_RELEASE"
|
||||||
|
|
||||||
|
# Set env vars for following steps
|
||||||
|
|
||||||
|
echo "::set-env name=LD_LIBRARY_PATH::$PWD/$ONNXRUNTIME_RELEASE/lib/"
|
||||||
|
echo "::set-env name=ONNXRUNTIME_LIB_DIR::$PWD/$ONNXRUNTIME_RELEASE/lib/"
|
||||||
|
echo "::set-env name=ONNXRUNTIME_INCLUDE_DIR::$PWD/$ONNXRUNTIME_RELEASE/include"
|
91
.github/workflows/cargo-ci.yml
vendored
Normal file
91
.github/workflows/cargo-ci.yml
vendored
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
name: "Cargo CI"
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
release:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check:
|
||||||
|
name: Check
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install stable toolchain
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
profile: minimal
|
||||||
|
toolchain: stable
|
||||||
|
override: true
|
||||||
|
|
||||||
|
- name: Install onnxruntime dependency
|
||||||
|
run: ./.github/scripts/setup-env.sh
|
||||||
|
|
||||||
|
- name: Run cargo check
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: check
|
||||||
|
args: --examples --tests --bins
|
||||||
|
|
||||||
|
test:
|
||||||
|
name: Test Suite
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
onnxruntime_version:
|
||||||
|
- "1.2.0"
|
||||||
|
- "1.3.0"
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install stable toolchain
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
profile: minimal
|
||||||
|
toolchain: stable
|
||||||
|
override: true
|
||||||
|
|
||||||
|
- name: Install onnxruntime dependency
|
||||||
|
run: ./.github/scripts/setup-env.sh
|
||||||
|
env:
|
||||||
|
ONNXRUNTIME_VERSION: ${{ matrix.onnxruntime_version }}
|
||||||
|
|
||||||
|
- name: Run cargo test
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: test
|
||||||
|
|
||||||
|
lints:
|
||||||
|
name: Lints
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install stable toolchain
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
profile: minimal
|
||||||
|
toolchain: stable
|
||||||
|
override: true
|
||||||
|
components: rustfmt, clippy
|
||||||
|
|
||||||
|
- name: Run cargo fmt
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: fmt
|
||||||
|
args: --all -- --check
|
||||||
|
|
||||||
|
- name: Install onnxruntime dependency
|
||||||
|
run: ./.github/scripts/setup-env.sh
|
||||||
|
|
||||||
|
- name: Run cargo clippy
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: clippy
|
@ -1,9 +1,14 @@
|
|||||||
name: "Test"
|
name: "Nix CI"
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
push:
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
release:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
tests:
|
tests:
|
||||||
|
name: Build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
target/
|
target/
|
||||||
|
result*
|
||||||
|
18
build.rs
18
build.rs
@ -7,23 +7,17 @@ fn main() {
|
|||||||
println!("cargo:rerun-if-env-changed=ONNXRUNTIME_LIB_DIR");
|
println!("cargo:rerun-if-env-changed=ONNXRUNTIME_LIB_DIR");
|
||||||
println!("cargo:rerun-if-env-changed=ONNXRUNTIME_INCLUDE_DIR");
|
println!("cargo:rerun-if-env-changed=ONNXRUNTIME_INCLUDE_DIR");
|
||||||
|
|
||||||
match std::env::var("ONNXRUNTIME_LIB_DIR") {
|
if let Ok(dirs) = std::env::var("ONNXRUNTIME_LIB_DIR") {
|
||||||
Ok(dirs) => {
|
for dir in dirs.split(':') {
|
||||||
for dir in dirs.split(":") {
|
println!("cargo:rustc-link-search={}", dir);
|
||||||
println!("cargo:rustc-link-search={}", dir);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Err(_) => (),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut clang_args = Vec::new();
|
let mut clang_args = Vec::new();
|
||||||
match std::env::var("ONNXRUNTIME_INCLUDE_DIR") {
|
if let Ok(dirs) = std::env::var("ONNXRUNTIME_INCLUDE_DIR") {
|
||||||
Ok(dirs) => {
|
for dir in dirs.split(':') {
|
||||||
for dir in dirs.split(":") {
|
clang_args.push(format!("-I{}", dir));
|
||||||
clang_args.push(format!("-I{}", dir));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Err(_) => (),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
println!("cargo:rustc-link-lib=onnxruntime");
|
println!("cargo:rustc-link-lib=onnxruntime");
|
||||||
|
@ -1 +1 @@
|
|||||||
#include <onnxruntime/core/session/onnxruntime_c_api.h>
|
#include <onnxruntime_c_api.h>
|
||||||
|
20
default.nix
20
default.nix
@ -14,14 +14,28 @@ let filterSource = with lib; builtins.filterSource (path: type:
|
|||||||
(baseNameOf path == "build" -> type != "directory") &&
|
(baseNameOf path == "build" -> type != "directory") &&
|
||||||
(baseNameOf path == "nix" -> type != "directory")
|
(baseNameOf path == "nix" -> type != "directory")
|
||||||
);
|
);
|
||||||
in
|
|
||||||
naersk.buildPackage {
|
# Version of onnxruntime.dev with include directory set up the same way as
|
||||||
|
# a released version from microsoft/onnxruntime GitHub release.
|
||||||
|
onnxruntime-headers = stdenv.mkDerivation {
|
||||||
|
name = "onnxruntime-headers";
|
||||||
|
src = onnxruntime.dev;
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/include
|
||||||
|
|
||||||
|
cp include/onnxruntime/core/session/onnxruntime_c_api.h $out/include/onnxruntime_c_api.h
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
in naersk.buildPackage {
|
||||||
root = filterSource ./.;
|
root = filterSource ./.;
|
||||||
|
|
||||||
LIBCLANG_PATH = "${llvmPackages.libclang}/lib";
|
LIBCLANG_PATH = "${llvmPackages.libclang}/lib";
|
||||||
buildInputs = [ onnxruntime.dev ];
|
buildInputs = [ onnxruntime onnxruntime-headers ];
|
||||||
nativeBuildInputs = [ pkg-config clang ];
|
nativeBuildInputs = [ pkg-config clang ];
|
||||||
|
|
||||||
|
# Note: This creates a doc attribute (nested derivation)
|
||||||
doDoc = true;
|
doDoc = true;
|
||||||
|
|
||||||
doCheck = true;
|
doCheck = true;
|
||||||
}
|
}
|
||||||
|
@ -29,10 +29,10 @@
|
|||||||
"homepage": "https://github.com/NixOS/nixpkgs",
|
"homepage": "https://github.com/NixOS/nixpkgs",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs-channels",
|
"repo": "nixpkgs-channels",
|
||||||
"rev": "d4226e3a4b5fcf988027147164e86665d382bbfa",
|
"rev": "3b4df94aeb6e215085d08e3d5b0edc1313b9f584",
|
||||||
"sha256": "15rn7i0938sfl1v857mx6kqnqjpc80vha9fafj7nkd2ncjrbn2mc",
|
"sha256": "1z8fnqxi0zd3wmjnmc4l2s4nq812mx0h4r09zdqi5si2in6rksxs",
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
"url": "https://github.com/NixOS/nixpkgs-channels/archive/d4226e3a4b5fcf988027147164e86665d382bbfa.tar.gz",
|
"url": "https://github.com/NixOS/nixpkgs-channels/archive/3b4df94aeb6e215085d08e3d5b0edc1313b9f584.tar.gz",
|
||||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
},
|
},
|
||||||
"nixpkgs-mozilla": {
|
"nixpkgs-mozilla": {
|
||||||
@ -41,10 +41,10 @@
|
|||||||
"homepage": null,
|
"homepage": null,
|
||||||
"owner": "mozilla",
|
"owner": "mozilla",
|
||||||
"repo": "nixpkgs-mozilla",
|
"repo": "nixpkgs-mozilla",
|
||||||
"rev": "e912ed483e980dfb4666ae0ed17845c4220e5e7c",
|
"rev": "ab9b53ebbbf9fe803e0fd7718192e7f3ba2c7759",
|
||||||
"sha256": "08fvzb8w80bkkabc1iyhzd15f4sm7ra10jn32kfch5klgl0gj3j3",
|
"sha256": "1v955b0km375i4ihyl3hgg3l0r3hflbwiyayn6jm0rcqlw9c6fay",
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
"url": "https://github.com/mozilla/nixpkgs-mozilla/archive/e912ed483e980dfb4666ae0ed17845c4220e5e7c.tar.gz",
|
"url": "https://github.com/mozilla/nixpkgs-mozilla/archive/ab9b53ebbbf9fe803e0fd7718192e7f3ba2c7759.tar.gz",
|
||||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -334,7 +334,7 @@ impl Session {
|
|||||||
ArgumentInfo {
|
ArgumentInfo {
|
||||||
session: &self,
|
session: &self,
|
||||||
ix,
|
ix,
|
||||||
arg_type: arg_type,
|
arg_type,
|
||||||
info: RefCell::new(None),
|
info: RefCell::new(None),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user