Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
155 changes: 155 additions & 0 deletions .github/workflows/checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
name: Checker

on:
pull_request:
branches:
- main
types:
- opened
- reopened
- synchronize
workflow_dispatch:

permissions:
contents: read

jobs:
compliance-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Validate compliance matrix/index drift
run: python3 tools/check_compliance_docs.py

fmt:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Install stable
run: rustup toolchain install stable --profile minimal --component rustfmt

- name: Check formatting
run: cargo +stable fmt --all -- --check

clippy-http:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Install stable
run: rustup toolchain install stable --profile minimal --component clippy

- name: Lint HTTP-only build
run: cargo +stable clippy --workspace --all-targets --no-default-features --features http -- -D warnings

clippy-all-features:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Install OpenSSL headers
run: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config

- name: Install stable
run: rustup toolchain install stable --profile minimal --component clippy

- name: Lint all features
run: cargo +stable clippy --workspace --all-targets --all-features -- -D warnings

test-http:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
toolchain:
- "1.71.0"
- stable
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Install Rust
run: rustup toolchain install ${{ matrix.toolchain }} --profile minimal

- name: Resolve HTTP-only dependency graph
run: |
rm -f Cargo.lock
cargo +${{ matrix.toolchain }} test --workspace --no-default-features --features http --no-run

- name: Test HTTP-only build with locked dependencies
run: cargo +${{ matrix.toolchain }} test --workspace --no-default-features --features http --locked

test-all-features:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
toolchain:
- "1.71.0"
- stable
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Install OpenSSL headers
run: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config

- name: Install Rust
run: rustup toolchain install ${{ matrix.toolchain }} --profile minimal

- name: Resolve all-features dependency graph
run: |
rm -f Cargo.lock
cargo +${{ matrix.toolchain }} test --workspace --all-features --no-run

- name: Test all features with locked dependencies
run: cargo +${{ matrix.toolchain }} test --workspace --all-features --locked

coverage-http:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Install stable
run: rustup toolchain install stable --profile minimal

- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov

- name: Enforce HTTP-only 100% line coverage
run: |
cargo llvm-cov clean --workspace
cargo llvm-cov --workspace --no-default-features --features http \
--lcov \
--output-path /tmp/http_cov.info
python3 tools/check_line_coverage.py --lcov /tmp/http_cov.info --root . --require 95

coverage-all-features:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Install OpenSSL headers
run: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config

- name: Install stable
run: rustup toolchain install stable --profile minimal

- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov

- name: Enforce all-features 100% line coverage
run: |
cargo llvm-cov clean --workspace
cargo llvm-cov --workspace --all-features \
--lcov \
--output-path /tmp/all_cov.info
python3 tools/check_line_coverage.py --lcov /tmp/all_cov.info --root . --require 95
60 changes: 60 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Publish

on:
release:
types:
- published

permissions:
contents: read

jobs:
publish:
if: github.event.release.target_commitish == 'main'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Fetch main
run: git fetch origin main

- name: Verify release commit is on main
run: git merge-base --is-ancestor "$GITHUB_SHA" origin/main

- name: Verify release tag matches Cargo version
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
python3 - <<'PY'
import os
import tomllib
from pathlib import Path

cargo = tomllib.loads(Path("Cargo.toml").read_text())
expected = f"v{cargo['package']['version']}"
actual = os.environ["RELEASE_TAG"]
if actual != expected:
raise SystemExit(f"release tag {actual!r} does not match Cargo.toml version {expected!r}")
PY

- name: Install OpenSSL headers
run: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config

- name: Install stable
run: rustup toolchain install stable --profile minimal

- name: Resolve publish dependency graph
run: |
rm -f Cargo.lock
cargo +stable test --workspace --all-features --no-run

- name: Verify tests
run: cargo +stable test --workspace --all-features --locked

- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo +stable publish --locked --token "$CARGO_REGISTRY_TOKEN"
46 changes: 0 additions & 46 deletions .github/workflows/rust.yml

This file was deleted.

57 changes: 52 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[package]
name = "nano-get"
description = """
A very tiny implementation of HTTP(s) GET, using minimal dependencies.
A tiny HTTP/1.1 GET and HEAD client with zero dependencies by default.
"""
version = "0.2.4"
version = "0.3.0"
authors = ["Rahul Thomas <rapidclock@users.noreply.github.com>"]
edition = "2018"
edition = "2021"
rust-version = "1.71"
license = "MIT"
repository = "https://github.com/rapidclock/nano-get"
documentation = "https://docs.rs/nano-get"
Expand All @@ -23,9 +24,55 @@ readme = "README.md"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
openssl = { version = "0.10.29", optional = true }
openssl = { version = "0.10.75", optional = true }

[features]
http = []
https = ["openssl"]
default = ["http"]
default = ["http"]

[[example]]
name = "simple-get"
path = "examples/simple-get/main.rs"

[[example]]
name = "get-bytes"
path = "examples/get-bytes/main.rs"

[[example]]
name = "head-request"
path = "examples/head-request/main.rs"

[[example]]
name = "request-builder"
path = "examples/request-builder/main.rs"

[[example]]
name = "protocol-specific-helpers"
path = "examples/protocol-specific-helpers/main.rs"
required-features = ["https"]

[[example]]
name = "session-reuse-and-pipelining"
path = "examples/session-reuse-and-pipelining/main.rs"

[[example]]
name = "memory-cache"
path = "examples/memory-cache/main.rs"

[[example]]
name = "basic-auth"
path = "examples/basic-auth/main.rs"

[[example]]
name = "custom-auth-handler"
path = "examples/custom-auth-handler/main.rs"

[[example]]
name = "proxy-and-proxy-auth"
path = "examples/proxy-and-proxy-auth/main.rs"

[[example]]
name = "advanced-client"
path = "examples/advanced-client/main.rs"
required-features = ["https"]
Loading