|
| 1 | +name: Samples Rust Clients |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths: |
| 6 | + - "samples/client/others/rust/**" |
| 7 | + - "samples/client/petstore/rust-server/**" |
| 8 | + pull_request: |
| 9 | + paths: |
| 10 | + - "samples/client/others/rust/**" |
| 11 | + - "samples/client/petstore/rust/**" |
| 12 | + |
| 13 | +jobs: |
| 14 | + build: |
| 15 | + name: Build Rust |
| 16 | + runs-on: ubuntu-latest |
| 17 | + strategy: |
| 18 | + fail-fast: false |
| 19 | + matrix: |
| 20 | + sample: |
| 21 | + # these folders contain sub-projects of rust clients, servers |
| 22 | + - samples/client/others/rust/ |
| 23 | + - samples/client/petstore/rust/ |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v5 |
| 26 | + - uses: actions-rs/toolchain@v1 |
| 27 | + with: |
| 28 | + toolchain: stable |
| 29 | + |
| 30 | + - name: Rust cache |
| 31 | + uses: Swatinem/rust-cache@v2 |
| 32 | + with: |
| 33 | + cache-targets: false # Don't cache workspace target directories as they don't exist |
| 34 | + cache-directories: |
| 35 | + ${{ matrix.sample }}/target |
| 36 | + workspaces: | |
| 37 | + ${{ matrix.sample }}/output/* |
| 38 | +
|
| 39 | + - name: Build |
| 40 | + working-directory: ${{ matrix.sample }} |
| 41 | + run: cargo build --all-targets --all-features |
| 42 | + - name: Tests |
| 43 | + working-directory: ${{ matrix.sample }} |
| 44 | + run: | |
| 45 | + set -e |
| 46 | +
|
| 47 | + # Iterate through each example and test various features |
| 48 | + for package in $(find . -maxdepth 1 -mindepth 1 -type d) |
| 49 | + do |
| 50 | + # Not all versions have a client example |
| 51 | + if test -f examples/client/main.rs; then |
| 52 | + cargo build --example client --features="client" |
| 53 | + fi |
| 54 | +
|
| 55 | + # Test the CLI works if present |
| 56 | + if test -f bin/cli.rs; then |
| 57 | + cargo build --bin ${package##*/} --features cli |
| 58 | + target/debug/${package##*/} --help |
| 59 | + fi |
| 60 | + cargo fmt |
| 61 | + cargo test |
| 62 | + cargo clippy |
| 63 | + cargo doc |
| 64 | + done |
0 commit comments