| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- name: CI
- on:
- push:
- branches: ["main"]
- pull_request:
- merge_group:
- types: [checks_requested]
- env:
- CARGO_NET_GIT_FETCH_WITH_CLI: true
- jobs:
- Test:
- strategy:
- matrix:
- os: [ubuntu-latest, macos-latest, windows-latest]
- rust: [1.63.0, 1.82.0, stable, beta, nightly]
- exclude:
- - os: macos-latest
- rust: 1.82.0
- - os: windows-latest
- rust: 1.82.0
- - os: macos-latest
- rust: beta
- - os: windows-latest
- rust: beta
- runs-on: ${{ matrix.os }}
- steps:
- - uses: actions/checkout@v4
- - uses: dtolnay/rust-toolchain@master
- with:
- toolchain: ${{ matrix.rust }}
- components: ${{ matrix.rust == 'nightly' && 'rust-src' || '' }}
- # Add toolchain for no_std tests
- - run: rustup toolchain install nightly
- - name: Downgrade deps on Rust 1.63.0
- if: |
- matrix.rust == '1.63.0'
- run: |
- # cargo update -p idna_adapter --precise 1.1.0
- # cargo update -p getopts --precise 0.2.22
- # cargo update -p unicode-width --precise 0.1.12
- # cargo update syn@2 --precise 2.0.100
- # Unfortunately `syn@2` syntax doesn't work on 1.63, and we don't know the precise
- # version beforehand. So we copy the lockfile we have already prepared.
- cp ci-lockfiles/1.63.Cargo.lock Cargo.lock
- # Older Unicode versions have a different test file
- cp idna/tests/IdnaTestV2-Unicode16.txt idna/tests/IdnaTestV2.txt
- - name: Downgrade deps on Rust 1.82.0
- if: |
- matrix.rust == '1.82.0'
- run: |
- cargo update -p icu_normalizer --precise 2.0.1
- cargo update -p icu_provider --precise 2.0.0
- cargo update -p icu_locale_core --precise 2.0.1
- # Older Unicode versions have a different test file
- cp idna/tests/IdnaTestV2-Unicode16.txt idna/tests/IdnaTestV2.txt
- - name: Add `aarch64-unknown-none` toolchain for `no_std` tests
- if: |
- matrix.os == 'ubuntu-latest' &&
- matrix.rust == 'nightly'
- run: rustup target add aarch64-unknown-none && rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu
- - run: cargo build --all-targets
- # Run tests
- - name: Run tests
- run: cargo test
- # Run tests enabling the serde feature
- - name: Run tests with the serde feature
- run: cargo test --features "url/serde,url/expose_internals"
- # The #[debugger_visualizer] attribute is currently gated behind a feature flag until #[debugger_visualizer]
- # is available in all rustc versions past our MSRV. As such, we only run the tests on newer rustc versions.
- - name: Run debugger_visualizer tests
- if: |
- matrix.os == 'windows-latest' &&
- matrix.rust != '1.63.0' &&
- matrix.rust != '1.82.0'
- run: cargo test --test debugger_visualizer --features "url/debugger_visualizer,url_debug_tests/debugger_visualizer" -- --test-threads=1 || echo "debugger test failed"
- continue-on-error: true # Fails on GH actions, but not locally.
- - name: Test `no_std` support
- run: cargo test --no-default-features --features=alloc
- - name: Build `url` crate for `aarch64-unknown-none` with `no_std`
- if: |
- matrix.os == 'ubuntu-latest' &&
- matrix.rust == 'nightly'
- run: >
- cd url
- && cargo check --target aarch64-unknown-none -v --no-default-features
- - name: Run tests with sanitizers
- if: (matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest') && matrix.rust == 'nightly'
- env:
- ASAN_OPTIONS: detect_leaks=1:detect_stack_use_after_return=1
- run: |
- if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
- sudo apt-get install -y --no-install-recommends llvm
- TARGET="x86_64-unknown-linux-gnu"
- SANITIZERS="address thread leak memory"
- elif [ "${{ matrix.os }}" = "macos-latest" ]; then
- TARGET="aarch64-apple-darwin"
- # no memory and leak sanitizer support yet
- SANITIZERS="address thread"
- # Suppress non-crate leaks on macOS. TODO: Check occasionally if these are still needed.
- {
- echo "leak:dyld4::RuntimeState"
- echo "leak:fetchInitializingClassList"
- echo "leak:std::sys::pal::unix::stack_overflow::imp::init"
- echo "leak:dyld::ThreadLocalVariables::instantiateVariable"
- echo "leak:_tlv_get_addr"
- } > suppressions.txt
- export LSAN_OPTIONS="suppressions=$(pwd)/suppressions.txt"
- fi
- for sanitizer in $SANITIZERS; do
- echo "Running tests with $sanitizer sanitizer..."
- export RUSTFLAGS="-Z sanitizer=$sanitizer"
- export RUSTDOCFLAGS="$RUSTFLAGS"
- cargo +nightly test -Z build-std --target "$TARGET" --lib --tests
- done
- WASM:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
- - uses: dtolnay/rust-toolchain@stable
- with:
- targets: wasm32-unknown-unknown
- - name: Install wasm-pack
- run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- - run: cargo build --target wasm32-unknown-unknown
- - run: cd url && wasm-pack test --headless --chrome
- - run: cd url && wasm-pack test --headless --firefox
- Lint:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
- - uses: dtolnay/rust-toolchain@stable
- with:
- components: rustfmt, clippy
- - run: cargo fmt --all --check
- - run: cargo clippy --workspace --all-targets -- -D warnings
- if: always()
- Audit:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
- - uses: EmbarkStudios/cargo-deny-action@v2
- Result:
- name: Result
- runs-on: ubuntu-latest
- needs:
- - "Test"
- - "WASM"
- - "Lint"
- - "Audit"
- steps:
- - name: Mark the job as successful
- run: exit 0
- if: success()
- - name: Mark the job as unsuccessful
- run: exit 1
- if: "!success()"
|