Split crates and clean up structure of codebase ()

Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Félix Saparelli 2022-08-20 23:24:12 +12:00 committed by GitHub
parent bf700f9012
commit 4b00f5f143
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
88 changed files with 2989 additions and 1423 deletions

View file

@ -2,8 +2,29 @@
version: 2
updates:
- package-ecosystem: "cargo"
- package-ecosystem: "github-actions"
# Workflow files stored in the
# default location of `.github/workflows`
directory: "/"
schedule:
interval: "weekly"
interval: "daily"
- package-ecosystem: "cargo"
directory: "/crates/bin"
schedule:
interval: "daily"
- package-ecosystem: "cargo"
directory: "/crates/detect-wasi"
schedule:
interval: "daily"
- package-ecosystem: "cargo"
directory: "/crates/flock"
schedule:
interval: "daily"
- package-ecosystem: "cargo"
directory: "/crates/lib"
schedule:
interval: "daily"
- package-ecosystem: "cargo"
directory: "/crates/normalize-path"
schedule:
interval: "daily"

35
.github/scripts/compile-settings.jq vendored Normal file
View file

@ -0,0 +1,35 @@
if $for_release then {
output: "release",
profile: "release",
# Use build-std to build a std library optimized for size and abort immediately on abort,
# so that format string for `unwrap`/`expect`/`unreachable`/`panic` can be optimized out.
args: ($matrix.release_build_args // "-Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort"),
features: ($matrix.release_features // []),
} else {
output: "debug",
profile: "dev",
args: ($matrix.debug_build_args // ""),
features: ($matrix.debug_features // ["rustls", "fancy-with-backtrace"]),
} end
|
.rustflags = (
if $for_release and $matrix.target == "aarch64-unknown-linux-musl" or $matrix.target == "armv7-unknown-linux-musleabihf"
then "-C link-arg=-lgcc -Clink-arg=-static-libgcc"
else "" end
)
|
.features = (
if (.features | length > 0)
then "--no-default-features --features \(.features | join(","))"
else "" end
)
|
{
CBIN: (if ($matrix.target | test("windows")) then "cargo-binstall.exe" else "cargo-binstall" end),
CTOOL: (if ($matrix."use-cross" // false) then "cross" else "cargo" end),
COUTPUT: .output,
CARGS: "--target \($matrix.target) --profile \(.profile) \(.features) \(.args)",
RUSTFLAGS: .rustflags,
}
|
to_entries[] | "\(.key)=\(.value)"

16
.github/scripts/extract-release-notes.sh vendored Executable file
View file

@ -0,0 +1,16 @@
#!/bin/bash
set -euxo pipefail
release_pr=$(head -n1 <<< "${COMMIT_MESSAGE:-}" | jq -Rr 'split("[()]"; "")[1] // ""')
if [[ -z "$release_pr" ]]; then
echo "::set-output name=notes_json::null"
exit
fi
gh \
pr --repo "$GITHUB_REPO" \
view "$release_pr" \
--json body \
--jq '"::set-output name=notes_json::\((.body | split("### Release notes")[1] // "") | tojson)"'

View file

@ -0,0 +1,6 @@
#!/bin/bash
set -euxo pipefail
message="$(head -n1 <<< "$COMMIT_MESSAGE")"
version="$(cut -d ' ' -f 2 <<< "${message}")"
echo "::set-output name=version::${version}"

6
.github/scripts/install-deps.sh vendored Executable file
View file

@ -0,0 +1,6 @@
#!/bin/bash
set -euxo pipefail
apt update
exec apt install -y --no-install-recommends liblzma-dev libzip-dev libzstd-dev

18
.github/scripts/pack-release-archives.sh vendored Executable file
View file

@ -0,0 +1,18 @@
#!/bin/bash
set -euxo pipefail
for o in outputs/*; do
pushd "$o"
chmod +x cargo-binstall*
cp ../../LICENSE.txt ../../README.md .
target=$(basename "$o" | cut -d. -f1)
if grep -qE '(apple|windows)' <<< "$target"; then
zip "../cargo-binstall-${target}.zip" *
else
tar cv * | gzip -9 > "../cargo-binstall-${target}.tgz"
fi
popd
done

28
.github/scripts/release-pr.txt vendored Normal file
View file

@ -0,0 +1,28 @@
This is a release PR for version **%version%**.
**Use squash merge.**
Upon merging, this will automatically build the CLI and create a GitHub release.
You still need to manually publish the cargo crate.
```
$ git pull
$ git checkout v%version%
$ cargo publish
```
---
_Edit release notes into the section below:_
<!-- do not change or remove this heading -->
### Release notes
_Binstall is a tool to fetch and install Rust-based executables as binaries. It aims to be a drop-in replacement for `cargo install` in most cases. Install it today with `cargo install cargo-binstall`, from the binaries below, or if you already have it, upgrade with `cargo binstall cargo-binstall`._
#### In this release:
-
#### Other changes:
-

60
.github/scripts/tests.sh vendored Executable file
View file

@ -0,0 +1,60 @@
#!/bin/bash
set -euxo pipefail
bins="cargo-llvm-cov cargo-binstall"
test_bins="cargo-llvm-cov"
unset CARGO_INSTALL_ROOT
unset CARGO_HOME
# Install binaries using cargo-binstall
# shellcheck disable=SC2086
"./$1" binstall --log-level debug --no-confirm $bins
# Test that the installed binaries can be run
for bin in $test_bins; do
"$HOME/.cargo/bin/$bin" --version
done
cargo binstall --help >/dev/null
# Install binaries using `--manifest-path`
"./$1" binstall --force --log-level debug --manifest-path crates/bin/Cargo.toml --no-confirm cargo-binstall
"./$1" binstall --force --log-level debug --manifest-path crates/bin --no-confirm cargo-binstall
# Test that the installed binaries can be run
cargo binstall --help >/dev/null
# Install binaries using secure mode
min_tls=1.3
[[ "${2:-}" == "Windows" ]] && min_tls=1.2 # WinTLS on GHA doesn't support 1.3 yet
"./$1" binstall \
--force \
--log-level debug \
--secure \
--min-tls-version $min_tls \
--no-confirm \
cargo-binstall
# Test that the installed binaries can be run
cargo binstall --help >/dev/null
# Test --version
"./$1" binstall --force --log-level debug --no-confirm --version 0.11.1 cargo-binstall
# Test that the installed binaries can be run
cargo binstall --help >/dev/null
# Test "$crate_name@$version"
"./$1" binstall --force --log-level debug --no-confirm cargo-binstall@0.11.1
# Test that the installed binaries can be run
cargo binstall --help >/dev/null
# Test skip when installed
"./$1" binstall --no-confirm --force cargo-binstall@0.11.1
"./$1" binstall --no-confirm cargo-binstall@0.11.1 | grep -q 'cargo-binstall v0.11.1 is already installed'
"./$1" binstall --no-confirm cargo-binstall@0.10.0 | grep -q -v 'cargo-binstall v0.10.0 is already installed'
## Test When 0.11.0 is installed but can be upgraded.
"./$1" binstall --no-confirm cargo-binstall@0.11.0
"./$1" binstall --no-confirm cargo-binstall@0.11.0 | grep -q 'cargo-binstall v0.11.0 is already installed'
"./$1" binstall --no-confirm cargo-binstall@^0.11.0 | grep -q -v 'cargo-binstall v0.11.0 is already installed'

View file

@ -84,7 +84,7 @@ jobs:
jq \
--argjson for_release '${{ toJSON(inputs.for_release) }}' \
--argjson matrix '${{ toJSON(matrix) }}' \
-nrf ci-scripts/compile-settings.jq \
-nrf .github/scripts/compile-settings.jq \
| tee -a $GITHUB_ENV
- name: Configure caching
@ -107,7 +107,7 @@ jobs:
- name: Install deps
if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' && !startsWith(github.ref, 'refs/tags/v') }}
run: sudo ./ci-scripts/install-deps.sh
run: sudo .github/scripts/install-deps.sh
- name: Build
run: ${{ env.CTOOL }} build ${{ env.CARGS }}

View file

@ -50,7 +50,7 @@ jobs:
- name: Test
shell: bash
run: ./ci-scripts/tests.sh ${{ matrix.bin }} ${{ runner.os }}
run: .github/scripts/tests.sh ${{ matrix.bin }} ${{ runner.os }}
env:
CARGO_HOME: /tmp/cargo-home-for-test/

View file

@ -62,7 +62,7 @@ jobs:
ecnef=$'\n```'
title='release: v${{ inputs.version }}'
body=$(sed 's/%version%/${{ inputs.version }}/g' ci-scripts/release-pr.txt)
body=$(sed 's/%version%/${{ inputs.version }}/g' .github/scripts/release-pr.txt)
gh pr create --title "$title" --body "$body" --base main --head "${{ env.branch_name }}" --label "release"
env:

View file

@ -20,13 +20,13 @@ jobs:
- uses: actions/checkout@v2
- name: Extract tag from commit message
id: version
run: ./ci-scripts/extract-tag-from-release-commit.sh
run: .github/scripts/extract-tag-from-release-commit.sh
- name: Extract release notes
id: notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPO: ${{ github.repository }}
run: ./ci-scripts/extract-release-notes.sh
run: .github/scripts/extract-release-notes.sh
tag:
needs: info
@ -61,7 +61,7 @@ jobs:
path: outputs/
- name: Pack archives
run: ./ci-scripts/pack-release-archives.sh
run: .github/scripts/pack-release-archives.sh
- name: Publish release
uses: softprops/action-gh-release@50195ba7f6f93d1ac97ba8332a178e008ad176aa

View file

@ -21,7 +21,7 @@ jobs:
- windows
runs-on: ${{ matrix.os }}-latest
name: on ${{ matrix.os }}
name: unit tests on ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
@ -44,7 +44,7 @@ jobs:
- name: Install deps
if: matrix.os == 'ubuntu'
run: sudo ./ci-scripts/install-deps.sh
run: sudo .github/scripts/install-deps.sh
- name: Test (Unix)
if: matrix.os != 'windows'