| name: Rust Build |
| on: |
| workflow_call: |
| jobs: |
| fmt: |
| runs-on: ubuntu-latest |
| name: code style check |
| steps: |
| - uses: actions/checkout@v3 |
| with: |
| submodules: true |
| - name: Install stable |
| uses: actions-rs/toolchain@v1 |
| with: |
| toolchain: stable |
| components: rustfmt |
| - name: Code format check |
| working-directory: ./rust |
| run: cargo fmt --check |
| clippy: |
| name: clippy |
| runs-on: ubuntu-latest |
| steps: |
| - uses: actions/checkout@v3 |
| with: |
| submodules: true |
| - name: Install stable |
| uses: actions-rs/toolchain@v1 |
| with: |
| toolchain: stable |
| components: clippy |
| # Run clippy |
| - name: clippy check |
| working-directory: ./rust |
| run: cargo clippy --all-features -- -D warnings |
| doc: |
| runs-on: ubuntu-latest |
| name: doc check |
| steps: |
| - uses: actions/checkout@v3 |
| with: |
| submodules: true |
| - name: Install stable |
| uses: actions-rs/toolchain@v1 |
| with: |
| toolchain: stable |
| - name: Build doc |
| working-directory: ./rust |
| run: cargo doc --no-deps --all-features |
| env: |
| RUSTDOCFLAGS: --cfg docsrs |
| msrv: |
| runs-on: ubuntu-latest |
| strategy: |
| matrix: |
| msrv: [1.61] |
| name: msrv ${{ matrix.msrv }} check |
| steps: |
| - uses: actions/checkout@v3 |
| with: |
| submodules: true |
| - name: Install ${{ matrix.msrv }} |
| uses: actions-rs/toolchain@v1 |
| with: |
| toolchain: ${{ matrix.msrv }} |
| - name: Check MSRV ${{ matrix.msrv }} |
| working-directory: ./rust |
| run: cp .cargo/Cargo.lock.min Cargo.lock && cargo +${{ matrix.msrv }} fetch && cargo +${{ matrix.msrv }} check --locked --frozen |
| build: |
| name: "${{ matrix.os }}" |
| runs-on: ${{ matrix.os }} |
| needs: [fmt, msrv] |
| defaults: |
| run: |
| working-directory: ./rust |
| strategy: |
| matrix: |
| os: [ubuntu-20.04, macos-11, windows-2022] |
| msrv: [1.61] |
| steps: |
| - uses: actions/checkout@v2 |
| with: |
| submodules: true |
| - uses: actions-rs/toolchain@v1 |
| with: |
| toolchain: ${{ matrix.msrv }} |
| components: clippy |
| - name: Install protoc |
| uses: arduino/setup-protoc@v1 |
| with: |
| version: "3.x" |
| repo-token: ${{ secrets.GITHUB_TOKEN }} |
| - name: Build |
| env: |
| BUILD_PROTO: true |
| run: rm src/pb/*.rs && cargo build |
| - name: Unit Test |
| run: cargo test -- --nocapture |