diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2b2523d..4374a05 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,7 @@ jobs: build_and_test: strategy: + fail-fast: false matrix: os: - ubuntu-latest @@ -20,15 +21,55 @@ jobs: - beta - nightly runs-on: ${{ matrix.os }} + # Nightly breaking shouldn't block pull requests + continue-on-error: ${{ matrix.rust == 'nightly' }} steps: - run: git config --global core.autocrlf false - uses: actions/checkout@v4 + - name: Install Rust ${{ matrix.rust }} + run: | + rustup toolchain install ${{ matrix.rust }} --profile minimal + rustup default ${{ matrix.rust }} - name: Build run: cargo build --all --locked --verbose - name: Run tests run: cargo test --all --locked --verbose + + # The minimum supported Rust version, as declared by rust-version in Cargo.toml + msrv: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Install Rust 1.74 + run: rustup toolchain install 1.74 --profile minimal + - name: Pick the newest dependency versions that support Rust 1.74 + run: | + rm Cargo.lock + CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS=fallback cargo generate-lockfile + # Cargo before 1.78 can't read version 4 lockfiles (the format is otherwise the same) + sed -i 's/^version = 4$/version = 3/' Cargo.lock + grep -A1 'name = "encoding_rs"' Cargo.lock + - name: Build and run tests with Rust 1.74 + run: cargo +1.74 test --locked --verbose + + lint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Install Rust with rustfmt and clippy + run: | + rustup toolchain install stable --profile minimal --component rustfmt,clippy + rustup default stable - name: Check code formatting run: | - rustup component add rustfmt cargo fmt --all -- --check + rustfmt --edition 2021 --check fuzz/fuzz_targets/*.rs + - name: Run clippy + run: cargo clippy --all-targets --locked -- -D warnings + - name: Check documentation + run: cargo doc --no-deps --locked + env: + RUSTDOCFLAGS: -D warnings diff --git a/CHANGELOG.md b/CHANGELOG.md index d9d6cdc..7a20831 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,9 @@ ### Testing + - CI checks the minimum supported Rust version (1.74), with the newest dependency versions that support it + (encoding_rs 0.8.40 and newer need Rust 1.88), and runs clippy and rustdoc with warnings treated as errors; + the stable, beta and nightly builds now really use those toolchains (they all used stable before) - Randomized round-trip tests (`tests/roundtrip.rs`) and [cargo-fuzz](https://github.com/rust-fuzz/cargo-fuzz) targets (`fuzz/`), which share the same checks: parsing never panics, and anything that parses or gets set survives being serialized and parsed again, with every combination of encoding and escaping diff --git a/README.md b/README.md index 918a183..632f2d3 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,10 @@ assert_eq!(data_url.to_string(), "data:image/png;base64,iVBORw=="); Data is stored as raw bytes and serialized as-is; use `set_text()` to store text encoded in the data URL's charset, and `text()` to decode it. Disabling default features skips the `cli` feature, which only matters for `cargo install`. +The minimum supported Rust version is 1.74. Recent versions of encoding_rs (0.8.40 and newer) need Rust 1.88, +so on older toolchains, have Cargo pick dependency versions that match yours: +`CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS=fallback cargo update` (with Cargo 1.84 or newer). + ### Choosing how data gets encoded `set_data_encoding()` picks percent-encoding (the default), base64, or `DataEncoding::Shortest`, whichever comes out shorter for the data.