CI: Share code to setup Rust

pull/710/head
Tpt 12 months ago committed by Thomas Tanon
parent 1761672b41
commit bdf5d593ee
  1. 27
      .github/actions/setup-rust/action.yml
  2. 31
      .github/workflows/artifacts.yml
  3. 97
      .github/workflows/tests.yml

@ -0,0 +1,27 @@
name: 'Setup Rust'
description: 'Setup Rust using Rustup'
inputs:
version:
description: 'Rust version to use. By default latest stable version'
required: false
default: 'stable'
component:
description: 'Rust extra component to install like clippy'
required: false
target:
description: 'Rust extra target to install like wasm32-unknown-unknown'
required: false
runs:
using: "composite"
steps:
- run: rustup update
shell: bash
- run: rustup default ${{ inputs.version }}
shell: bash
- run: rustup component add ${{ inputs.component }}
shell: bash
if: ${{ inputs.component }}
- run: rustup target add ${{ inputs.target }}
shell: bash
if: ${{ inputs.target }}
- uses: Swatinem/rust-cache@v2

@ -20,12 +20,13 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update && rustup target add aarch64-unknown-linux-gnu
- uses: ./.github/actions/setup-rust
with:
target: aarch64-unknown-linux-gnu
- run: |
sudo apt update && sudo apt-get install -y g++-aarch64-linux-gnu
mkdir .cargo
echo -e "[target.aarch64-unknown-linux-gnu]\nlinker = \"aarch64-linux-gnu-gcc\"" >> .cargo/config.toml
- uses: Swatinem/rust-cache@v2
- run: cargo build --release --no-default-features --features rustls-native
working-directory: ./cli
- run: cargo build --release --target aarch64-unknown-linux-gnu --no-default-features --features rustls-native
@ -61,8 +62,9 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update && rustup target add aarch64-apple-darwin
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust
with:
target: aarch64-apple-darwin
- run: cargo build --release
working-directory: ./cli
- run: cargo build --release --target aarch64-apple-darwin
@ -92,8 +94,7 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust
- run: Remove-Item -LiteralPath "C:\msys64\" -Force -Recurse
- run: cargo build --release
working-directory: ./cli
@ -114,8 +115,7 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust
- uses: actions/setup-python@v4
with:
python-version: "3.12"
@ -152,7 +152,7 @@ jobs:
with:
platforms: linux/${{ matrix.architecture }}
if: github.event_name == 'release' && matrix.architecture != 'x86_64'
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust
- run: sed 's/%arch%/${{ matrix.architecture }}/g' .github/workflows/manylinux_build.sh | sed 's/%for_each_version%/${{ github.event_name == 'release' || '' }}/g' > .github/workflows/manylinux_build_script.sh
- run: docker run -v "$(pwd)":/workdir --platform linux/${{ matrix.architecture }} quay.io/pypa/manylinux2014_${{ matrix.architecture }} /bin/bash /workdir/.github/workflows/manylinux_build_script.sh
if: github.event_name == 'release' || matrix.architecture == 'x86_64'
@ -181,7 +181,7 @@ jobs:
with:
platforms: linux/${{ matrix.architecture }}
if: github.event_name == 'release' && matrix.architecture != 'x86_64'
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust
- run: sed 's/%arch%/${{ matrix.architecture }}/g' .github/workflows/musllinux_build.sh | sed 's/%for_each_version%/${{ github.event_name == 'release' || '' }}/g' > .github/workflows/musllinux_build_script.sh
- run: docker run -v "$(pwd)":/workdir --platform linux/${{ matrix.architecture }} quay.io/pypa/musllinux_1_2_${{ matrix.architecture }} /bin/bash /workdir/.github/workflows/musllinux_build_script.sh
if: github.event_name == 'release' || matrix.architecture == 'x86_64'
@ -206,8 +206,9 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update && rustup target add aarch64-apple-darwin
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust
with:
target: aarch64-apple-darwin
- uses: actions/setup-python@v4
with:
python-version: "3.12"
@ -244,8 +245,7 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust
- uses: actions/setup-python@v4
with:
python-version: "3.12"
@ -276,8 +276,7 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust
- run: cargo install wasm-pack || true
- uses: actions/setup-node@v3
with:

