Skip to content

Commit

Permalink
Rework rust build matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
arnodb committed Oct 27, 2024
1 parent 8df81f7 commit 659559c
Show file tree
Hide file tree
Showing 3 changed files with 147 additions and 97 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Build

on:
workflow_call:
inputs:
rust_toolchain:
required: true
type: string
rust_features:
required: false
type: string
default: --all-features
with_rustfmt:
required: false
type: boolean
default: false
with_clippy:
required: false
type: boolean
default: false

env:
CARGO_TERM_COLOR: always

jobs:

build:

name: Rust ${{ inputs.rust_toolchain }} ${{ inputs.rust_features }}

runs-on: ubuntu-latest

steps:

- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ inputs.rust_toolchain }}
components: rustfmt, clippy

- id: rustfmt
name: Rust format
if: ${{ inputs.with_rustfmt }}
run: |
cargo fmt --verbose --all -- --check
echo "Rustfmt OK" >> "$GITHUB_STEP_SUMMARY"
- id: clippy
name: Clippy
if: ${{ inputs.with_clippy }}
run: |
cargo clippy --all ${{ inputs.rust_features }} --all-targets -- -D warnings
echo "Clippy OK" >> "$GITHUB_STEP_SUMMARY"
- id: test
name: Compile and run tests
run: cargo test ${{ inputs.rust_features }} --verbose

51 changes: 51 additions & 0 deletions .github/workflows/_cross_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Cross Build

on:
workflow_call:
inputs:
rust_toolchain:
required: true
type: string
rust_features:
required: false
type: string
default: --all-features

env:
CARGO_TERM_COLOR: always

jobs:

cross-build:

name: Rust ${{ matrix.rust }}, target ${{ matrix.target }}

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
rust: [1.65.0, stable]
target: [i686-unknown-linux-gnu, aarch64-unknown-linux-gnu]

env:
TRUC_CROSS: yes

steps:

- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}

- run: |
curl -OL "https://github.com/cross-rs/cross/releases/download/v0.2.5/cross-x86_64-unknown-linux-gnu.tar.gz"
mkdir cross
tar -C cross -xvzf cross-x86_64-unknown-linux-gnu.tar.gz
- run: |
mkdir -p "target/shared_machin/${{ matrix.target }}/debug"
./cross/cross run --target "${{ matrix.target }}" -p machin_target_types >| "target/shared_machin/${{ matrix.target }}/debug/target_types.json"
- run: ./cross/cross test --target ${{ matrix.target }} -vv
134 changes: 37 additions & 97 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,103 +4,43 @@ on:
workflow_dispatch:
push:

env:
CARGO_TERM_COLOR: always

jobs:

test:

name: Rust ${{ matrix.rust }}

runs-on: ubuntu-latest

outputs:
passed_rustfmt: ${{ steps.rustfmt.outputs.passed_rustfmt }}
passed_clippy: ${{ steps.clippy.outputs.passed_clippy }}

strategy:
fail-fast: false
matrix:
rust: [1.56.1, stable]

steps:

- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
components: rustfmt, clippy

- id: rustfmt
name: Rust format
if: ${{ matrix.rust == 'stable' }}
run: |
cargo fmt --verbose --all -- --check
echo "passed_rustfmt=${{ matrix.rust }}" >> "$GITHUB_OUTPUT"
- id: clippy
name: Clippy
if: ${{ matrix.rust == '1.56.1' }}
run: |
cargo clippy --all --all-features --all-targets -- -D warnings
echo "passed_clippy=${{ matrix.rust }}" >> "$GITHUB_OUTPUT"
- id: test
name: Compile and run tests
run: cargo test --verbose

code-checks:

name: Code checks

runs-on: ubuntu-latest

needs: test

steps:

- name: Rustfmt
run: |
echo "Rustfmt run on ${{ needs.test.outputs.passed_rustfmt }}" >> "$GITHUB_STEP_SUMMARY"
test "${{ needs.test.outputs.passed_rustfmt }}" = "stable"
- name: Clippy
run: |
echo "Clippy run on ${{ needs.test.outputs.passed_clippy }}" >> "$GITHUB_STEP_SUMMARY"
test "${{ needs.test.outputs.passed_clippy }}" = "1.56.1"
cross-test:

name: Rust ${{ matrix.rust }}, target ${{ matrix.target }}

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
rust: [1.65.0, stable]
target: [i686-unknown-linux-gnu, aarch64-unknown-linux-gnu]

env:
TRUC_CROSS: yes

steps:

- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}

- run: |
curl -OL "https://github.com/cross-rs/cross/releases/download/v0.2.5/cross-x86_64-unknown-linux-gnu.tar.gz"
mkdir cross
tar -C cross -xvzf cross-x86_64-unknown-linux-gnu.tar.gz
- run: |
mkdir -p "target/shared_machin/${{ matrix.target }}/debug"
./cross/cross run --target "${{ matrix.target }}" -p machin_target_types >| "target/shared_machin/${{ matrix.target }}/debug/target_types.json"
main_stable:
name: Rust stable
uses: ./.github/workflows/_build.yml
with:
rust_toolchain: stable
with_rustfmt: true

main_1_56_1:
name: Rust 1.56.1
uses: ./.github/workflows/_build.yml
with:
rust_toolchain: 1.56.1
with_clippy: true

cross_stable_i686:
name: Rust stable i686-unknown-linux-gnu
uses: ./.github/workflows/_cross_build.yml
with:
rust_toolchain: stable

cross_stable_aarch64:
name: Rust stable aarch64-unknown-linux-gnu
uses: ./.github/workflows/_cross_build.yml
with:
rust_toolchain: stable

cross_1_65_0_i686:
name: Rust 1.65.0 i686-unknown-linux-gnu
uses: ./.github/workflows/_cross_build.yml
with:
rust_toolchain: 1.65.0

cross_1_65_0_aarch64:
name: Rust 1.65.0 aarch64-unknown-linux-gnu
uses: ./.github/workflows/_cross_build.yml
with:
rust_toolchain: 1.65.0

- run: ./cross/cross test --target ${{ matrix.target }} -vv

0 comments on commit 659559c

Please sign in to comment.