diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6094065..855708c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,9 +6,14 @@ on: pull_request: branches: [main] +# Cancel in-progress runs for the same branch/PR +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + jobs: # --------------------------------------------------------------------------- - # Lint (Python + Rust) + # Lint (Python + Rust) — fast, no compilation # --------------------------------------------------------------------------- lint: runs-on: ubuntu-latest @@ -25,6 +30,11 @@ jobs: with: components: clippy, rustfmt + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + with: + shared-key: lint + - name: Rust fmt check run: cargo fmt --check @@ -38,15 +48,24 @@ jobs: ruff format --check python/ # --------------------------------------------------------------------------- - # Test across Python versions + # Test — reduced matrix (ubuntu + latest Python is the core gate) # --------------------------------------------------------------------------- test: runs-on: ${{ matrix.os }} strategy: - fail-fast: false + fail-fast: true matrix: - os: [ubuntu-latest, macos-14, windows-latest] - python-version: ["3.10", "3.11", "3.12", "3.13"] + include: + # Core: Linux with min and max Python + - os: ubuntu-latest + python-version: "3.10" + - os: ubuntu-latest + python-version: "3.13" + # Spot-check other OS with one Python version + - os: macos-14 + python-version: "3.12" + - os: windows-latest + python-version: "3.12" steps: - uses: actions/checkout@v4 @@ -58,6 +77,11 @@ jobs: - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + with: + shared-key: test-${{ matrix.os }} + - name: Install package and test deps run: | python -m pip install --upgrade pip diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 29d45de..c851b7d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -7,6 +7,11 @@ on: paths: - "pyproject.toml" +# Cancel in-progress runs for the same branch +concurrency: + group: publish-${{ github.ref }} + cancel-in-progress: true + jobs: # --------------------------------------------------------------------------- # 1. Check if the version actually changed @@ -51,28 +56,29 @@ jobs: fi # --------------------------------------------------------------------------- - # 2. Run tests before building wheels + # 2. Quick smoke test (single Python, Linux only — full matrix done in CI) # --------------------------------------------------------------------------- test: needs: check-version if: needs.check-version.outputs.version_changed == 'true' runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - python-version: ["3.10", "3.11", "3.12", "3.13"] steps: - name: Checkout code uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} + - name: Set up Python uses: actions/setup-python@v5 with: - python-version: ${{ matrix.python-version }} + python-version: "3.12" - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + with: + shared-key: publish-test + - name: Install package and test deps run: | python -m pip install --upgrade pip @@ -82,7 +88,7 @@ jobs: run: python -m pytest -v --tb=short # --------------------------------------------------------------------------- - # 3. Build native wheels for all platforms + # 3. Build native wheels for all platforms (parallel with sdist) # --------------------------------------------------------------------------- build-wheels: needs: [check-version, test] @@ -122,12 +128,16 @@ jobs: target: ${{ matrix.target }} args: --release --out dist --interpreter 3.10 3.11 3.12 3.13 manylinux: ${{ matrix.manylinux }} + rust-toolchain: stable + sccache: "true" before-script-linux: | - # Ensure Perl is available for vendored OpenSSL build (openssl-src) + # Install OpenSSL dev headers (for native-tls) and Perl (for openssl-src fallback) if command -v yum &> /dev/null; then - yum install -y perl-IPC-Cmd perl-core + yum install -y openssl-devel perl-IPC-Cmd perl-core elif command -v apk &> /dev/null; then - apk add --no-cache perl make + apk add --no-cache openssl-dev perl make + elif command -v apt-get &> /dev/null; then + apt-get update && apt-get install -y libssl-dev pkg-config perl fi - name: Upload wheels @@ -137,7 +147,7 @@ jobs: path: dist/*.whl # --------------------------------------------------------------------------- - # 4. Build sdist (source distribution) + # 4. Build sdist (source distribution) — runs parallel with wheels # --------------------------------------------------------------------------- build-sdist: needs: [check-version, test] diff --git a/Cargo.lock b/Cargo.lock index e68ca30..5be8d92 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -108,6 +108,22 @@ dependencies = [ "url", ] +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + [[package]] name = "crc32fast" version = "1.5.0" @@ -207,6 +223,22 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + [[package]] name = "find-msvc-tools" version = "0.1.9" @@ -223,6 +255,21 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.2.2" @@ -285,7 +332,7 @@ dependencies = [ [[package]] name = "googer" -version = "0.2.5" +version = "0.2.7" dependencies = [ "html-escape", "log", @@ -468,6 +515,12 @@ version = "0.2.183" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d" +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + [[package]] name = "litemap" version = "0.8.1" @@ -551,6 +604,23 @@ dependencies = [ "simd-adler32", ] +[[package]] +name = "native-tls" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "465500e14ea162429d264d44189adc38b199b62b1c21eea9f69e4b73cb03bbf2" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "new_debug_unreachable" version = "1.0.6" @@ -569,6 +639,50 @@ version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" +[[package]] +name = "openssl" +version = "0.10.76" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "951c002c75e16ea2c65b8c7e4d3d51d5530d8dfa7d060b4776828c88cfb18ecf" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" + +[[package]] +name = "openssl-sys" +version = "0.9.112" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57d55af3b3e226502be1526dfdba67ab0e9c96fc293004e79576b2b9edb0dbdb" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "parking_lot" version = "0.12.5" @@ -650,6 +764,12 @@ dependencies = [ "siphasher", ] +[[package]] +name = "pkg-config" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + [[package]] name = "portable-atomic" version = "1.13.1" @@ -853,60 +973,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" [[package]] -name = "ring" -version = "0.17.14" +name = "rustix" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" dependencies = [ - "cc", - "cfg-if", - "getrandom 0.2.17", + "bitflags", + "errno", "libc", - "untrusted", - "windows-sys", -] - -[[package]] -name = "rustls" -version = "0.23.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "758025cb5fccfd3bc2fd74708fd4682be41d99e5dff73c377c0646c6012c73a4" -dependencies = [ - "log", - "once_cell", - "ring", - "rustls-pki-types", - "rustls-webpki", - "subtle", - "zeroize", + "linux-raw-sys", + "windows-sys 0.52.0", ] [[package]] -name = "rustls-pki-types" -version = "1.14.0" +name = "rustversion" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be040f8b0a225e40375822a563fa9524378b9d63112f53e19ffff34df5d33fdd" -dependencies = [ - "zeroize", -] +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" [[package]] -name = "rustls-webpki" -version = "0.103.9" +name = "schannel" +version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7df23109aa6c1567d1c575b9952556388da57401e4ace1d15f79eedad0d8f53" +checksum = "91c1b7e4904c873ef0710c1f407dde2e6287de2bebc1bbbf7d430bb7cbffd939" dependencies = [ - "ring", - "rustls-pki-types", - "untrusted", + "windows-sys 0.61.2", ] -[[package]] -name = "rustversion" -version = "1.0.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" - [[package]] name = "scopeguard" version = "1.2.0" @@ -929,6 +1022,29 @@ dependencies = [ "tendril", ] +[[package]] +name = "security-framework" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "selectors" version = "0.26.0" @@ -1066,12 +1182,6 @@ dependencies = [ "quote", ] -[[package]] -name = "subtle" -version = "2.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" - [[package]] name = "syn" version = "2.0.117" @@ -1100,6 +1210,19 @@ version = "0.12.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand", + "getrandom 0.3.4", + "once_cell", + "rustix", + "windows-sys 0.52.0", +] + [[package]] name = "tendril" version = "0.4.3" @@ -1214,12 +1337,6 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3" -[[package]] -name = "untrusted" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" - [[package]] name = "ureq" version = "2.12.1" @@ -1231,12 +1348,10 @@ dependencies = [ "cookie_store", "flate2", "log", + "native-tls", "once_cell", - "rustls", - "rustls-pki-types", "socks", "url", - "webpki-roots 0.26.11", ] [[package]] @@ -1275,6 +1390,12 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version_check" version = "0.9.5" @@ -1296,24 +1417,6 @@ dependencies = [ "wit-bindgen", ] -[[package]] -name = "webpki-roots" -version = "0.26.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9" -dependencies = [ - "webpki-roots 1.0.6", -] - -[[package]] -name = "webpki-roots" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22cfaf3c063993ff62e73cb4311efde4db1efb31ab78a3e5c457939ad5cc0bed" -dependencies = [ - "rustls-pki-types", -] - [[package]] name = "winapi" version = "0.3.9" @@ -1351,6 +1454,15 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + [[package]] name = "windows-targets" version = "0.52.6" @@ -1491,12 +1603,6 @@ dependencies = [ "synstructure", ] -[[package]] -name = "zeroize" -version = "1.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" - [[package]] name = "zerotrie" version = "0.2.3" diff --git a/Cargo.toml b/Cargo.toml index 95fe40d..113667b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "googer" -version = "0.2.6" +version = "0.2.7" edition = "2021" description = "A powerful, type-safe Google Search library for Python — powered by Rust." license = "Apache-2.0" @@ -11,7 +11,7 @@ crate-type = ["cdylib"] [dependencies] pyo3 = { version = "0.23", features = ["extension-module"] } -ureq = { version = "2", features = ["cookies", "socks-proxy"] } +ureq = { version = "2", default-features = false, features = ["cookies", "socks-proxy", "native-tls", "gzip"] } scraper = "0.21" rand = "0.8" regex = "1" diff --git a/pyproject.toml b/pyproject.toml index fdc2ed8..6d68abc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "maturin" [project] name = "googer" -version = "0.2.6" +version = "0.2.7" description = "A powerful, type-safe Google Search library for Python — powered by Rust." readme = "README.md" requires-python = ">=3.10"