diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e30d10b4f69..bb9bce15227 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -77,6 +77,7 @@ jobs: strategy: matrix: build: [linux, linux-arm, macos, win-msvc, win-gnu, win32-msvc] + feature: ["lean", "small"] include: - build: linux os: ubuntu-18.04 @@ -119,12 +120,6 @@ jobs: run: | ci/macos-install-packages - - name: Patch Cargo.toml (Windows) - if: matrix.os == 'windows-2019' - shell: bash - run: | - cat Cargo.toml.windows-suffix >> Cargo.toml - - name: Install Rust uses: actions-rs/toolchain@v1 with: @@ -166,11 +161,12 @@ jobs: echo "release version: $RELEASE_VERSION" - name: Build release binary - run: ${{ env.CARGO }} build --verbose --release ${{ env.TARGET_FLAGS }} + run: ${{ env.CARGO }} build --verbose --release ${{ env.TARGET_FLAGS }} --no-default-features --features ${{ matrix.feature }} - name: Strip release binary (linux and macos) if: matrix.build == 'linux' || matrix.build == 'macos' - run: strip "target/${{ matrix.target }}/release/${{ env.BIN_NAME }}" + shell: bash + run: strip target/${{ matrix.target }}/release/${{ env.BIN_NAME }}{,p} - name: Strip release binary (arm) if: matrix.build == 'linux-arm' @@ -179,22 +175,22 @@ jobs: "$PWD/target:/target:Z" \ rustembedded/cross:arm-unknown-linux-gnueabihf \ arm-linux-gnueabihf-strip \ - /target/arm-unknown-linux-gnueabihf/release/${{ env.BIN_NAME }} + /target/arm-unknown-linux-gnueabihf/release/${{ env.BIN_NAME }}{,p} - name: Build archive shell: bash run: | - staging="${{ env.BIN_NAME }}-${{ env.RELEASE_VERSION }}-${{ matrix.target }}" + staging="${{ env.BIN_NAME }}-${{ matrix.feature }}-${{ env.RELEASE_VERSION }}-${{ matrix.target }}" mkdir -p "$staging" - cp {README.md,LICENSE,CHANGELOG.md} "$staging/" + cp {README.md,LICENSE.md,CHANGELOG.md} "$staging/" if [ "${{ matrix.os }}" = "windows-2019" ]; then - cp "target/${{ matrix.target }}/release/${{ env.BIN_NAME }}.exe" "$staging/" + cp target/${{ matrix.target }}/release/${{ env.BIN_NAME }}{,p}.exe "$staging/" 7z a "$staging.zip" "$staging" echo "::set-env name=ASSET::$staging.zip" else - cp "target/${{ matrix.target }}/release/${{ env.BIN_NAME }}" "$staging/" + cp target/${{ matrix.target }}/release/${{ env.BIN_NAME }}{,p} "$staging/" tar czf "$staging.tar.gz" "$staging" echo "::set-env name=ASSET::$staging.tar.gz" fi diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000000..e69de29bb2d diff --git a/Cargo.lock b/Cargo.lock index 2ef74803eba..b7a3867e471 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,9 +8,9 @@ checksum = "567b077b825e468cc974f0020d4082ee6e03132512f207ef1a02fd5d00d1f32d" [[package]] name = "ahash" -version = "0.3.8" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8fd72866655d1904d6b0997d0b07ba561047d070fbe29de039031c641b61217" +checksum = "94e200a506d98f285fcd550bd2b0e5eacdfd53775e6d3aefaf2781571aabfe6f" dependencies = [ "const-random", ] @@ -179,9 +179,9 @@ checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" [[package]] name = "cc" -version = "1.0.56" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c1f1d60091c1b73e2b1f4560ab419204b178e625fa945ded7b660becd2bd46" +checksum = "0fde55d2a2bfaa4c9668bbc63f531fbdeee3ffe188f4662511ce2c22b3eedebe" [[package]] name = "cfg-if" @@ -333,9 +333,9 @@ dependencies = [ [[package]] name = "dashmap" -version = "3.11.4" +version = "3.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cfcd41ae02d60edded204341d2798ba519c336c51a37330aa4b98a1128def32" +checksum = "142c7c0bd53a40359d2f19a983e824650df36e38510e817519660a0f1676305b" dependencies = [ "ahash", "cfg-if", @@ -683,9 +683,9 @@ checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" [[package]] name = "memoffset" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4fc2c02a7e374099d4ee95a193111f72d2110197fe200272371758f6c3643d8" +checksum = "c198b026e1bbf08a937e94c6c60f9ec4a2267f5b0d2eec9c1b21b061ce2be55f" dependencies = [ "autocfg", ] @@ -1326,9 +1326,9 @@ checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" [[package]] name = "unicode-width" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" [[package]] name = "unicode-xid" diff --git a/Cargo.toml b/Cargo.toml index 2ca31d4100d..56e9c9a4ef5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,11 @@ test = false doctest = false [features] -default = ["fast", "pretty-cli"] +default = ["max"] +max = ["fast", "pretty-cli"] +lean = ["fast", "lean-cli"] +small = ["lean-cli"] + fast = ["git-features/parallel", "git-features/fast-sha1"] pretty-cli = ["structopt", "git-features/progress-prodash", diff --git a/Makefile b/Makefile index c67ad3dffc2..2332c60847e 100644 --- a/Makefile +++ b/Makefile @@ -13,19 +13,19 @@ interactive-developer-environment-in-docker: ## Use docker for all dependencies ##@ Release Builds -release-default: always ## the default build, big bug pretty (builds in ~2min 35s) +release-default: always ## the default build, big but pretty (builds in ~2min 35s) cargo build --release release-lean: always ## lean and fast (builds in ~1min 10s) - cargo build --release --no-default-features --features lean-cli,fast + cargo build --release --no-default-features --features lean release-small: always ## minimal dependencies, at cost of performance (builds in ~46s) - cargo build --release --no-default-features --features lean-cli + cargo build --release --no-default-features --features small ##@ Development target/release/gio: always - cargo build --release --no-default-features --features lean-cli + cargo build --release --no-default-features --features small lint: ## Run lints with clippy cargo clippy @@ -39,14 +39,14 @@ benchmark: target/release/gio ## see how fast things are, powered by hyperfine ##@ Testing -tests: check unit-tests journey-tests journey-tests-lean-cli ## run all tests, including journey tests +tests: check unit-tests journey-tests journey-tests-small ## run all tests, including journey tests check: ## Build all code in suitable configurations cargo check --all cargo check --all --all-features - cargo check --no-default-features --features lean-cli - cargo check --no-default-features --features pretty-cli - cargo check --no-default-features --features lean-cli,fast + cargo check --no-default-features --features small + cargo check --no-default-features --features lean + cargo check --no-default-features --features max cd gitoxide-core && cargo check --all-features cd git-object && cargo check --all-features cd git-odb && cargo check --all-features @@ -60,13 +60,13 @@ unit-tests: ## run all unit tests continuous-unit-tests: ## run all unit tests whenever something changes watchexec -w src $(MAKE) unit-tests -journey-tests: always ## run stateless journey tests (pretty-cli) +journey-tests: always ## run stateless journey tests (max) cargo build - ./tests/stateless-journey.sh target/debug/gio target/debug/giop pretty_and_fast + ./tests/stateless-journey.sh target/debug/gio target/debug/giop max -journey-tests-lean-cli: always ## run stateless journey tests (lean-cli) - cargo build --no-default-features --features lean-cli - ./tests/stateless-journey.sh target/debug/gio target/debug/giop lean_and_small +journey-tests-small: always ## run stateless journey tests (lean-cli) + cargo build --no-default-features --features small + ./tests/stateless-journey.sh target/debug/gio target/debug/giop small continuous-journey-tests: ## run stateless journey tests whenever something changes watchexec $(MAKE) journey-tests diff --git a/README.md b/README.md index 5dd17774817..f8001b2aabc 100644 --- a/README.md +++ b/README.md @@ -172,6 +172,12 @@ The top-level command-line interface. * **lean-cli** _(mutually exclusive to pretty-cli)_ * Use `argh` to produce a usable binary with decent documentation that is smallest in size, usually 300kb less than `pretty-cli`. * If `pretty-cli` is enabled as well, `small-cli` will take precedence, and you pay for building unnecessary dependencies. + +There are convenience features, which combine common choices of the above into one name + +* **max** = *pretty-cli* + *fast* +* **lean** = *lean-cli* + *fast* +* **small** = *lean-cli* ### git-features diff --git a/ci/install.sh b/ci/install.sh new file mode 100644 index 00000000000..2830b7ba612 --- /dev/null +++ b/ci/install.sh @@ -0,0 +1,155 @@ +#!/bin/sh + +set -e + +help() { + cat <<'EOF' +Install a binary release of a Rust crate hosted on GitHub + +Usage: + install.sh [options] + +Options: + -h, --help Display this message + --git SLUG Get the crate from "https://github/$SLUG" + -f, --force Force overwriting an existing binary + --crate NAME Name of the crate to install (default ) + --tag TAG Tag (version) of the crate to install (default ) + --target TARGET Install the release compiled for $TARGET (default <`rustc` host>) + --to LOCATION Where to install the binary (default ~/.cargo/bin) +EOF +} + +say() { + echo "install.sh: $1" +} + +say_err() { + say "$1" >&2 +} + +err() { + if [ ! -z $td ]; then + rm -rf $td + fi + + say_err "ERROR $1" + exit 1 +} + +need() { + if ! command -v $1 > /dev/null 2>&1; then + err "need $1 (command not found)" + fi +} + +force=false +while test $# -gt 0; do + case $1 in + --crate) + crate=$2 + shift + ;; + --force | -f) + force=true + ;; + --git) + git=$2 + shift + ;; + --help | -h) + help + exit 0 + ;; + --tag) + tag=$2 + shift + ;; + --target) + target=$2 + shift + ;; + --to) + dest=$2 + shift + ;; + *) + ;; + esac + shift +done + +# Dependencies +need basename +need curl +need install +need mkdir +need mktemp +need tar + +# Optional dependencies +if [ -z $crate ] || [ -z $tag ] || [ -z $target ]; then + need cut +fi + +if [ -z $tag ]; then + need rev +fi + +if [ -z $target ]; then + need grep + need rustc +fi + +if [ -z $git ]; then + err 'must specify a git repository using `--git`. Example: `install.sh --git japaric/cross`' +fi + +url="https://github.com/$git" +say_err "GitHub repository: $url" + +if [ -z $crate ]; then + crate=$(echo $git | cut -d'/' -f2) +fi + +say_err "Crate: $crate" + +url="$url/releases" + +if [ -z $tag ]; then + tag=$(curl -s "$url/latest" | cut -d'"' -f2 | rev | cut -d'/' -f1 | rev) + say_err "Tag: latest ($tag)" +else + say_err "Tag: $tag" +fi + +if [ -z $target ]; then + target=$(rustc -Vv | grep host | cut -d' ' -f2) +fi + +say_err "Target: $target" + +if [ -z $dest ]; then + dest="$HOME/.cargo/bin" +fi + +say_err "Installing to: $dest" + +url="$url/download/$tag/$crate-$tag-$target.tar.gz" + +say_err "Downloading: $url" +td=$(mktemp -d || mktemp -d -t tmp) +curl -sL $url | tar -C $td -xz + +for f in $(cd $td && find . -type f); do + test -x $td/$f || continue + + if [ -e "$dest/$f" ] && [ $force = false ]; then + err "$f already exists in $dest" + else + mkdir -p $dest + install -v -m 755 $td/$f $dest + fi +done + +rm -rf $td diff --git a/ci/macos-install-packages b/ci/macos-install-packages new file mode 100755 index 00000000000..13f47935d98 --- /dev/null +++ b/ci/macos-install-packages @@ -0,0 +1,2 @@ +#!/bin/sh + diff --git a/ci/ubuntu-install-packages b/ci/ubuntu-install-packages new file mode 100755 index 00000000000..a979efb8457 --- /dev/null +++ b/ci/ubuntu-install-packages @@ -0,0 +1,5 @@ +#!/bin/sh + +sudo apt-get update +sudo apt-get install -y --no-install-recommends \ + xz-utils liblz4-tool musl-tools diff --git a/src/plumbing/pretty.rs b/src/plumbing/pretty.rs index 5124a870efe..2e3e8dfd618 100644 --- a/src/plumbing/pretty.rs +++ b/src/plumbing/pretty.rs @@ -12,7 +12,7 @@ mod options { use structopt::{clap::AppSettings, StructOpt}; #[derive(Debug, StructOpt)] - #[structopt(name = "gio-plumbing", about = "The pretty git underworld")] + #[structopt(name = "gio-plumbing", about = "The git underworld")] #[structopt(settings = &[AppSettings::SubcommandRequired, AppSettings::ColoredHelp])] pub struct Args { diff --git a/src/porcelain/pretty.rs b/src/porcelain/pretty.rs index 37cfa6be57b..36b66ea0285 100644 --- a/src/porcelain/pretty.rs +++ b/src/porcelain/pretty.rs @@ -6,7 +6,7 @@ mod options { use structopt::{clap::AppSettings, StructOpt}; #[derive(Debug, StructOpt)] - #[structopt(about = "The pretty git")] + #[structopt(about = "The git")] #[structopt(settings = &[AppSettings::SubcommandRequired, AppSettings::ColoredHelp])] pub struct Args { diff --git a/tests/stateless-journey.sh b/tests/stateless-journey.sh index 497eec67e44..f16a3aafbe8 100755 --- a/tests/stateless-journey.sh +++ b/tests/stateless-journey.sh @@ -69,7 +69,7 @@ title "CLI ${kind}" expect_run $SUCCESSFULLY "$exe_plumbing" verify-pack --statistics "$PACK_INDEX_FILE" } ) - if test "$kind" = pretty_and_fast; then + if test "$kind" = "max"; then (with "statistics (JSON)" it "verifies the pack index successfully and with desired output" && { WITH_SNAPSHOT="$snapshot/plumbing-verify-pack-index-with-statistics-json-success" \