From 15744dcea4e861bc796f0f27cfa740d3542615f7 Mon Sep 17 00:00:00 2001 From: "Kevin R. Thornton" Date: Fri, 31 Mar 2023 09:04:15 -0700 Subject: [PATCH] Improve handling of rust in CI (#1146) * use dtolnay's toolchain actions * Forcibly set rust version when needed * Use cargo-install to cache cbindgen --- .github/workflows/docs.yml | 19 +++++++++++++++++++ .github/workflows/tests.yml | 27 +++++++++++++++++++++++++++ .github/workflows/ubuntu.yml | 14 +++++++++++--- 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index ff6970bac3..f5f5af3923 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -15,6 +15,7 @@ jobs: matrix: compiler: [gcc] python-version: ["3.10"] + rust: [1.62.1] defaults: run: shell: bash @@ -30,6 +31,16 @@ jobs: submodules: true fetch-depth: 0 + - name: Set up rust + uses: dtolnay/rust-toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + + - name: Install cbindgen + uses: baptiste0928/cargo-install@v2 + with: + crate: cbindgen + version: "=0.24.3" # We install the R dependencies first # Later, Python dependencies will go into the same place. # Python will silently update dependencies if needed, @@ -74,6 +85,14 @@ jobs: python -m pip install --user --upgrade setuptools wheel python -m pip install --user --upgrade -r requirements/development.txt + - name: rustc version + run: | + rustc --version + + - name: cbindgen version + run: | + cbindgen --version + - name: Build module run: | python3 -m pip install -e . diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index cb73390537..79f1fe35e9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,6 +13,7 @@ jobs: matrix: python: [ 3.8, 3.9, "3.10", "3.11" ] os: [ macos-latest, ubuntu-latest ] + rust: [1.62.1] defaults: run: shell: bash @@ -76,6 +77,32 @@ jobs: run: | cp ~/.bash_profile ~/.bashrc + - name: Set rust version + run: | + source ~/.bashrc + conda activate anaconda-client-env + rustup override set ${{ matrix.rust }} + + - name: rustc version + run: | + source ~/.bashrc + conda activate anaconda-client-env + rustc --version + which rustc + + - name: Install cbindgen + uses: baptiste0928/cargo-install@v2 + with: + crate: cbindgen + version: "=0.24.3" + + - name: cbindgen version + run: | + source ~/.bashrc + conda activate anaconda-client-env + cbindgen --version + which cbindgen + - name: Build run: | source ~/.bashrc diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 503be377ea..e8bff56379 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -32,18 +32,26 @@ jobs: with: submodules: true - - uses: actions-rs/toolchain@v1 + - uses: dtolnay/rust-toolchain@v1 with: toolchain: ${{ matrix.rust }} - override: false - name: Install apt dependencies run: | sudo apt install --fix-missing -y libgsl-dev cmake autoconf libboost-test-dev libboost-program-options-dev - name: Install cbindgen + uses: baptiste0928/cargo-install@v2 + with: + crate: cbindgen + version: "=0.24.3" + + - name: rustc version + run: | + rustc --version + - name: cbindgen version run: | - cargo install cbindgen@0.24.3 + cbindgen --version - name: Edit PATH run: |