Skip to content

Commit

Permalink
Merge pull request #13 from nyurik/wip
Browse files Browse the repository at this point in the history
Incremental changes to fix this with macros
  • Loading branch information
gquintard authored Oct 7, 2024
2 parents 20aff2e + b7a9b48 commit 488dacb
Show file tree
Hide file tree
Showing 8 changed files with 850 additions and 779 deletions.
52 changes: 37 additions & 15 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,41 @@
name: Build
on: [push]

# FIXME: remove testing_gq from below

on:
push:
branches: [ main, testing_gq ]
pull_request:
branches: [ main, testing_gq ]
release:
types: [ published ]
workflow_dispatch:

jobs:
main:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false # 7.6 is not yet supported properly. Once fixed, this can be set to true
matrix:
include:
- setup: varnish74
- setup: varnish75
- setup: varnish76
env:
RUST_BACKTRACE: 1
RUSTDOCFLAGS: -D warnings
RUSTFLAGS: -D warnings
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- run: |
sudo apt-get install -y curl
curl -s https://packagecloud.io/install/repositories/varnishcache/varnish75/script.deb.sh | sudo bash
sudo apt-get install varnish-dev
- run: |
export RUST_BACKTRACE=1
cargo doc
cargo build
cargo test
- uses: taiki-e/install-action@v2
with: { tool: just }
- uses: actions/checkout@v4
- name: Ensure this crate has not yet been published (on release)
if: github.event_name == 'release'
run: just check-if-published
- uses: Swatinem/rust-cache@v2
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
- name: install varnish-dev
run: |
curl -s https://packagecloud.io/install/repositories/varnishcache/${{ matrix.setup }}/script.deb.sh | sudo bash
sudo apt-get install -y varnish-dev
- run: just -v ci-test
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 9 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,22 @@ name = "vmod_reqwest"
version = "0.0.12"
edition = "2021"
license = "BSD-3-Clause"
authors = [ "Guillaume Quintard [email protected]" ]

[build-dependencies]
varnish = { git = "https://github.com/gquintard/varnish-rs.git", branch = "proc-macro-cleanup-gq"}
authors = ["Guillaume Quintard [email protected]"]

[dependencies]
varnish = { git = "https://github.com/gquintard/varnish-rs.git", branch = "proc-macro-cleanup-gq"}
varnish-sys = { git = "https://github.com/gquintard/varnish-rs.git", branch = "proc-macro-cleanup-gq"}
varnish-macros = { git = "https://github.com/gquintard/varnish-rs.git", branch = "proc-macro-cleanup-gq" }
regex = "1.5"
lru = "0.7.1"
anyhow = "1.0"
bytes = "1.1.0"
reqwest = { version = "0.11", features = ["stream", "deflate", "gzip", "brotli", "native-tls"] }
tokio = { version = "1", features = ["full"] }
futures = "0.3"
futures-util = "0.3"
hyper = "0.14.16"
anyhow = "1.0"
lru = "0.7.1"
regex = "1.5"
reqwest = { version = "0.11", features = ["stream", "deflate", "gzip", "brotli", "native-tls"] }
serde_json = "1"
tokio = { version = "1", features = ["full"] }
varnish = { git = "https://github.com/gquintard/varnish-rs.git", branch = "feature-macro"}
varnish-macros = { git = "https://github.com/gquintard/varnish-rs.git", branch = "feature-macro" }
varnish-sys = { git = "https://github.com/gquintard/varnish-rs.git", branch = "feature-macro"}

[lib]
crate-type = ["cdylib"]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import reqwest from "path/to/libreqwest.so";
```vcl
// Create a new instance of the object in your VCL init function
sub vcl_init {
new new = client.new([STRING base_url], [BOOL https], [INT follow], [DURATION timeout], [DURATION connect_timeout], [BOOL auto_gzip], [BOOL auto_deflate], [BOOL auto_brotli], [BOOL accept_invalid_certs], [BOOL accept_invalid_hostnames], [STRING http_proxy], [STRING https_proxy]);
new new = client.new([STRING base_url], [BOOL https], INT follow = 10, [DURATION timeout], [DURATION connect_timeout], BOOL auto_gzip = 1, BOOL auto_deflate = 1, BOOL auto_brotli = 1, BOOL accept_invalid_certs = 0, BOOL accept_invalid_hostnames = 0, [STRING http_proxy], [STRING https_proxy], [PROBE probe]);
}
```

#### Method `VOID init(STRING name, STRING url, [STRING method])`
#### Method `VOID init(STRING name, STRING url, STRING method = "GET")`

#### Method `VOID send(STRING name)`

Expand Down
26 changes: 0 additions & 26 deletions build.sh

This file was deleted.

69 changes: 69 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env just --justfile

@_default:
just --list --unsorted

# Clean all build artifacts
clean:
cargo clean
rm -f Cargo.lock

# Update dependencies, including breaking changes
update:
cargo +nightly -Z unstable-options update --breaking
cargo update

# Run cargo clippy
clippy:
cargo clippy --workspace --all-targets -- -D warnings

# Test code formatting
test-fmt:
cargo fmt --all -- --check

# Run cargo fmt
fmt:
cargo +nightly fmt -- --config imports_granularity=Module,group_imports=StdExternalCrate

# Build and open code documentation
docs:
cargo doc --no-deps --open

# Quick compile
check:
cargo check --workspace --all-targets

# Default build
build:
cargo build --workspace --all-targets

# Run all tests
test: build
cargo test --workspace --all-targets

# Test documentation
test-doc:
cargo doc --no-deps

rust-info:
rustc --version
cargo --version

# Run all tests as expected by CI
ci-test: rust-info test-fmt clippy test test-doc

# Verify that the current version of the crate is not the same as the one published on crates.io
check-if-published:
#!/usr/bin/env bash
LOCAL_VERSION="$(grep '^version =' Cargo.toml | sed -E 's/version = "([^"]*)".*/\1/')"
echo "Detected crate version: $LOCAL_VERSION"
CRATE_NAME="$(grep '^name =' Cargo.toml | head -1 | sed -E 's/name = "(.*)"/\1/')"
echo "Detected crate name: $CRATE_NAME"
PUBLISHED_VERSION="$(cargo search ${CRATE_NAME} | grep "^${CRATE_NAME} =" | sed -E 's/.* = "(.*)".*/\1/')"
echo "Published crate version: $PUBLISHED_VERSION"
if [ "$LOCAL_VERSION" = "$PUBLISHED_VERSION" ]; then
echo "ERROR: The current crate version has already been published."
exit 1
else
echo "The current crate version has not yet been published."
fi
Loading

0 comments on commit 488dacb

Please sign in to comment.