Skip to content

Commit e3570e2

Browse files
committed
chore(ci): test against multiple platforms
1 parent 2da0d39 commit e3570e2

4 files changed

Lines changed: 107 additions & 26 deletions

File tree

.github/workflows/ci.yml

Lines changed: 53 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,67 @@
1-
name: CI Test
1+
name: CI
22

33
on:
44
push:
5-
paths: [ "src/**", "Cargo.toml"]
6-
workflow_dispatch: {}
5+
branches: ["main"]
6+
paths:
7+
- "src/**"
8+
- "Cargo.toml"
9+
- "Cargo.lock"
10+
- ".github/workflows/ci.yml"
11+
pull_request:
12+
paths:
13+
- "src/**"
14+
- "Cargo.toml"
15+
- "Cargo.lock"
16+
- ".github/workflows/ci.yml"
17+
merge_group:
18+
paths:
19+
- "src/**"
20+
- "Cargo.toml"
21+
- "Cargo.lock"
22+
- ".github/workflows/ci.yml"
23+
workflow_dispatch:
24+
25+
permissions:
26+
contents: read
727

828
env:
29+
RUSTFLAGS: -Dwarnings
30+
RUST_BACKTRACE: full
931
CARGO_TERM_COLOR: always
1032

1133
jobs:
1234
test:
13-
name: Build & Test
14-
runs-on: ubuntu-latest
35+
name: Test (Rust ${{matrix.toolchain}}, ${{matrix.os}}, target ${{matrix.target}})
36+
runs-on: ${{matrix.os}}
37+
strategy:
38+
fail-fast: false
39+
matrix:
40+
toolchain: ["nightly", "beta", "stable", "1.83.0"]
41+
os: [ubuntu-latest, windows-latest, macos-latest]
42+
include:
43+
- os: ubuntu-latest
44+
target: x86_64-unknown-linux-gnu
45+
- os: windows-latest
46+
target: x86_64-pc-windows-msvc
47+
- os: macos-latest
48+
target: aarch64-apple-darwin
49+
timeout-minutes: 45
1550
steps:
16-
- name: Checkout repository
17-
uses: actions/checkout@v4
51+
- uses: actions/checkout@v4
1852
with:
1953
persist-credentials: false
20-
- name: Read MSRV from Cargo.toml
21-
id: msrv
22-
run: |
23-
echo "MSRV=$(grep '^rust-version = ' Cargo.toml | cut -d'"' -f2)" >> $GITHUB_ENV
24-
- name: Setup Rust toolchain to MSRV
25-
uses: actions-rust-lang/setup-rust-toolchain@v1
54+
- uses: dtolnay/rust-toolchain@master
2655
with:
27-
toolchain: ${{ env.MSRV }}
28-
- name: Build
29-
run: cargo build --verbose
30-
# criterion breaks MSRV
31-
- name: Setup Rust toolchain to latest stable
32-
uses: actions-rust-lang/setup-rust-toolchain@v1
56+
toolchain: ${{matrix.toolchain}}
57+
components: llvm-tools, clippy, rust-src
58+
- uses: taiki-e/install-action@v2
3359
with:
34-
toolchain: stable
35-
- name: Test
36-
run: cargo test --verbose
37-
env:
38-
RUST_BACKTRACE: 1
60+
tool: just,cargo-llvm-cov,cargo-nextest
61+
- name: Enable type layout randomization
62+
if: matrix.toolchain == 'nightly'
63+
run: echo RUSTFLAGS=${RUSTFLAGS}\ -Zrandomize-layout >> $GITHUB_ENV
64+
- run: sudo apt-get update && sudo apt-get install -y musl-tools
65+
if: endsWith(matrix.target, 'musl')
66+
- run: rustup target add ${{matrix.target}}
67+
- run: just ci-test --target ${{matrix.target}}

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "proxy-protocol-codec"
3-
version = "0.3.0"
3+
version = "0.3.1"
44
edition = "2021"
55
rust-version = "1.83.0"
66

@@ -17,7 +17,7 @@ repository = "https://github.com/hanyu-dev/proxy-protocol-codec"
1717
crc32c = { version = "0.6.8", default-features = false, optional = true }
1818
slicur = { version = "0.3.0", optional = true }
1919
thiserror = { version = "2.0", optional = true }
20-
uni-addr = { version = "0.3.1", default-features = false, optional = true }
20+
uni-addr = { version = "0.3.4", default-features = false, optional = true }
2121
wrapper-lite = { version = "0.3.2", default-features = false }
2222

2323
[dev-dependencies]

Justfile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# just manual: https://github.com/casey/just#readme
2+
3+
_default:
4+
just --list
5+
6+
# Run all tests with nextest and cargo-llvm-cov
7+
ci-test *args:
8+
#!/bin/bash -eux
9+
cargo llvm-cov nextest {{args}} --locked --lcov --output-path coverage.lcov
10+
11+
# =========== LOCAL COMMANDS ===========
12+
13+
build *args:
14+
cargo build {{args}} --locked
15+
16+
b *args:
17+
just build {{args}}
18+
19+
# Show coverage locally
20+
cov *args:
21+
#!/bin/bash -eux
22+
cargo llvm-cov nextest {{args}} --locked --hide-instantiations --html --output-dir coverage
23+
24+
check *args:
25+
cargo check {{args}} --locked --all-features
26+
27+
c *args:
28+
just check {{args}}
29+
30+
clippy *args:
31+
cargo clippy {{args}} --locked --all-features -- -Dclippy::all -Dclippy::pedantic
32+
33+
example *args:
34+
cargo run --example {{args}}
35+
36+
e *args:
37+
just example {{args}}
38+
39+
msrv *args:
40+
cargo +1.83.0 clippy {{args}} --locked --all-features -- -Dclippy::all -Dclippy::pedantic
41+
42+
t *args:
43+
just test {{args}}
44+
45+
test *args:
46+
#!/bin/bash -eux
47+
export RUST_BACKTRACE=1
48+
cargo nextest run {{args}} --locked --all-features

src/v2/model.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ impl AddressPair {
216216
Self::Unix { src_addr, .. } => uni_addr::unix::SocketAddr::from_bytes_until_nul(src_addr)
217217
.map(Into::into)
218218
.map(Some),
219+
#[cfg(not(unix))]
220+
Self::Unix { .. } => Err(io::Error::other("The platform does not support UDS addresses.")),
219221
}
220222
}
221223

@@ -236,6 +238,8 @@ impl AddressPair {
236238
Self::Unix { dst_addr, .. } => uni_addr::unix::SocketAddr::from_bytes_until_nul(dst_addr)
237239
.map(Into::into)
238240
.map(Some),
241+
#[cfg(not(unix))]
242+
Self::Unix { .. } => Err(io::Error::other("The platform does not support UDS addresses.")),
239243
}
240244
}
241245
}

0 commit comments

Comments
 (0)