diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index aca5e03..3ee303a 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -1,18 +1,39 @@ name: Build -on: [push] + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + 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: | - 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 diff --git a/Cargo.lock b/Cargo.lock index 2fcf8b8..914fdbb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,21 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + [[package]] name = "android_system_properties" version = "0.1.5" @@ -13,22 +28,20 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.1.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "bindgen" -version = "0.69.4" +version = "0.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" +checksum = "f49d8fed880d473ea71efb9bf597651e77201bdd4893efe54c9e5d65ae04ce6f" dependencies = [ "bitflags", "cexpr", "clang-sys", "itertools", - "lazy_static", - "lazycell", "log", "prettyplease", "proc-macro2", @@ -36,27 +49,38 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.57", - "which", + "syn", ] [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] [[package]] name = "bumpalo" -version = "3.12.0" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "cc" -version = "1.0.79" +version = "1.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "812acba72f0a070b003d3697490d2b55b837230ae7c6c6497f05cc2ddbb8d938" +dependencies = [ + "shlex", +] [[package]] name = "cexpr" @@ -75,24 +99,23 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.24" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ + "android-tzdata", "iana-time-zone", "js-sys", - "num-integer", "num-traits", - "time", "wasm-bindgen", - "winapi", + "windows-targets", ] [[package]] name = "clang-sys" -version = "1.6.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ed9a53e5d4d9c573ae844bfac6872b159cb1d1585a83b29e7a64b7eef7332a" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" dependencies = [ "glob", "libc", @@ -100,70 +123,96 @@ dependencies = [ ] [[package]] -name = "codespan-reporting" -version = "0.11.1" +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "cpufeatures" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ - "termcolor", - "unicode-width", + "libc", ] [[package]] -name = "core-foundation-sys" -version = "0.8.3" +name = "crypto-common" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] [[package]] -name = "cxx" -version = "1.0.93" +name = "darling" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c00419335c41018365ddf7e4d5f1c12ee3659ddcf3e01974650ba1de73d038" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" dependencies = [ - "cc", - "cxxbridge-flags", - "cxxbridge-macro", - "link-cplusplus", + "darling_core", + "darling_macro", ] [[package]] -name = "cxx-build" -version = "1.0.93" +name = "darling_core" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb8307ad413a98fff033c8545ecf133e3257747b3bae935e7602aab8aa92d4ca" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" dependencies = [ - "cc", - "codespan-reporting", - "once_cell", + "fnv", + "ident_case", "proc-macro2", "quote", - "scratch", - "syn 2.0.57", + "strsim", + "syn", ] [[package]] -name = "cxxbridge-flags" -version = "1.0.93" +name = "darling_macro" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edc52e2eb08915cb12596d29d55f0b5384f00d697a646dbd269b6ecb0fbd9d31" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" +dependencies = [ + "darling_core", + "quote", + "syn", +] [[package]] -name = "cxxbridge-macro" -version = "1.0.93" +name = "digest" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "631569015d0d8d54e6c241733f944042623ab6df7bc3be7466874b05fcdb1c5f" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.57", + "block-buffer", + "crypto-common", ] [[package]] name = "either" -version = "1.8.1" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] [[package]] name = "glob" @@ -173,97 +222,84 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "iana-time-zone" -version = "0.1.53" +version = "0.1.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "winapi", + "windows-core", ] [[package]] name = "iana-time-zone-haiku" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" dependencies = [ - "cxx", - "cxx-build", + "cc", ] [[package]] -name = "itertools" -version = "0.12.1" +name = "ident_case" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" -dependencies = [ - "either", -] +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] -name = "js-sys" -version = "0.3.61" +name = "itertools" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" dependencies = [ - "wasm-bindgen", + "either", ] [[package]] -name = "lazy_static" -version = "1.4.0" +name = "itoa" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] -name = "lazycell" -version = "1.3.0" +name = "js-sys" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" +checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +dependencies = [ + "wasm-bindgen", +] [[package]] name = "libc" -version = "0.2.140" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "libloading" -version = "0.7.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" +checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" dependencies = [ "cfg-if", - "winapi", -] - -[[package]] -name = "link-cplusplus" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" -dependencies = [ - "cc", + "windows-targets", ] [[package]] name = "log" -version = "0.4.17" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "memchr" -version = "2.5.0" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "minimal-lexical" @@ -282,78 +318,91 @@ dependencies = [ ] [[package]] -name = "num-integer" -version = "0.1.45" +name = "num-traits" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", - "num-traits", ] [[package]] -name = "num-traits" -version = "0.2.15" +name = "once_cell" +version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "82881c4be219ab5faaf2ad5e5e5ecdff8c66bd7402ca3160975c93b24961afd1" dependencies = [ - "autocfg", + "portable-atomic", ] [[package]] -name = "once_cell" -version = "1.17.1" +name = "pkg-config" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] -name = "pkg-config" -version = "0.3.26" +name = "portable-atomic" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" +checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" [[package]] name = "prettyplease" -version = "0.2.17" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3928fb5db768cb86f891ff014f0144589297e3c6a1aba6ed7cecfdace270c7" +checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" dependencies = [ "proc-macro2", - "syn 2.0.57", + "syn", ] [[package]] name = "proc-macro2" -version = "1.0.79" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.35" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] [[package]] name = "regex" -version = "1.7.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" +dependencies = [ + "aho-corasick", + "memchr", "regex-syntax", ] [[package]] name = "regex-syntax" -version = "0.6.28" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "rustc-hash" @@ -362,156 +411,171 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] -name = "scratch" -version = "1.0.5" +name = "ryu" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "serde" -version = "1.0.157" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707de5fcf5df2b5788fca98dd7eab490bc2fd9b7ef1404defc462833b83f25ca" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.157" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78997f4555c22a7971214540c4a661291970619afd56de19f77e0de86296e1e5" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn", ] [[package]] -name = "shlex" -version = "1.1.0" +name = "serde_json" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] [[package]] -name = "syn" -version = "1.0.109" +name = "sha2" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "cfg-if", + "cpufeatures", + "digest", ] [[package]] -name = "syn" -version = "2.0.57" +name = "shlex" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11a6ae1e52eb25aab8f3fb9fca13be982a373b8f1157ca14b897a825ba4a2d35" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] -name = "termcolor" -version = "1.2.0" +name = "strsim" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" -dependencies = [ - "winapi-util", -] +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] -name = "time" -version = "0.1.45" +name = "syn" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ - "libc", - "wasi", - "winapi", + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] -name = "unicode-ident" -version = "1.0.8" +name = "typenum" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] -name = "unicode-width" -version = "0.1.10" +name = "unicode-ident" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "varnish" version = "0.0.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98deff452d19846a43892821647e81e5520291d8d006464c31d8e280e1fda139" +source = "git+https://github.com/gquintard/varnish-rs.git?branch=feature-macro#a99d66cdb32a4da309b283ba3bccc46bfd9ddf04" dependencies = [ - "pkg-config", - "serde", + "glob", + "varnish-macros", + "varnish-sys", +] + +[[package]] +name = "varnish-macros" +version = "0.0.19" +source = "git+https://github.com/gquintard/varnish-rs.git?branch=feature-macro#a99d66cdb32a4da309b283ba3bccc46bfd9ddf04" +dependencies = [ + "darling", + "prettyplease", + "proc-macro2", + "quote", + "serde_json", + "sha2", + "syn", "varnish-sys", ] [[package]] name = "varnish-sys" version = "0.0.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f21a779a3c486b0cf616b5980c7a561f11575bc267db5144263593cf8906c646" +source = "git+https://github.com/gquintard/varnish-rs.git?branch=feature-macro#a99d66cdb32a4da309b283ba3bccc46bfd9ddf04" dependencies = [ "bindgen", "pkg-config", + "serde", ] +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + [[package]] name = "vmod_fileserver" version = "0.0.6" dependencies = [ "chrono", "varnish", + "varnish-macros", + "varnish-sys", ] -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - [[package]] name = "wasm-bindgen" -version = "0.2.84" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" dependencies = [ "cfg-if", + "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.84" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" +checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 1.0.109", + "syn", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.84" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -519,61 +583,92 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.84" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.84" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" +checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" [[package]] -name = "which" -version = "4.4.0" +name = "windows-core" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "either", - "libc", - "once_cell", + "windows-targets", ] [[package]] -name = "winapi" -version = "0.3.9" +name = "windows-targets" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] [[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" +name = "windows_aarch64_gnullvm" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] -name = "winapi-util" -version = "0.1.5" +name = "windows_aarch64_msvc" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" +name = "windows_x86_64_msvc" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/Cargo.toml b/Cargo.toml index f14b4cd..ffe4050 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,12 +4,11 @@ version = "0.0.6" edition = "2021" license = "BSD-3-Clause" -[build-dependencies] -varnish = "0.0.19" - [dependencies] -varnish = "0.0.19" chrono = "0.4.23" +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"] diff --git a/build.rs b/build.rs deleted file mode 100644 index c9821f6..0000000 --- a/build.rs +++ /dev/null @@ -1,4 +0,0 @@ -// before we actually compile our code, parse `vmod.vcc` to generate some boilerplate -fn main() { - varnish::generate_boilerplate().unwrap(); -} diff --git a/build.sh b/build.sh deleted file mode 100755 index 6401e7d..0000000 --- a/build.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh - -set -ex - -OUT="$1" - -if [ -z "$OUT" ]; then - OUT=. -fi - -if [ -z "$PKG" ]; then - PKG="$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].name')" -fi - -if [ -z "" ]; then - VMODTOOL="$(pkg-config --variable=vmodtool varnishapi)" -fi - -cargo build --release -cargo test --release - -mkdir -p "$OUT" -cp target/debug/lib$PKG.so "$OUT" -rst2man $PKG.man.rst > "$OUT/$PKG.3" -"$VMODTOOL" vmod.vcc -w "$OUT" --output /tmp/tmp_file_to_delete -rm /tmp/tmp_file_to_delete.* diff --git a/justfile b/justfile new file mode 100644 index 0000000..69f989c --- /dev/null +++ b/justfile @@ -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 diff --git a/src/lib.rs b/src/lib.rs index dffb884..49da174 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,3 @@ -varnish::boilerplate!(); - use std::collections::hash_map::DefaultHasher; use std::collections::HashMap; use std::error::Error; @@ -10,17 +8,69 @@ use std::os::unix::fs::MetadataExt; use std::path::PathBuf; use std::time::SystemTime; -use chrono::offset::Utc; -use chrono::DateTime; -use varnish::vcl::backend::{Backend, Serve, Transfer, VCLBackendPtr}; -use varnish::vcl::ctx::{Ctx, LogTag}; +use chrono::{DateTime, Utc}; +use varnish::run_vtc_tests; +use varnish::vcl::{Backend, Ctx, LogTag, Serve, Transfer, VclResult}; + +run_vtc_tests!("tests/*.vtc"); + +#[varnish::vmod] +mod fileserver { + use std::error::Error; + + use varnish::vcl::{Backend, Ctx}; + use varnish_sys::ffi::VCL_BACKEND; + + use super::root; + use crate::{build_mime_dict, FileBackend}; + + // Rust implementation of the VCC object, it mirrors what happens in C, except + // for a couple of points: + // - we create and return a Rust object, instead of a void pointer + // - new() returns a Result, leaving the error handling to varnish-rs + impl root { + pub fn new( + ctx: &mut Ctx, + #[vcl_name] vcl_name: &str, + path: &str, + mime_db: Option<&str>, + ) -> Result> { + // sanity check (note that we don't have null pointers, so path is + // at worst empty) + if path.is_empty() { + return Err( + format!("fileserver: can't create {vcl_name} with an empty path").into(), + ); + } -varnish::vtc!(test01); -varnish::vtc!(test02); -varnish::vtc!(test03); -varnish::vtc!(test04); -varnish::vtc!(test05); -varnish::vtc!(test06); + // store the mime database in memory, possibly + let mimes = match mime_db { + // if there's no path given, we try with a default one, and don't + // complain if it fails + None => build_mime_dict("/etc/mime.types").ok(), + // empty strings means the user does NOT want the mime db + Some("") => None, + // otherwise we do want the file to be valid + Some(p) => Some(build_mime_dict(p)?), + }; + + let backend = Backend::new( + ctx, + vcl_name, + FileBackend { + mimes, + path: path.to_string(), + }, + false, + )?; + Ok(root { backend }) + } + + pub fn backend(&self, _ctx: &Ctx) -> VCL_BACKEND { + self.backend.vcl_ptr() + } + } +} // root is the Rust implement of the VCC definition (in vmod.vcc) // it only contains backend, which wraps a FileBackend, and @@ -30,51 +80,6 @@ struct root { backend: Backend, } -// Rust implementation of the VCC object, it mirrors what happens in C, except -// for a couple of points: -// - we create and return a Rust object, instead of a void pointer -// - new() returns a Result, leaving the error handling to varnish-rs -impl root { - pub fn new( - ctx: &mut Ctx, - vcl_name: &str, - path: &str, - mime_db: Option<&str>, - ) -> Result> { - // sanity check (note that we don't have null pointers, so path is - // at worst empty) - if path.is_empty() { - return Err(format!("fileserver: can't create {vcl_name} with an empty path").into()); - } - - // store the mime database in memory, possibly - let mimes = match mime_db { - // if there's no path given, we try with a default one, and don't - // complain if it fails - None => build_mime_dict("/etc/mime.types").ok(), - // empty strings means the user does NOT want the mime db - Some("") => None, - // otherwise we do want the file to be valid - Some(p) => Some(build_mime_dict(p)?), - }; - - let backend = Backend::new( - ctx, - vcl_name, - FileBackend { - mimes, - path: path.to_string(), - }, - false, - )?; - Ok(root { backend }) - } - - pub fn backend(&self, _ctx: &Ctx) -> VCLBackendPtr { - self.backend.vcl_ptr() - } -} - struct FileBackend { path: String, // top directory of our backend mimes: Option>, // a hashmap linking extensions to maps (optional) @@ -85,17 +90,14 @@ impl Serve for FileBackend { "fileserver" } - fn get_headers(&self, ctx: &mut Ctx) -> Result, Box> { + fn get_headers(&self, ctx: &mut Ctx) -> VclResult> { // we know that bereq and bereq_url, so we can just unwrap the options let bereq = ctx.http_bereq.as_ref().unwrap(); let bereq_url = bereq.url().unwrap(); // combine root and url into something that's hopefully safe let path = assemble_file_path(&self.path, bereq_url); - ctx.log( - LogTag::Debug, - &format!("fileserver: file on disk: {path:?}"), - ); + ctx.log(LogTag::Debug, format!("fileserver: file on disk: {path:?}")); // reset the bereq lifetime, otherwise we couldn't use ctx in the line above // yes, it feels weird at first, but it's for our own good @@ -174,8 +176,8 @@ struct FileTransfer { } impl Transfer for FileTransfer { - fn read(&mut self, buf: &mut [u8]) -> Result> { - self.reader.read(buf).map_err(|e| e.into()) + fn read(&mut self, buf: &mut [u8]) -> VclResult { + self.reader.read(buf).map_err(|e| e.to_string().into()) } fn len(&self) -> Option { Some(self.reader.limit() as usize)