|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + rust_toolchain: |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + rust_features: |
| 10 | + required: false |
| 11 | + type: string |
| 12 | + default: --all-features |
| 13 | + with_rustfmt: |
| 14 | + required: false |
| 15 | + type: boolean |
| 16 | + default: false |
| 17 | + with_audit: |
| 18 | + required: false |
| 19 | + type: boolean |
| 20 | + default: false |
| 21 | + with_clippy: |
| 22 | + required: false |
| 23 | + type: boolean |
| 24 | + default: false |
| 25 | + with_doc: |
| 26 | + required: false |
| 27 | + type: boolean |
| 28 | + default: false |
| 29 | + pre_build_script: |
| 30 | + required: false |
| 31 | + type: string |
| 32 | + |
| 33 | +env: |
| 34 | + CARGO_TERM_COLOR: always |
| 35 | + |
| 36 | +jobs: |
| 37 | + |
| 38 | + build: |
| 39 | + |
| 40 | + name: Rust ${{ inputs.rust_toolchain }} ${{ inputs.rust_features }} |
| 41 | + |
| 42 | + runs-on: ubuntu-latest |
| 43 | + |
| 44 | + steps: |
| 45 | + |
| 46 | + - uses: actions/checkout@v4 |
| 47 | + |
| 48 | + - uses: dtolnay/rust-toolchain@master |
| 49 | + with: |
| 50 | + toolchain: ${{ inputs.rust_toolchain }} |
| 51 | + components: rustfmt, clippy |
| 52 | + |
| 53 | + - id: quickinstall |
| 54 | + name: Install cargo-quickinstall |
| 55 | + if: ${{ inputs.with_audit }} |
| 56 | + run: | |
| 57 | + cargo install cargo-quickinstall |
| 58 | +
|
| 59 | + - id: pre_build_script |
| 60 | + name: Pre build script |
| 61 | + if: ${{ inputs.pre_build_script }} |
| 62 | + run: ${{ inputs.pre_build_script }} |
| 63 | + |
| 64 | + - id: rustfmt |
| 65 | + name: Rust format |
| 66 | + if: ${{ inputs.with_rustfmt }} |
| 67 | + run: | |
| 68 | + cargo fmt --verbose --all -- --check |
| 69 | + echo "Rustfmt OK" >> "$GITHUB_STEP_SUMMARY" |
| 70 | +
|
| 71 | + - id: audit |
| 72 | + name: Audit |
| 73 | + if: ${{ inputs.with_audit }} |
| 74 | + run: | |
| 75 | + cargo quickinstall cargo-audit |
| 76 | + cargo audit |
| 77 | + echo "Audit OK" >> "$GITHUB_STEP_SUMMARY" |
| 78 | +
|
| 79 | + - id: clippy |
| 80 | + name: Clippy |
| 81 | + if: ${{ inputs.with_clippy }} |
| 82 | + run: | |
| 83 | + cargo clippy --all ${{ inputs.rust_features }} --all-targets -- -D warnings |
| 84 | + echo "Clippy OK" >> "$GITHUB_STEP_SUMMARY" |
| 85 | +
|
| 86 | + - id: test |
| 87 | + name: Compile and run tests |
| 88 | + run: cargo test ${{ inputs.rust_features }} --verbose |
| 89 | + |
| 90 | + - id: doc |
| 91 | + name: Doc |
| 92 | + if: ${{ inputs.with_doc }} |
| 93 | + run: | |
| 94 | + RUSTDOCFLAGS="-D warnings" cargo doc ${{ inputs.rust_features }} --no-deps |
| 95 | + echo "Doc OK" >> "$GITHUB_STEP_SUMMARY" |
| 96 | +
|
0 commit comments