123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- # Reusable GitHub CI workflow:
- # More info: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_iduses
- # Common Rust CI setup that checkout the repo, installs the common toolchain
- # and set's up the cargo cache. It builds, tests, and lints the code, but is
- # configurable. This way, the same workflow can be used to build, test, and lint
- # all in different steps, but with the same cache.
- on:
- workflow_call:
- inputs:
- runs-on:
- type: string
- required: false
- default: ubuntu-latest
- description: |
- The value for the "runs-on" property: e.g.
- - ubuntu-latest
- - windows-latest
- rust-version:
- type: string
- required: false
- default: stable
- description: Rust version
- rust-target:
- type: string
- required: false
- default: x86_64-unknown-linux-gnu
- description: Rust target for the build step. Clippy and tests are still executed with the default target.
- features:
- type: string
- required: false
- # Make sure we always an empty string to "--features <FEATURES>"
- default: '""'
- description: >
- Comma-separated string with additional crate features. Empty string by
- default. CAUTION: For Windows CI runners, this must be '""' as is,
- i.e., the string itself must be "". This is a limitation of the
- Windows power shell. This might be configured like this:
- features: >
- '""'
- do-style-check:
- type: boolean
- required: false
- default: true
- description: Perform code and doc style checks.
- do-test:
- type: boolean
- required: false
- default: true
- description: Execute tests.
- do-miri:
- type: boolean
- required: false
- default: false
- description: Execute unit tests with miri.
- jobs:
- rust:
- runs-on: ${{ inputs.runs-on }}
- steps:
- - name: Check out
- uses: actions/checkout@v4
- - name: Setup Rust toolchain
- uses: dtolnay/rust-toolchain@stable
- with:
- toolchain: ${{ inputs.rust-version }}
- targets: ${{ inputs.rust-target }}
- components: clippy, rustfmt
- - name: Set up cargo cache
- uses: actions/cache@v4
- continue-on-error: false
- with:
- path: |
- ~/.cargo/bin/
- ~/.cargo/registry/index/
- ~/.cargo/registry/cache/
- ~/.cargo/git/db/
- target/
- # Hash over Cargo.toml and Cargo.lock, as this might be copied to
- # projects that do not have a Cargo.lock in their repository tree!
- key: ${{ runner.os }}-rust-${{ inputs.rust-version }}-cargo-${{ hashFiles('**/Cargo.toml', '**/Cargo.lock') }}
- - run: cargo version
- - name: Build (library)
- run: cargo build --target ${{ inputs.rust-target }} --features ${{ inputs.features }} --no-default-features
- - name: Build (all targets)
- run: cargo build --all-targets --features ${{ inputs.features }} --no-default-features
- - name: Code Formatting
- if: inputs.do-style-check
- run: cargo fmt --all -- --check
- - name: Code Style and Doc Style
- if: inputs.do-style-check
- run: |
- cargo doc --no-deps --document-private-items --features ${{ inputs.features }} --no-default-features
- cargo clippy --all-targets --features ${{ inputs.features }} --no-default-features
- - name: Unit Test
- run: cargo test --verbose
- - name: Unit Test with Miri
- if: inputs.do-miri
- run: |
- rustup component add miri
- # Run with stack-borrow model
- # XXX Temporarily, just for multiboot2 crate.
- cargo miri test -p multiboot2
- # Run with tree-borrow model
- # XXX Temporarily, just for multiboot2 crate.
- MIRIFLAGS=-Zmiri-tree-borrows cargo +nightly miri test -p multiboot2
|