@ -17,7 +17,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: rustup update && rustup component add rustfmt
- uses: ./.github/actions/setup-rust
with:
component: rustfmt
- run: cargo fmt -- --check
clippy:
@ -26,8 +28,10 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update && rustup default 1.74.1 && rustup component add clippy
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust
with:
version: 1.74.1
component: clippy
- run: cargo clippy --all-targets -- -D warnings -D clippy::all
working-directory: ./lib/oxsdatatypes
- run: cargo clippy --all-targets -- -D warnings -D clippy::all
@ -59,8 +63,11 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update && rustup default 1.74.1 && rustup target add wasm32-unknown-unknown && rustup component add clippy
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust
with:
version: 1.74.1
target: wasm32-unknown-unknown
component: clippy
- run: cargo clippy --lib --tests --target wasm32-unknown-unknown -- -D warnings -D clippy::all
working-directory: ./js
@ -70,8 +77,11 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update && rustup default 1.74.1 && rustup target add wasm32-wasi && rustup component add clippy
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust
with:
version: 1.74.1
target: wasm32-wasi
component: clippy
- run: cargo clippy --lib --tests --target wasm32-wasi -- -D warnings -D clippy::all
working-directory: ./lib
@ -81,8 +91,11 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update && rustup default 1.74.1 && rustup target add wasm32-unknown-unknown && rustup component add clippy
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust
with:
version: 1.74.1
target: wasm32-unknown-unknown
component: clippy
- run: cargo clippy --lib --tests --target wasm32-unknown-unknown --features getrandom/custom --features oxsdatatypes/custom-now -- -D warnings -D clippy::all
working-directory: ./lib
@ -90,8 +103,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: rustup update
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust
- run: cargo install cargo-deny || true
- run: cargo deny check
@ -102,8 +114,7 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust
- run: cargo install cargo-semver-checks || true
- run: cargo semver-checks check-release --exclude oxrocksdb-sys --exclude oxigraph-js --exclude pyoxigraph --exclude oxigraph-testsuite --exclude oxigraph-cli
@ -113,8 +124,7 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust
- run: cargo test
test_linux_msv:
@ -123,8 +133,10 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update && rustup toolchain install nightly && rustup default 1.70.0
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust
with:
version: 1.70.0
- run: rustup toolchain install nightly
- run: rm Cargo.lock && cargo +nightly update -Z direct-minimal-versions
- run: cargo test
@ -134,8 +146,7 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust
- run: rm Cargo.lock && cargo update
- run: cargo test
@ -145,9 +156,10 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update && rustup default nightly
- uses: ./.github/actions/setup-rust
with:
version: nightly
- run: sudo apt-get install -y llvm
- uses: Swatinem/rust-cache@v2
- run: cargo test --tests --target x86_64-unknown-linux-gnu --workspace --exclude pyoxigraph --exclude oxigraph-testsuite --exclude oxigraph-cli
env:
RUSTFLAGS: -Z sanitizer=address
@ -158,8 +170,7 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust
- uses: actions/cache@v3
with:
path: rocksdb
@ -173,12 +184,9 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust
- run: Remove-Item -LiteralPath "C:\msys64\" -Force -Recurse
- run: cargo test
env:
RUST_BACKTRACE: 1
test_wasi:
runs-on: ubuntu-latest
@ -186,13 +194,12 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update && rustup target add wasm32-wasi
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust
with:
target: wasm32-wasi
- uses: taiki-e/install-action@wasmtime
- run: cargo install cargo-wasi || true
- run: cargo wasi test --workspace --exclude oxigraph-js --exclude oxigraph-cli --exclude oxigraph-testsuite --exclude oxrocksdb-sys --exclude pyoxigraph
env:
RUST_BACKTRACE: 1
rustdoc:
runs-on: ubuntu-latest
@ -200,8 +207,9 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update && rustup default 1.74.1
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust
with:
version: 1.74.1
- run: cargo doc
working-directory: ./lib
env:
@ -211,8 +219,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: rustup update
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust
- run: cargo install wasm-pack || true
- uses: actions/setup-node@v3
with:
@ -230,8 +237,7 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust
- uses: actions/setup-python@v4
with:
python-version: "3.12"
@ -264,8 +270,10 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update && rustup toolchain install nightly && rustup default 1.70.0
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust
with:
version: 1.70.0
- run: rustup toolchain install nightly
- uses: actions/setup-python@v4
with:
python-version: "3.8"
@ -285,8 +293,7 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust
- uses: actions/setup-python@v4
with:
python-version: "pypy3.10"
@ -305,8 +312,7 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust
- uses: actions/setup-python@v4
with:
python-version: "3.12"
@ -323,7 +329,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust
- run: cargo install typos-cli || true
- run: typos
@ -421,6 +427,5 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: rustup update
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/setup-rust
- run: python lints/test_debian_compatibility.py

Loading…
Cancel
Save