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
23 changes: 23 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,26 @@ updates:
applies-to: security-updates
patterns:
- "*"

- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
day: monday
time: "09:00"
timezone: Europe/Moscow
open-pull-requests-limit: 1
labels:
- dependencies
groups:
github-actions-major:
applies-to: version-updates
patterns:
- "*"
update-types:
- major
ignore:
- dependency-name: "*"
update-types:
- version-update:semver-minor
- version-update:semver-patch
102 changes: 93 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- '.github/workflows/build.yml'
- 'package.json'
- 'package-lock.json'
- 'rust-toolchain.toml'
- 'rust/**'
- 'scripts/**'
release:
Expand All @@ -23,12 +24,6 @@ jobs:
- host: macos-latest
target: aarch64-apple-darwin
build: npm run build:rust -- --target aarch64-apple-darwin
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
build: npm run build:rust -- --target x86_64-unknown-linux-gnu
- host: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
build: npm run build:rust -- --target aarch64-unknown-linux-gnu
- host: ubuntu-latest
target: x86_64-unknown-linux-musl
setup: |
Expand Down Expand Up @@ -58,19 +53,34 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: 20
node-version: 20.20.2
cache: npm

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.98.0
targets: ${{ matrix.settings.target }}

- name: Cache Rust builds
uses: Swatinem/rust-cache@v2
with:
workspaces: rust -> target
shared-key: ${{ matrix.settings.target }}

- name: Cache musl cross toolchain
if: matrix.settings.target == 'x86_64-unknown-linux-musl'
uses: actions/cache@v6
with:
path: ~/musl-cross
key: musl-cross-${{ runner.os }}-x86_64-11-20211120

- name: Install target toolchain dependencies
if: matrix.settings.setup != ''
run: ${{ matrix.settings.setup }}

- name: Install dependencies
run: npm install
run: npm ci --ignore-scripts

- name: Build native module
run: ${{ matrix.settings.build }}
Expand All @@ -82,10 +92,84 @@ jobs:
path: rust/*.node
if-no-files-found: error

build-linux-gnu:
strategy:
fail-fast: false
matrix:
settings:
- host: ubuntu-latest
image: quay.io/pypa/manylinux_2_28_x86_64@sha256:4dc41da7df20400310c80d162a2fe2d2c2f3d9734d8dec20f6b9843711618deb
node_arch: x64
target: x86_64-unknown-linux-gnu
binary: rust/node-wreq.linux-x64-gnu.node
- host: ubuntu-24.04-arm
image: quay.io/pypa/manylinux_2_28_aarch64@sha256:29a6ceb78de5b00494e6e7456a72782a4cb54238de102e7491d15fe47789b4d1
node_arch: arm64
target: aarch64-unknown-linux-gnu
binary: rust/node-wreq.linux-arm64-gnu.node

name: Build - ${{ matrix.settings.target }}
runs-on: ${{ matrix.settings.host }}
container:
image: ${{ matrix.settings.image }}
defaults:
run:
shell: bash

steps:
- name: Install container dependencies
run: dnf install -y --disablerepo=epel --setopt=install_weak_deps=False clang zstd

- uses: actions/checkout@v7

- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: 20.20.2
architecture: ${{ matrix.settings.node_arch }}
cache: npm

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.98.0
targets: ${{ matrix.settings.target }}

- name: Cache Rust builds
uses: Swatinem/rust-cache@v2
with:
workspaces: rust -> target
shared-key: manylinux-${{ matrix.settings.target }}

- name: Install dependencies
run: npm ci --ignore-scripts

- name: Build native module
env:
LIBCLANG_PATH: /usr/lib64
run: npm run build:rust -- --target "${{ matrix.settings.target }}"

- name: Verify and smoke test native module
run: |
if [ ! -f "${{ matrix.settings.binary }}" ]; then
echo "Native build produced no ${{ matrix.settings.binary }} binary" >&2
exit 1
fi

node ./scripts/verify-linux-binary.mjs "${{ matrix.settings.binary }}"
node ./scripts/smoke-native.mjs "${{ matrix.settings.binary }}"

- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: bindings-${{ matrix.settings.target }}
path: ${{ matrix.settings.binary }}
if-no-files-found: error

publish:
name: Publish platform package - ${{ matrix.settings.target }}
runs-on: ubuntu-latest
needs: build
needs: [build, build-linux-gnu]
if: github.event_name == 'release'
permissions:
contents: read
Expand Down
45 changes: 17 additions & 28 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- '.github/workflows/test.yml'
- 'package.json'
- 'package-lock.json'
- 'rust-toolchain.toml'
- 'tsconfig.json'
- 'src/**'
- 'rust/**'
Expand All @@ -15,6 +16,7 @@ on:
- '.github/workflows/test.yml'
- 'package.json'
- 'package-lock.json'
- 'rust-toolchain.toml'
- 'tsconfig.json'
- 'src/**'
- 'rust/**'
Expand Down Expand Up @@ -43,37 +45,17 @@ jobs:

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.98.0

- name: Cache Rust dependencies
uses: actions/cache@v6
- name: Cache Rust builds
uses: Swatinem/rust-cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
rust/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
workspaces: rust -> target
shared-key: test-${{ matrix.os }}

- name: Install dependencies
run: npm install

- name: Build Rust module
run: npm run build:rust

- name: Debug - List built files
shell: bash
run: |
echo "=== Files in rust/ ==="
ls -la rust/*.node || echo "No .node files in rust/"
echo ""
echo "=== Node platform info ==="
node -e "console.log('Platform:', process.platform, 'Arch:', process.arch)"

- name: Build TypeScript
run: npm run build:ts
run: npm ci --ignore-scripts

- name: Run tests
run: npm test
Expand All @@ -93,13 +75,20 @@ jobs:
cache: 'npm'

- name: Install dependencies
run: npm install
run: npm ci --ignore-scripts

- name: Install Rust linting components
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.98.0
components: rustfmt, clippy

- name: Cache Rust builds
uses: Swatinem/rust-cache@v2
with:
workspaces: rust -> target
shared-key: lint

- name: Check TypeScript types
run: npx tsc --noEmit

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wreq-upstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
body: |
Automated upstream bump for the Rust crates.

This workflow checks `crates.io` for the latest published `max_version` of:
This workflow checks `crates.io` for the latest published stable version of:
- `wreq`
- `wreq-util`
labels: |
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,6 @@ Useful redirect facts:
- `301` / `302` rewrite `POST` to `GET`
- `303` rewrites to `GET` unless current method is `HEAD`
- `307` / `308` preserve method and body
- `authorization` is stripped on cross-origin redirect

### simple retries

Expand Down Expand Up @@ -661,6 +660,7 @@ Main error classes:
- `TimeoutError`
- `AbortError`
- `WebSocketError`
- `ERR_DNS`

Typical patterns:

Expand Down Expand Up @@ -875,6 +875,7 @@ const client = createClient({
poolMaxIdlePerHost: 8,
poolMaxSize: 128,
tlsSessionCacheCapacity: 8,
tcpLinger: 5_000,
});

await client.get('/account', {
Expand All @@ -894,7 +895,8 @@ client.close();
```

Set `poolIdleTimeout: false` to disable idle expiry. `connectionGroup` accepts a string or a
non-negative integer.
non-negative integer. `tcpLinger` configures `SO_LINGER` in milliseconds; `0` requests an abortive
close with TCP `RST`, while omitting the option keeps the operating-system default.

### mTLS and custom CAs

Expand Down
Loading