Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
build_and_test:

strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
Expand All @@ -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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading