diff --git a/.forgejo/workflows/publish.yaml b/.forgejo/workflows/publish.yaml new file mode 100644 index 0000000..56ff89a --- /dev/null +++ b/.forgejo/workflows/publish.yaml @@ -0,0 +1,54 @@ +on: + push: + tags: + - 'v*' +env: + JUST_VERSION: 1.45.0 + JUST_SHA256SUM: dc3f958aaf8c6506dd90426e9b03f86dd15e74a6467ee0e54929f750af3d9e49 + CARGO_LLVM_COV_VERSION: 0.6.21 + CARGO_LLVM_COV_SHA256SUM: 57f491aedf7cdb261538ceb49cbb1ee9d27df7ca205a5e1a009caaf5cb911afb +jobs: + verify: + runs-on: docker + timeout-minutes: 20 + container: + image: rust:slim + steps: + - name: Install action dependencies + run: | + apt-get install --no-install-recommends --update -y nodejs curl + + - name: Checkout code + uses: actions/checkout@v6 + + - name: Setup Rust toolchain + run: | + rustup component add clippy llvm-tools-preview + rustup component add --toolchain nightly rustfmt + + - name: Setup additional tooling + run: | + fetch() { + repo="$1"; tag="$2"; filename="$3"; digest="$4" + + curl -sSLO -w '%{stderr}HTTP %{response_code} %{url}\n' \ + "https://github.com/$repo/releases/download/$tag/$filename" + + printf '%s %s\n' "$digest" "$filename" > digest + sha256sum --check digest && tar xf "$filename" -C tools + } + + mkdir tools + + fetch casey/just ${{ env.JUST_VERSION }} \ + just-${{ env.JUST_VERSION }}-x86_64-unknown-linux-musl.tar.gz \ + ${{ env.JUST_SHA256SUM }} + fetch taiki-e/cargo-llvm-cov v${{ env.CARGO_LLVM_COV_VERSION }} \ + cargo-llvm-cov-x86_64-unknown-linux-gnu.tar.gz \ + ${{ env.CARGO_LLVM_COV_SHA256SUM }} + + mv -v tools/just tools/cargo-llvm-cov /usr/local/bin + + - name: Build release binary and upload it + run: just upload + diff --git a/.justfile b/.justfile index 9990d42..b5494d3 100644 --- a/.justfile +++ b/.justfile @@ -5,8 +5,6 @@ update: cargo update --verbose -alias u := update - # Build and serve [group: 'develop'] run host='::1' port='3003' *args: @@ -230,10 +228,18 @@ verify: echo "Git working tree is dirty: Commit or stash your changes first" exit 1 fi - {{ just_cmd }} format-assess lint-assess check test cover-assess + {{ just_cmd }} version-assess format-assess lint-assess check test cover-assess alias v := verify +# Check tag-manifest consistency +[script, group: 'assess'] +version-assess: + last_tag=$(git describe --tags --abbrev=0 \ + $(git rev-list --tags --max-count=1) | tr -d v) + manifest_version=$(cat Cargo.toml | grep '^version' | cut -d \" -f 2) + [ "$last_tag" = "$manifest_version" ] + # BUILD # Cleanup build artifacts @@ -259,10 +265,35 @@ alias rb := release-build # Clean, run assessments, release build [group: 'build'] -full-build: clean update verify release-build +full-build: clean release-build alias fb := full-build +# Upload release build to git.jutty.dev package registry +[script, group: 'build'] +upload: full-build && shasum + version=$(./target/release/en --version) + api_root=https://git.jutty.dev/api/ + url=$api_root/packages/jutty/generic/en/$version/en-x86_64-linux-gnu + file=target/release/en + if [ "${CI:-}" = true ]; then + curl -fsSL \ + --user jutty:${{{{ secrets.GJD_REGISTRY_TOKEN }} \ + --upload-file $file $url + else + curl -fsSL \ + --user jutty:$(secret-tool lookup Title gjd-registry-token) \ + --upload-file $file $url + + fi + +alias u := upload + +# Print sha256sum for CI logging +[group: 'build'] +shasum: + sha256sum target/release/en + ## META [default, private] diff --git a/Cargo.lock b/Cargo.lock index 8423a21..d9c09ea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -98,9 +98,9 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bitflags" -version = "2.10.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" +checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" [[package]] name = "block-buffer" @@ -129,15 +129,15 @@ checksum = "5dd9dc738b7a8311c7ade152424974d8115f2cdad61e8dab8dac9f2362298510" [[package]] name = "bytes" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3" +checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" [[package]] name = "cc" -version = "1.2.51" +version = "1.2.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a0aeaff4ff1a90589618835a598e545176939b97874f7abc7851caa0618f203" +checksum = "aebf35691d1bfb0ac386a69bac2fde4dd276fb618cf8bf4f5318fe285e821bb2" dependencies = [ "find-msvc-tools", "shlex", @@ -151,9 +151,9 @@ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "chrono" -version = "0.4.42" +version = "0.4.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2" +checksum = "fac4744fb15ae8337dc853fee7fb3f4e48c0fbaa23d0afe49c447b4fab126118" dependencies = [ "iana-time-zone", "num-traits", @@ -279,15 +279,15 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "find-msvc-tools" -version = "0.1.6" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645cbb3a84e60b7531617d5ae4e57f7e27308f6445f5abf653209ea76dec8dff" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" [[package]] name = "flate2" -version = "1.1.5" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfe33edd8e85a12a67454e37f8c75e730830d83e313556ab9ebf9ee7fbeb3bfb" +checksum = "843fba2746e448b37e26a819579957415c8cef339bf08564fe8b7ddbd959573c" dependencies = [ "crc32fast", "miniz_oxide", @@ -304,35 +304,35 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" dependencies = [ "futures-core", ] [[package]] name = "futures-core" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" [[package]] name = "futures-task" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" [[package]] name = "futures-util" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" dependencies = [ "futures-core", "futures-task", "pin-project-lite", - "pin-utils", + "slab", ] [[package]] @@ -347,9 +347,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" dependencies = [ "cfg-if", "libc", @@ -463,12 +463,11 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.19" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "727805d60e7938b76b826a6ef209eb70eaa1812794f9424d4a4e2d740662df5f" +checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0" dependencies = [ "bytes", - "futures-core", "http", "http-body", "hyper", @@ -479,9 +478,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.64" +version = "0.1.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33e57f83510bb73707521ebaffa789ec8caf86f9657cad665b092b581d40e9fb" +checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -519,9 +518,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.12.1" +version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ad4bb2b565bca0645f4d68c5c9af97fba094e9791da685bf83cb5f3ce74acf2" +checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" dependencies = [ "equivalent", "hashbrown", @@ -535,9 +534,9 @@ checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" [[package]] name = "js-sys" -version = "0.3.83" +version = "0.3.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "464a3709c7f55f1f721e5389aa6ea4e3bc6aba669353300af094b29ffbdde1d8" +checksum = "8c942ebf8e95485ca0d52d97da7c5a2c387d0e7f0ba4c35e93bfcaee045955b3" dependencies = [ "once_cell", "wasm-bindgen", @@ -551,15 +550,15 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.178" +version = "0.2.182" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091" +checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112" [[package]] name = "libm" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" [[package]] name = "log" @@ -575,9 +574,9 @@ checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" [[package]] name = "memchr" -version = "2.7.6" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" [[package]] name = "mime" @@ -638,9 +637,9 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "pest" -version = "2.8.4" +version = "2.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbcfd20a6d4eeba40179f05735784ad32bdaef05ce8e8af05f180d45bb3e7e22" +checksum = "e0848c601009d37dfa3430c4666e147e49cdcf1b92ecd3e63657d8a5f19da662" dependencies = [ "memchr", "ucd-trie", @@ -648,9 +647,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.8.4" +version = "2.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51f72981ade67b1ca6adc26ec221be9f463f2b5839c7508998daa17c23d94d7f" +checksum = "11f486f1ea21e6c10ed15d5a7c77165d0ee443402f0780849d1768e7d9d6fe77" dependencies = [ "pest", "pest_generator", @@ -658,9 +657,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.8.4" +version = "2.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee9efd8cdb50d719a80088b76f81aec7c41ed6d522ee750178f83883d271625" +checksum = "8040c4647b13b210a963c1ed407c1ff4fdfa01c31d6d2a098218702e6664f94f" dependencies = [ "pest", "pest_meta", @@ -671,9 +670,9 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.8.4" +version = "2.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf1d70880e76bdc13ba52eafa6239ce793d85c8e43896507e43dd8984ff05b82" +checksum = "89815c69d36021a140146f26659a81d6c2afa33d216d736dd4be5381a7362220" dependencies = [ "pest", "sha2", @@ -740,18 +739,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.104" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9695f8df41bb4f3d222c95a67532365f569318332d03d5f3f67f37b20e6ebdf0" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.42" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f" +checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4" dependencies = [ "proc-macro2", ] @@ -788,9 +787,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.12.2" +version = "1.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" +checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" dependencies = [ "aho-corasick", "memchr", @@ -800,9 +799,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" +checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" dependencies = [ "aho-corasick", "memchr", @@ -811,9 +810,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" +checksum = "a96887878f22d7bad8a3b6dc5b7440e0ada9a245242924394987b21cf2210a4c" [[package]] name = "ring" @@ -831,9 +830,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.35" +version = "0.23.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "533f54bc6a7d4f647e46ad909549eda97bf5afc1585190ef692b4286b198bd8f" +checksum = "c665f33d38cea657d9614f766881e4d510e0eda4239891eea56b4cadcf01801b" dependencies = [ "log", "once_cell", @@ -846,18 +845,18 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.13.2" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21e6f2ab2928ca4291b86736a8bd920a277a399bba1589409d72154ff87c1282" +checksum = "be040f8b0a225e40375822a563fa9524378b9d63112f53e19ffff34df5d33fdd" dependencies = [ "zeroize", ] [[package]] name = "rustls-webpki" -version = "0.103.8" +version = "0.103.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ffdfa2f5286e2247234e03f680868ac2815974dc39e00ea15adc445d0aafe52" +checksum = "d7df23109aa6c1567d1c575b9952556388da57401e4ace1d15f79eedad0d8f53" dependencies = [ "ring", "rustls-pki-types", @@ -872,9 +871,9 @@ checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" [[package]] name = "ryu" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a50f4cf475b65d88e057964e0e9bb1f0aa9bbb2036dc65c64596b42932536984" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" [[package]] name = "same-file" @@ -917,9 +916,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.148" +version = "1.0.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3084b546a1dd6289475996f182a22aba973866ea8e8b02c51d9f46b1336a22da" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" dependencies = [ "itoa", "memchr", @@ -985,9 +984,15 @@ checksum = "e320a6c5ad31d271ad523dcf3ad13e2767ad8b1cb8f047f75a8aeaf8da139da2" [[package]] name = "siphasher" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" +checksum = "b2aa850e253778c88a04c3d7323b043aeda9d3e30d5971937c1855769763678e" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" [[package]] name = "slug" @@ -1007,9 +1012,9 @@ checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" [[package]] name = "socket2" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17129e116933cf371d018bb80ae557e889637989d8638274fb25622827b03881" +checksum = "86f4aa3ad99f2088c990dfa82d367e19cb29268ed67c574d10d0a4bfe71f07e0" dependencies = [ "libc", "windows-sys 0.60.2", @@ -1023,9 +1028,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.111" +version = "2.0.116" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "390cc9a294ab71bdb1aa2e99d13be9c753cd2d7bd6560c77118597410c4d2e87" +checksum = "3df424c70518695237746f84cede799c9c58fcb37450d7b23716568cc8bc69cb" dependencies = [ "proc-macro2", "quote", @@ -1062,9 +1067,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.48.0" +version = "1.49.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff360e02eab121e0bc37a2d3b4d4dc622e6eda3a8e5253d5435ecf5bd4c68408" +checksum = "72a2903cd7736441aac9df9d7688bd0ce48edccaadf181c3b90be801e81d3d86" dependencies = [ "libc", "mio", @@ -1087,9 +1092,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.9.10+spec-1.1.0" +version = "0.9.12+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0825052159284a1a8b4d6c0c86cbc801f2da5afd2b225fa548c72f2e74002f48" +checksum = "cf92845e79fc2e2def6a5d828f0801e29a2f8acc037becc5ab08595c7d5e9863" dependencies = [ "indexmap", "serde_core", @@ -1111,9 +1116,9 @@ dependencies = [ [[package]] name = "toml_parser" -version = "1.0.6+spec-1.1.0" +version = "1.0.9+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3198b4b0a8e11f09dd03e133c0280504d0801269e9afa46362ffde1cbeebf44" +checksum = "702d4415e08923e7e1ef96cd5727c0dfed80b4d2fa25db9647fe5eb6f7c5a4c4" dependencies = [ "winnow", ] @@ -1126,9 +1131,9 @@ checksum = "ab16f14aed21ee8bfd8ec22513f7287cd4a91aa92e44edfe2c17ddd004e92607" [[package]] name = "tower" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" +checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" dependencies = [ "futures-core", "futures-util", @@ -1186,9 +1191,9 @@ checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" [[package]] name = "unicode-ident" -version = "1.0.22" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" [[package]] name = "unicode-segmentation" @@ -1204,9 +1209,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "ureq" -version = "3.1.4" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d39cb1dbab692d82a977c0392ffac19e188bd9186a9f32806f0aaa859d75585a" +checksum = "fdc97a28575b85cfedf2a7e7d3cc64b3e11bd8ac766666318003abbacc7a21fc" dependencies = [ "base64", "flate2", @@ -1261,9 +1266,9 @@ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] name = "wasm-bindgen" -version = "0.2.106" +version = "0.2.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d759f433fa64a2d763d1340820e46e111a7a5ab75f993d1852d70b03dbb80fd" +checksum = "64024a30ec1e37399cf85a7ffefebdb72205ca1c972291c51512360d90bd8566" dependencies = [ "cfg-if", "once_cell", @@ -1274,9 +1279,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.106" +version = "0.2.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48cb0d2638f8baedbc542ed444afc0644a29166f1595371af4fecf8ce1e7eeb3" +checksum = "008b239d9c740232e71bd39e8ef6429d27097518b6b30bdf9086833bd5b6d608" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1284,9 +1289,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.106" +version = "0.2.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cefb59d5cd5f92d9dcf80e4683949f15ca4b511f4ac0a6e14d4e1ac60c6ecd40" +checksum = "5256bae2d58f54820e6490f9839c49780dff84c65aeab9e772f15d5f0e913a55" dependencies = [ "bumpalo", "proc-macro2", @@ -1297,18 +1302,18 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.106" +version = "0.2.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbc538057e648b67f72a982e708d485b2efa771e1ac05fec311f9f63e5800db4" +checksum = "1f01b580c9ac74c8d8f0c0e4afb04eeef2acf145458e52c03845ee9cd23e3d12" dependencies = [ "unicode-ident", ] [[package]] name = "webpki-roots" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2878ef029c47c6e8cf779119f20fcf52bde7ad42a731b2a304bc221df17571e" +checksum = "22cfaf3c063993ff62e73cb4311efde4db1efb31ab78a3e5c457939ad5cc0bed" dependencies = [ "rustls-pki-types", ] @@ -1545,18 +1550,18 @@ checksum = "5a5364e9d77fcdeeaa6062ced926ee3381faa2ee02d3eb83a5c27a8825540829" [[package]] name = "zerocopy" -version = "0.8.31" +version = "0.8.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd74ec98b9250adb3ca554bdde269adf631549f51d8a8f8f0a10b50f1cb298c3" +checksum = "db6d35d663eadb6c932438e763b262fe1a70987f9ae936e60158176d710cae4a" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.31" +version = "0.8.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8a8d209fdf45cf5138cbb5a506f6b52522a25afccc534d1475dad8e31105c6a" +checksum = "4122cd3169e94605190e77839c9a40d40ed048d305bfdc146e7df40ab0f3e517" dependencies = [ "proc-macro2", "quote", @@ -1571,6 +1576,6 @@ checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" [[package]] name = "zmij" -version = "1.0.0" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d6085d62852e35540689d1f97ad663e3971fc19cf5eceab364d62c646ea167" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/src/main.rs b/src/main.rs index f561e2d..23fe357 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,13 +5,8 @@ use en::{ONSET, graph::Graph, log, prelude::*, syntax}; #[tokio::main] #[expect(clippy::print_stderr, clippy::print_stdout, clippy::use_debug)] async fn main() -> io::Result<()> { - log::print_state(); let mut instant = now(); - let args = syntax::command::Arguments::default().parse(); - let address = args.make_address(); - instant = tlog!(&instant, "Parsed CLI arguments"); - panic::set_hook(Box::new(|info| { let payload = info .payload_as_str() @@ -37,12 +32,23 @@ async fn main() -> io::Result<()> { })); instant = tlog!(&instant, "Set up panic hook"); + let args = syntax::command::Arguments::default().parse(); + instant = tlog!(&instant, "Parsed CLI arguments"); + + if args.flags.version { + println!(env!("CARGO_PKG_VERSION")); + return Ok(()); + } + + log::print_state(); + let graph = Graph::load(); instant = tlog!(&instant, "Loaded graph"); let router = en::router::new(graph); tlog!(&instant, "Initialized router"); + let address = args.make_address(); let listener = tokio::net::TcpListener::bind(&address).await.map_err(|e| { log!(ERROR, "Failed to create listener at {address}: {e:#?}"); diff --git a/src/syntax/command.rs b/src/syntax/command.rs index 4d5dd02..04d1195 100644 --- a/src/syntax/command.rs +++ b/src/syntax/command.rs @@ -12,6 +12,12 @@ pub struct Arguments { pub hostname: String, pub port: u16, pub graph_path: PathBuf, + pub flags: Flags, +} + +#[derive(Default, Clone, Debug, PartialEq, Eq)] +pub struct Flags { + pub version: bool, } impl Arguments { @@ -32,6 +38,7 @@ impl Default for Arguments { hostname: String::from("0.0.0.0"), port: 0, graph_path: PathBuf::from("./static/graph.toml"), + flags: Flags::default(), } } } @@ -39,21 +46,33 @@ impl Default for Arguments { fn parse(defaults: &Arguments, args: &[String]) -> Arguments { let mut out_args = defaults.clone(); - let filtered_args = if let Some((head, tail)) = args.split_first() { + // The first argument is usually the command path, but this is not + // guaranteed on all platforms so we drop it if it is unrecognized. + // For now, this is done simply by checking if it starts with a dash + let commandless_args = if let Some((head, tail)) = args.split_first() { if head.starts_with('-') { args } else { tail } } else { args }; - for arg in filtered_args.chunks(2) { + let mut nonflag_args: Vec<&str> = vec![]; + for arg in commandless_args { + if arg == "--version" || arg == "-v" { + out_args.flags.version = true; + } else { + nonflag_args.push(arg); + } + } + + for arg in nonflag_args.chunks(2) { if let Some(argument) = arg.first() && let Some(parameter) = arg.get(1) { - if argument.eq("-h") || argument.eq("--hostname") { - out_args.hostname = String::from(parameter); - } else if argument.eq("-p") || argument.eq("--port") { + if *argument == "-h" || *argument == "--hostname" { + out_args.hostname = String::from(*parameter); + } else if *argument == "-p" || *argument == "--port" { out_args.port = parameter.parse().unwrap_or(out_args.port); - } else if argument.eq("-g") || argument.eq("--graph") { + } else if *argument == "-g" || *argument == "--graph" { out_args.graph_path = PathBuf::from(parameter); } else { if FIRST_PARSE.load(Ordering::SeqCst) { @@ -78,6 +97,7 @@ mod tests { hostname: String::from("localhost"), port: 3007, graph_path: PathBuf::default(), + flags: Flags::default(), }; assert_eq!(args.make_address(), "localhost:3007"); diff --git a/static/graph.toml b/static/graph.toml index daa7c3d..a8007a9 100644 --- a/static/graph.toml +++ b/static/graph.toml @@ -4,25 +4,42 @@ root_node = "Documentation" text = """ ## Installation -For now, if you want to try en, you must build it yourself. +### Pre-built binaries -In an environment with a |Rust toolchain|https://rustup.rs/ and Git installed, run: +The easiest way to get started is by downloading a pre-built binary. + +x86-64 Linux binaries are available from the |git.jutty.dev package registry|https://git.jutty.dev/jutty/-/packages/generic/en|. Check the links under "Assets" for direct downloads. + +Other platforms may be supported in the future depending on CI resources. + +### Build from source + +If you are on another platform or simply paranoid, you can also build en yourself. + +You will need: + +- For compiling en, a |Rust toolchain|https://rustup.rs/ +- For compiling dependencies, a C toolchain + +Given the above is satisfied, you can build directly through Cargo: ` -git clone https://codeberg.org/jutty/en -cd en -cargo build --release +cargo install --git https://codeberg.org/jutty/en ` -The en binary will be in `target/release/en`. +And you should now have the `en` command available on your shell. -You can start it and point it to an address, port and graph: +For more information on building from source, see |SourceBuild|. + +## Usage + +Once you have installed en, run it and point it to your graph: ` -en --host localhost --port 3003 --graph ./graph.toml +en --graph my-graph.toml ` -See |CLI| for defaults and details on the CLI options. +See |CLI| for defaults and details on the available options. ## Graph Syntax @@ -87,6 +104,44 @@ This will create a connection from the node with ID `Realism` to a node with ID redirect = "Documentation" hidden = true +[nodes.SourceBuild] +text = """ +Building from source is briefly described in the |Documentation| page. + +Source builds are tested on both Debian and Alpine, meaning en should compile and run on both glibc and musl systems. + +## Dependencies + +A Rust toolchain is required to build en itself and can be installed through |rustup|https://rustup.rs/|. + +For compiling en dependencies, you will need a C compiler and a libc (e.g. `gcc` + `glibc` or `clang` + `musl`), which may already be installed on your system + +% + Distribution ! Needed packages + *Debian* | `gcc` `libc6-dev` + *Alpine* | `clang` +% + +You may also need `curl` or `git` depending on how you will fetch sources. + +## Building from a Git clone + +Aside from the `cargo install` approach described in |Documentation|, ou can alternatively fetch the code yourself first using Git: + +` +git clone https://codeberg.org/jutty/en +cd en +cargo build --release +` + +In this case, the `en` binary will be in `target/release/en`. + +## Runnable examples + +You can find the exact commands used to test installation on both systems in the |tests/containers|https://codeberg.org/jutty/en/src/branch/main/tests/containers| directory of the en source repository. + +""" + [nodes.Node] text = """ A node is defined in your graph file starting with a table header of the form: diff --git a/tests/containers/Containerfile.alpine b/tests/containers/Containerfile.alpine new file mode 100644 index 0000000..d00149a --- /dev/null +++ b/tests/containers/Containerfile.alpine @@ -0,0 +1,14 @@ +FROM alpine:latest +MAINTAINER Juno Takano juno@jutty.dev +USER root + +# Setup tooling +RUN apk add curl clang +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + +# Install +RUN echo "root_node = 'test'" > /root/graph.toml +RUN $HOME/.cargo/bin/cargo install --git https://codeberg.org/jutty/en + +# Launch +CMD ["/root/.cargo/bin/en", "-p", "3008", "-g", "/root/graph.toml"] diff --git a/tests/containers/Containerfile.debian b/tests/containers/Containerfile.debian new file mode 100644 index 0000000..0622617 --- /dev/null +++ b/tests/containers/Containerfile.debian @@ -0,0 +1,15 @@ +FROM debian:stable-slim +MAINTAINER Juno Takano juno@jutty.dev +USER root + +# Setup tooling +RUN apt-get -y --update install --no-install-recommends \ + curl ca-certificates gcc libc6-dev +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + +# Install +RUN echo "root_node = 'test'" > /root/graph.toml +RUN $HOME/.cargo/bin/cargo install --git https://codeberg.org/jutty/en + +# Launch +CMD ["/root/.cargo/bin/en", "-p", "3008", "-g", "/root/graph.toml"] diff --git a/tests/containers/build.sh b/tests/containers/build.sh new file mode 100755 index 0000000..a59edfb --- /dev/null +++ b/tests/containers/build.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env sh + +set -eu + +distro="$1" + +podman build --tag "en-$distro" -f "Containerfile.$distro" diff --git a/tests/containers/run.sh b/tests/containers/run.sh new file mode 100755 index 0000000..ff636a1 --- /dev/null +++ b/tests/containers/run.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env sh + +set -eu + +distro="$1" + +podman run --replace --name "en-$distro" --publish 3008:3008 "en-$distro"