Skip to content

Commit

Permalink
ci: Build ONNX from source for Win
Browse files Browse the repository at this point in the history
Signed-off-by: Anush008 <[email protected]>
  • Loading branch information
Anush008 committed Nov 17, 2024
1 parent c5927b5 commit 4600d64
Show file tree
Hide file tree
Showing 3 changed files with 2,612 additions and 34 deletions.
70 changes: 37 additions & 33 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,65 +42,69 @@ jobs:
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v4

- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.cache/ort.pyke.io
target/
/onnxruntime/build/Windows/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Setup node
uses: actions/setup-node@v4
if: ${{ !matrix.settings.docker }}
with:
node-version: 20
cache: yarn

- name: Install
uses: dtolnay/rust-toolchain@stable
if: ${{ !matrix.settings.docker }}
with:
toolchain: stable
targets: ${{ matrix.settings.target }}
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
.cargo-cache
target/
key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}
- uses: goto-bus-stop/setup-zig@v2
if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' || matrix.settings.target == 'armv7-unknown-linux-musleabihf' }}
with:
version: 0.13.0
- name: Setup toolchain
run: ${{ matrix.settings.setup }}
if: ${{ matrix.settings.setup }}
shell: bash
- name: Setup node x86
if: matrix.settings.target == 'i686-pc-windows-msvc'
run: yarn config set supportedArchitectures.cpu "ia32"
shell: bash

- name: Install dependencies
run: yarn install
- name: Setup node x86
uses: actions/setup-node@v4
if: matrix.settings.target == 'i686-pc-windows-msvc'
with:
node-version: 20
cache: yarn
architecture: x86
- name: Build in docker

- name: Build in Docker for Ubuntu
uses: addnab/docker-run-action@v3
if: ${{ matrix.settings.docker }}
if: matrix.settings.host == 'ubuntu-latest'
with:
image: ${{ matrix.settings.docker }}
options: '--user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build'
run: ${{ matrix.settings.build }}
- name: Build

- name: Compile ONNX Runtime for Windows
if: matrix.settings.host == 'windows-latest'
run: |
git clone https://github.com/microsoft/onnxruntime --recursive --branch v1.19.2 --single-branch --depth 1
cd onnxruntime
.\build.bat --update --build --config Release --parallel --compile_no_warning_as_error --skip_submodule_sync
cd ..
- name: Build with ORT_LIB_LOCATION for Windows
run: |
set ORT_LIB_LOCATION=%CD%\onnxruntime\build\Windows\Release
${{ matrix.settings.build }}
if: matrix.settings.host == 'windows-latest'

- name: Build for MacOS
run: ${{ matrix.settings.build }}
if: ${{ !matrix.settings.docker }}
if: matrix.settings.host == 'macos-latest'

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bindings-${{ matrix.settings.target }}
path: ${{ env.APP_NAME }}.*.node
if-no-files-found: error

test-macOS-windows-binding:
name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }}
needs:
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ $RECYCLE.BIN/
#Added by cargo

/target
Cargo.lock

.pnp.*
.yarn/*
Expand Down
Loading

0 comments on commit 4600d64

Please sign in to comment.