diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..8ab2437 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +# https://editorconfig.org +# Adapted from https://github.com/rust-lang/rust-clippy/blob/master/.editorconfig + +root = true + +[*] +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +indent_style = space +indent_size = 4 +max_line_length = 120 + +[*.md] +# double whitespace at end of line +# denotes a line break in Markdown +trim_trailing_whitespace = false + +[{*.yml,yaml}] +indent_size = 2 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..90cf330 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +* text=auto eol=lf +*.rs text eol=lf whitespace=tab-in-indent,trailing-space,tabwidth=4 +*.fixed linguist-language=Rust diff --git a/.github/renovate.json b/.github/renovate.json new file mode 100644 index 0000000..515d19c --- /dev/null +++ b/.github/renovate.json @@ -0,0 +1,45 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:recommended", + "docker:pinDigests", + "helpers:pinGitHubActionDigests", + ":pinDevDependencies" + ], + "osvVulnerabilityAlerts": true, + "dependencyDashboard": true, + "labels": [ + "dependencies" + ], + "packageRules": [ + { + "description": [ + "Rust" + ], + "matchPackageNames": [ + "rust" + ], + "matchManagers": [ + "custom.regex" + ], + "commitMessageTopic": "rust" + } + ], + "customManagers": [ + { + "description": [ + "Update Rust stable version in rust-toolchain.toml" + ], + "customType": "regex", + "fileMatch": [ + "(^|/)rust-toolchain\\.toml$" + ], + "matchStrings": [ + "channel\\s*=\\s*\"(?\\d+\\.\\d+(\\.\\d+)?)\"" + ], + "depNameTemplate": "rust", + "packageNameTemplate": "rust-lang/rust", + "datasourceTemplate": "github-releases" + } + ] +} diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..58dc18d --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,45 @@ +# Copyright 2024 Dotanuki Labs +# SPDX-License-Identifier: MIT + +name: CD + +on: + workflow_dispatch + +jobs: + release: + runs-on: ubuntu-22.04 + + steps: + - name: Project Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Install additional tools + run: | + sudo snap install --edge --classic just + sudo snap install zig --classic --beta && zig version + + - name: Setup Rust and Cargo plugins + run: just setup-ci + + - name: Check supply-chain issues + run: just supply-chain-checks + + - name: Build against all supported targets + run: just cross-build + + - name: Prepare to release + id: prepare-release + run: ./scripts/prepare-release.sh + + - name: Create draft release + uses: softprops/action-gh-release@9d7c94cfd0a1f3ed45544c887983e9fa900f0564 # v2.0.4 + with: + name: ${{ steps.prepare-release.outputs.version }} + tag_name: ${{ steps.prepare-release.outputs.version }} + token: ${{ secrets.DOTANUKI_BOT_TOKEN }} + generate_release_notes: true + draft: true + files: | + target/ci/**/* + gwv.cdx.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..eda82d7 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,67 @@ +# Copyright 2024 Dotanuki Labs +# SPDX-License-Identifier: MIT + +name: CI + +on: + pull_request: + push: + branches: + - main + +jobs: + essential-checks: + runs-on: ubuntu-22.04 + steps: + - name: Project Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Run essential checks + uses: dotanuki-labs/github-actions/essentials@main + with: + file-patterns: '*.sh,*.rs,*.yml' + license: 'mit' + build: + runs-on: ubuntu-22.04 + needs: essential-checks + + steps: + - name: Project Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Setup CI caching + uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 + with: + save-if: ${{ github.ref == 'refs/heads/main' }} + + - name: Install additional tools + run: | + sudo snap install --edge --classic just + sudo snap install zig --classic --beta && zig version + + - name: Setup Rust and Cargo plugins + run: just setup-ci + + - name: Check code smells + run: just lint + + - name: Run tests + run: just tests + + - name: Check supply-chain issues + run: just supply-chain-checks + + - name: Build against all supported targets + run: just cross-build + + - name: Archive SBOM + uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + with: + name: sbom-${{ github.sha }}.json + path: gwv.cdx.json + + - name: Archive binaries + uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + with: + name: gwv-binaries + path: target/ci diff --git a/.gitignore b/.gitignore index 6985cf1..f082f8f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,8 @@ -# Generated by Cargo -# will have compiled files and executables -debug/ -target/ +# Rust builds +/target +gwv.cdx.json -# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries -# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html -Cargo.lock +# IDE environment +.DS_STORE +.idea -# These are backup files generated by rustfmt -**/*.rs.bk - -# MSVC Windows builds of rustc generate these, which store debugging information -*.pdb diff --git a/.mergify.yml b/.mergify.yml new file mode 100644 index 0000000..16c8642 --- /dev/null +++ b/.mergify.yml @@ -0,0 +1,19 @@ +# Copyright 2024 Dotanuki Labs +# SPDX-License-Identifier: MIT + +pull_request_rules: + - name: Automatic merges for Renovate pull requests + conditions: + - author~=^renovate\[bot\]$ + - check-success=build + actions: + merge: + method: squash + + - name: Be author's friend + conditions: + - author~=^ubiratansoares + - check-success=build + actions: + merge: + method: squash diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..0256770 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,633 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + +[[package]] +name = "anstream" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" + +[[package]] +name = "anstyle-parse" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +dependencies = [ + "anstyle", + "windows-sys", +] + +[[package]] +name = "anyhow" +version = "1.0.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" + +[[package]] +name = "assert_cmd" +version = "2.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed72493ac66d5804837f480ab3766c72bdfab91a65e565fc54fa9e42db0073a8" +dependencies = [ + "anstyle", + "bstr", + "doc-comment", + "predicates", + "predicates-core", + "predicates-tree", + "wait-timeout", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "backtrace" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "bstr" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05efc5cfd9110c8416e471df0e96702d58690178e206e61b7173706673c93706" +dependencies = [ + "memchr", + "regex-automata", + "serde", +] + +[[package]] +name = "cc" +version = "1.0.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clap" +version = "4.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "949626d00e063efc93b6dca932419ceb5432f99769911c0b995f7e884c778813" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90239a040c80f5e14809ca132ddc4176ab33d5e17e49691793296e3fcb34d72f" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" + +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + +[[package]] +name = "difflib" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" + +[[package]] +name = "doc-comment" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "float-cmp" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" +dependencies = [ + "num-traits", +] + +[[package]] +name = "getrandom" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "gimli" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" + +[[package]] +name = "hashbrown" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "human-panic" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4f016c89920bbb30951a8405ecacbb4540db5524313b9445736e7e1855cf370" +dependencies = [ + "anstream", + "anstyle", + "backtrace", + "os_info", + "serde", + "serde_derive", + "toml", + "uuid", +] + +[[package]] +name = "indexmap" +version = "2.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "libc" +version = "0.2.153" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" + +[[package]] +name = "log" +version = "0.4.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" + +[[package]] +name = "memchr" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" + +[[package]] +name = "miniz_oxide" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +dependencies = [ + "adler", +] + +[[package]] +name = "normalize-line-endings" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" + +[[package]] +name = "num-traits" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" +dependencies = [ + "autocfg", +] + +[[package]] +name = "object" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +dependencies = [ + "memchr", +] + +[[package]] +name = "os_info" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "006e42d5b888366f1880eda20371fedde764ed2213dc8496f49622fa0c99cd5e" +dependencies = [ + "log", + "serde", + "winapi", +] + +[[package]] +name = "predicates" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68b87bfd4605926cdfefc1c3b5f8fe560e3feca9d5552cf68c466d3d8236c7e8" +dependencies = [ + "anstyle", + "difflib", + "float-cmp", + "normalize-line-endings", + "predicates-core", + "regex", +] + +[[package]] +name = "predicates-core" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b794032607612e7abeb4db69adb4e33590fa6cf1149e95fd7cb00e634b92f174" + +[[package]] +name = "predicates-tree" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "368ba315fb8c5052ab692e68a0eefec6ec57b23a36959c14496f0b0df2c0cecf" +dependencies = [ + "predicates-core", + "termtree", +] + +[[package]] +name = "proc-macro2" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "regex" +version = "1.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" + +[[package]] +name = "gwv" +version = "0.1.0" +dependencies = [ + "anyhow", + "assert_cmd", + "clap", + "human-panic", + "predicates", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + +[[package]] +name = "serde" +version = "1.0.197" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.197" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_spanned" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +dependencies = [ + "serde", +] + +[[package]] +name = "strsim" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" + +[[package]] +name = "syn" +version = "2.0.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "termtree" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" + +[[package]] +name = "toml" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a9aad4a3066010876e8dcf5a8a06e70a558751117a145c6ce2b82c2e2054290" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c1b5fd4128cc8d3e0cb74d4ed9a9cc7c7284becd4df68f5f940e1ad123606f6" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + +[[package]] +name = "uuid" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" +dependencies = [ + "getrandom", +] + +[[package]] +name = "wait-timeout" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" +dependencies = [ + "libc", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..4294bde --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "gwv" +version = "0.1.0" +edition = "2021" +authors = ["ubiratan.f.soares@gmail.com"] +description = "An opinionated way to kick-off CLI apps powered by Rust" +repository = "https://github.com/dotanuki-labs/gwv" +readme = "README.md" +license = "MIT" +publish = false + +[dependencies] +anyhow = "1.0.81" +assert_cmd = "2.0.14" +clap = { version = "4.5.3", features = ["derive"] } +human-panic = "1.2.3" +predicates = "3.1.0" + +[profile.release] +strip = true +lto = true +codegen-units = 1 diff --git a/LICENSE b/LICENSE index 3f86ef1..694fffd 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ -MIT License +The MIT License -Copyright (c) 2024 Dotanuki Labs +Copyright (c) 2024 - Dotanuki Labs Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 25b4759..2e8ddf1 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,15 @@ # gradle-wrapper-validator -A validator for gradle/wrapper jar binaries, intended to be used within CI pipelines. + +> A validator for gradle/wrapper jar binaries for your CI pipelines. + +## Why + +> To do + +## Using + +> To do + +## License + +Copyright (c) 2024 - Dotanuki Labs - [The MIT license](https://choosealicense.com/licenses/mit) diff --git a/deny.toml b/deny.toml new file mode 100644 index 0000000..699531a --- /dev/null +++ b/deny.toml @@ -0,0 +1,13 @@ +[advisories] +ignore = [ + # No advisories so far! +] + +[licenses] +confidence-threshold = 0.95 +allow = [ + "Apache-2.0", + "MIT", + "Unicode-DFS-2016" +] + diff --git a/justfile b/justfile new file mode 100644 index 0000000..9d31493 --- /dev/null +++ b/justfile @@ -0,0 +1,88 @@ +# General tasks driven by Just +# https://github.com/casey/just + +# Install and activate Rust toolchain +toolchain: + @echo "→ Install and activate Rust toolchain" + rustup show active-toolchain + @echo + +# Install Cargo plugins (local) +cargo-plugins-local: + @echo "→ Installing Cargo Binstall" + ./scripts/cargo-binstaller.sh + @echo + + @echo "→ Installing Cargo plugins (local)" + yes | cargo binstall cargo-nextest --secure --force + yes | cargo binstall cargo-get --secure --force + @echo + +# Performs setup for this project (local) +setup-local: toolchain cargo-plugins-local + @echo + @echo "✅ Setup (local) concluded" + @echo + +# Check code formatting and smells +lint: toolchain + @echo "→ Checking code formatting (rustfmt)" + cargo fmt --check + @echo + + @echo "→ Checking code smells (clippy)" + cargo clippy --all-targets --all-features + @echo + +# Build project against the local toolchain +simple-build: toolchain + @echo "→ Compile project and build binary" + cargo build + @echo + +# Run Tests +tests: simple-build + @echo "→ Run project tests" + cargo nextest run + @echo + +# Emulates CI checks +emulate-ci: lint tests + @echo + @echo "✅ Emulated a CI build with success" + @echo + +# Install required Cargo plugins (CI) +cargo-plugins-ci: + @echo "→ Installing Cargo Binstall" + ./scripts/cargo-binstaller.sh + @echo + + @echo "→ Installing Cargo plugins (CI)" + yes | cargo binstall cargo-deny --secure --force + yes | cargo binstall cargo-cyclonedx --secure --force + yes | cargo binstall cargo-zigbuild --secure --force + yes | cargo binstall cargo-nextest --secure --force + yes | cargo binstall cargo-get --secure --force + @echo + +# Performs setup for this project (CI) +setup-ci: toolchain cargo-plugins-ci + @echo "✅ Setup (CI) concluded" + @echo + +# Build project against all supported targets +cross-build: + @echo "→ Build project against all supported targets" + ./scripts/cross-build.sh + @echo + +# Generates supply-chain related artifacts +supply-chain-checks: + @echo "→ Checking supplying chain" + cargo deny check + @echo + + @echo "→ Generating SBOMs" + cargo cyclonedx --format json + @echo diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..b4b6ae4 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "1.76.0" +components = ["clippy", "rustfmt"] diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..1b5359f --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,5 @@ +# Adapted from https://github.com/rust-lang/rust-clippy/blob/master/rustfmt.toml + +edition = "2021" +max_width = 120 +match_block_trailing_comma = true diff --git a/scripts/cargo-binstaller.sh b/scripts/cargo-binstaller.sh new file mode 100755 index 0000000..c294cab --- /dev/null +++ b/scripts/cargo-binstaller.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Copyright 2024 Dotanuki Labs +# SPDX-License-Identifier: MIT + +set -euo pipefail + +cd "$(mktemp -d)" + +base_url="https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-" + +os="$(uname -s)" + +if [ "$os" == "Darwin" ]; then + url="${base_url}universal-apple-darwin.zip" + curl -LO --proto '=https' --tlsv1.2 -sSf "$url" + unzip cargo-binstall-universal-apple-darwin.zip + +elif [ "$os" == "Linux" ]; then + machine="$(uname -m)" + target="${machine}-unknown-linux-musl" + if [ "$machine" == "armv7" ]; then + target="${target}eabihf" + fi + + url="${base_url}${target}.tgz" + curl -L --proto '=https' --tlsv1.2 -sSf "$url" | tar -xvzf - +else + echo "Unsupported OS ${os}" + exit 1 +fi + +./cargo-binstall -y --force cargo-binstall + +CARGO_HOME="${CARGO_HOME:-$HOME/.cargo}" + +if ! [[ ":$PATH:" == *":$CARGO_HOME/bin:"* ]]; then + echo + printf "Your path is missing %s, you might want to add it.\n" "$CARGO_HOME/bin" + echo +fi diff --git a/scripts/cross-build.sh b/scripts/cross-build.sh new file mode 100755 index 0000000..3233834 --- /dev/null +++ b/scripts/cross-build.sh @@ -0,0 +1,30 @@ +#! /usr/bin/env bash +# Copyright 2024 Dotanuki Labs +# SPDX-License-Identifier: MIT + +set -euo pipefail + +readonly output_dir="target/ci" + +dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +cd "${dir%/*}" + +rm -rf "$output_dir" && mkdir -p "$output_dir" + +cross_compile() { + local target="$1" + + rustup target add "$target" + cargo zigbuild --release --target "$target" + + local binary="target/$target/release/gwv" + cp "$binary" "$output_dir"/gwv-"$target" + chmod +x "$output_dir"/gwv-"$target" + sha256sum "$binary" >>"$output_dir"/gwv-"$target"-sha256 +} + +for platform in apple-darwin unknown-linux-gnu; do + for arch in x86_64 aarch64; do + cross_compile "$arch-$platform" + done +done diff --git a/scripts/prepare-release.sh b/scripts/prepare-release.sh new file mode 100755 index 0000000..1e5496f --- /dev/null +++ b/scripts/prepare-release.sh @@ -0,0 +1,11 @@ +#! /usr/bin/env bash +# Copyright 2024 Dotanuki Labs +# SPDX-License-Identifier: MIT + +set -e + +dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +cd "${dir%/*}" + +version=$(cargo get package.version) +echo "version=$version" >>"$GITHUB_OUTPUT" diff --git a/src/core.rs b/src/core.rs new file mode 100644 index 0000000..449fa94 --- /dev/null +++ b/src/core.rs @@ -0,0 +1,6 @@ +// Copyright 2024 Dotanuki Labs +// SPDX-License-Identifier: MIT + +mod greeter; + +pub use greeter::greet; diff --git a/src/core/greeter.rs b/src/core/greeter.rs new file mode 100644 index 0000000..6f5470f --- /dev/null +++ b/src/core/greeter.rs @@ -0,0 +1,6 @@ +// Copyright 2024 Dotanuki Labs +// SPDX-License-Identifier: MIT + +pub fn greet(name: &str) -> anyhow::Result { + Ok(format!("Hello, {}!", name)) +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..0ac9225 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,57 @@ +// Copyright 2024 Dotanuki Labs +// SPDX-License-Identifier: MIT + +mod core; + +use clap::Parser; +use human_panic::setup_panic; + +#[derive(Parser, Debug)] +#[command(version, about, long_about = None)] +struct ProgramArguments { + #[arg(short, long)] + name: String, +} + +fn main() { + setup_panic!(); + + let arguments = ProgramArguments::parse(); + let greet = core::greet(&arguments.name).unwrap(); + println!("{}", greet); +} + +#[cfg(test)] +mod tests { + use assert_cmd::Command; + use predicates::str::contains; + + static TOOL: &str = "gwv"; + + #[test] + fn should_parse_arguments() { + let mut cmd = Command::cargo_bin(TOOL).unwrap(); + let assert = cmd.args(["--name", "John"]).assert(); + + let expected = "Hello, John!\n"; + assert.stdout(expected); + } + + #[test] + fn should_show_help() { + let mut cmd = Command::cargo_bin(TOOL).unwrap(); + let description = "An opinionated way to kick-off CLI apps powered by Rust"; + + let assert = cmd.arg("--help").assert(); + assert.stdout(contains(description)); + } + + #[test] + fn should_fail_without_arguments() { + let mut cmd = Command::cargo_bin(TOOL).unwrap(); + let instruction = "required arguments were not provided"; + + let assert = cmd.assert(); + assert.failure().stderr(contains(instruction)); + } +}