Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/actions/setup-rust/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Setup rust toolchain
description: Setup rust toolchain with the toolchain version input and sccache

inputs:
toolchain:
description: Toolchain name, such as 'stable', 'nightly', or '1.8.0'
required: true
default: stable
target:
description: Build target name, such as 'x86_64-unknown-linux-gnu', 'aarch64-apple-darwin', or 'x86_64-pc-windows-msvc'
required: false

runs:
using: composite
steps:
- name: Setup rust toolchain
shell: bash
run: |
rustup toolchain install ${{ inputs.toolchain }} --profile default
rustup default ${{ inputs.toolchain }}

- name: Add build target
if: "${{ inputs.target != '' }}"
shell: bash
run: rustup target add ${{ inputs.target }}

- uses: mozilla-actions/sccache-action@v0.0.9

- name: Setup rust cache variables
shell: bash
run: |
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
echo "CARGO_INCREMENTAL=false" >> $GITHUB_ENV
125 changes: 125 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
name: Rust

concurrency:
group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }}
cancel-in-progress: true

on:
push:
branches: [master]
paths-ignore:
- "**.md"
pull_request:
branches: [master]
paths-ignore:
- "**.md"
workflow_dispatch:

jobs:
fmt:
runs-on: ubuntu-latest
name: Check formatting
steps:
- uses: actions/checkout@v4

- name: Setup rust toolchain
uses: ./.github/actions/setup-rust

- name: Check formatting (rustfmt)
run: cargo fmt --all --check

build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
toolchain: [stable]
name: Build test
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: Setup rust toolchain
uses: ./.github/actions/setup-rust
with:
toolchain: ${{ matrix.toolchain }}

- name: cargo check
run: cargo check --profile=dev

- name: cargo build release
run: cargo build --profile=release

test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
toolchain: [stable]
name: Test
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: Setup rust toolchain
uses: ./.github/actions/setup-rust
with:
toolchain: ${{ matrix.toolchain }}

- name: Build test
run: cargo test --profile=dev

build_legacy:
strategy:
matrix:
os: [ubuntu-24.04-arm]
toolchain: [stable]
image: [ubuntu:20.04]
name: Build legacy
runs-on: ${{ matrix.os }}
container:
image: ${{ matrix.image }}
steps:
- uses: actions/checkout@v4

- name: Install rustup
run: |
apt update && apt install -y curl build-essential
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"

- name: Setup rust toolchain
uses: ./.github/actions/setup-rust
with:
toolchain: ${{ matrix.toolchain }}

- name: cargo check
run: cargo check --profile=dev

- name: cargo build release
run: cargo build --profile=release

test_legacy:
strategy:
matrix:
os: [ubuntu-24.04-arm]
toolchain: [stable]
image: [ubuntu:20.04]
name: Test legacy
runs-on: ${{ matrix.os }}
container:
image: ${{ matrix.image }}
steps:
- uses: actions/checkout@v4

- name: Install rustup
run: |
apt update && apt install -y curl build-essential
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"

- name: Setup rust toolchain
uses: ./.github/actions/setup-rust
with:
toolchain: ${{ matrix.toolchain }}

- name: Build test
run: cargo test --profile=dev
3 changes: 3 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
channel = "1.87"
components = ["rustc", "rust-std", "cargo", "clippy", "rustfmt", "rust-docs"]
Loading
Loading