diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 20444269cc..a6906e9cbe 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,12 +11,16 @@ jobs: name: Compile and Test strategy: matrix: - os: - - ubuntu-18.04 - - macos-latest - # Note: we need to use pre-compiled TensorFlow Lite binaries on - # Windows, so ignore the Windows build for now - #- windows-latest + include: + - name: linux + os: ubuntu-18.04 + setup_script: scripts/ci_setup.linux.sh + - name: windows + os: windows-latest + setup_script: scripts/ci_setup.windows.ps1 + - name: macos + os: macos-latest + setup_script: scripts/ci_setup.macos.sh runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 @@ -28,14 +32,16 @@ jobs: target python/target key: ${{ runner.os }}-${{ github.workflow }}-${{ github.job }}-${{ hashFiles('**/Cargo.lock') }} - - name: Update Rustup - run: | - # We need to update rustup because the mac version is out of date and - # self-update is disabled. https://github.com/rust-lang/rustup/issues/2766 - curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain none -y - if: runner.os == 'macOS' - - name: Setup Rust - run: rustup show + # We need to explicitly install clang and record where libclang is + # https://github.com/rust-lang/rust-bindgen/issues/1797 + - name: Install LLVM and Clang + uses: KyleMayes/install-llvm-action@v1 + with: + version: "11.0" + directory: ${{ runner.temp }}/llvm + if: runner.os == 'Windows' + - name: Setup Environment + run: ${{ matrix.setup_script }} - name: Type Check uses: actions-rs/cargo@v1 with: @@ -68,14 +74,8 @@ jobs: ~/.cargo/git target key: ${{ runner.os }}-${{ github.workflow }}-${{ github.job }}-${{ hashFiles('**/Cargo.lock') }} - - name: Update Rustup - run: | - # We need to update rustup because the mac version is out of date and - # self-update is disabled. https://github.com/rust-lang/rustup/issues/2766 - curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain none -y - if: runner.os == 'macOS' - - name: Setup Rust - run: rustup show + - name: Setup + run: scripts/ci_setup.linux.sh - name: Generate API Docs id: first_try uses: actions-rs/cargo@v1 diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 07f97bc8f0..0d83511ffb 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -47,14 +47,17 @@ jobs: os: ubuntu-18.04 artifact_name: "target/rune.*.zip" asset_name: rune-linux - # - name: windows - # os: windows-latest - # artifact_name: "target/rune.*.zip" - # asset_name: rune-windows + setup_script: scripts/ci_setup.linux.sh + - name: windows + os: windows-latest + artifact_name: "target/rune.*.zip" + asset_name: rune-windows + setup_script: scripts/ci_setup.windows.ps1 - name: macos os: macos-latest artifact_name: "target/rune.*.zip" asset_name: rune-macos + setup_script: scripts/ci_setup.macos.sh steps: - uses: actions/checkout@v1 - uses: actions/cache@v2 @@ -63,12 +66,16 @@ jobs: ~/.cargo/registry ~/.cargo/git key: ${{ runner.os }}-${{ github.workflow }}-${{ github.job }}-${{ hashFiles('**/Cargo.lock') }} - - name: Setup Rust - run: | - rustup default nightly-2021-05-09 - rustup target add wasm32-unknown-unknown - rustc --version --verbose - rustup show + # We need to explicitly install clang and record where libclang is + # https://github.com/rust-lang/rust-bindgen/issues/1797 + - name: Install LLVM and Clang + uses: KyleMayes/install-llvm-action@v1 + with: + version: "11.0" + directory: ${{ runner.temp }}/llvm + if: runner.os == 'Windows' + - name: Setup Environment + run: ${{ matrix.setup_script }} - name: Build run: cargo xtask dist env: diff --git a/util/build.sh b/scripts/build.sh old mode 100644 new mode 100755 similarity index 100% rename from util/build.sh rename to scripts/build.sh diff --git a/scripts/ci_setup.linux.sh b/scripts/ci_setup.linux.sh new file mode 100755 index 0000000000..d82b1669c3 --- /dev/null +++ b/scripts/ci_setup.linux.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +set -xe + +rustup show +rustc --version --verbose +cargo --version --verbose diff --git a/scripts/ci_setup.macos.sh b/scripts/ci_setup.macos.sh new file mode 100755 index 0000000000..fa0bdbe885 --- /dev/null +++ b/scripts/ci_setup.macos.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +set -xe + +# We need to update rustup because the mac version is out of date and +# self-update is disabled. https://github.com/rust-lang/rustup/issues/2766 +curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain none -y +# Make sure rust is on our path +source ~/.cargo/env + +# and now we can do the linux setup like normal +exec "$(git rev-parse --show-toplevel)/scripts/ci_setup.linux.sh" diff --git a/scripts/ci_setup.windows.ps1 b/scripts/ci_setup.windows.ps1 new file mode 100755 index 0000000000..5fa6ac05b1 --- /dev/null +++ b/scripts/ci_setup.windows.ps1 @@ -0,0 +1,11 @@ +# Note: in order to compile Rune on Windows we need to explicitly install clang +# and record where libclang is. +# https://github.com/rust-lang/rust-bindgen/issues/1797 + +echo "LIBCLANG_PATH=$((gcm clang).source -replace 'clang.exe')" >> $env:GITHUB_ENV +# tflite needs C++14 or higher to generate STL bindings +echo "BINDGEN_EXTRA_CLANG_ARGS=-std=c++17" >> $env:GITHUB_ENV + +rustup show +rustc --version --verbose +cargo --version --verbose diff --git a/util/rune.sh b/scripts/rune.sh old mode 100644 new mode 100755 similarity index 100% rename from util/rune.sh rename to scripts/rune.sh