Commit graph

125 commits

Author SHA1 Message Date
David Laban
c8dec953cc
report to new stats server (with status) (#1912)
* docstrings for things that I was curious about

* report to new stats server, with status

* Arc<Self> needs a clone

* fix stats url in docs

* fix stats url handling
2024-09-11 08:15:15 +00:00
Jiahao XU
a53d51c083
Send telemetry report to quickinstall if no pre-built is found (#1905)
* Send telemetry report to quickinstall if no pre-built is found

quickinstall telemtry is overloaded cargo-bins/cargo-quickinstall#268, it only needs report when the pre-built is not available in upstream.

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>

* Fix resolve.rs

And optimize sending telemtry: Remove unnecessary `<Arc as Clone>::clone`

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>

* Fix fmt of resolve.rs

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>

---------

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>
2024-09-05 14:43:38 +00:00
Jiahao XU
52f2db4f57
Add --maximum-resolution-timeout (#1862)
* Add --maximum-resolution-timeout

Fixed #1823

* Display default value for `--maximum-resolution-timeout` in help
2024-08-04 02:13:18 +00:00
Jiahao XU
6809601273
Add new option to --disable-telemetry to disable quickinstall statistics collection (#1831)
* Add new option `--disable-quick-install-stats`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Send quickinstall stats in parallel

This commit also make sure'the stats is always sent for
each fetcher, regardless of whether it is picked or not,
to make sure that the quick-install stats collection gets
the full infomration of possible targets.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Rename option to `--disable-telemetry`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Update args.rs

Co-authored-by: Félix Saparelli <felix@passcod.name>
Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>

* Update args.rs

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>

---------

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>
Co-authored-by: Félix Saparelli <felix@passcod.name>
2024-07-26 06:03:38 +00:00
Jiahao XU
3f29fbe83a
Feature: SupportdDisable of strategies for crate using Cargo.toml (#1828)
* Refactor: Move `Strategy` to `binstalk-types`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Add serialisation test for `Strategy`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Add support to disable strategies via crate `Cargo.toml`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Add e2e-test

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix `Cargo.toml` disabled strategy checking for compile strategy

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Optimize `resolve_inner`: Cache meta override

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Add compile-time length checking for `Strategy`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* More optimization

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix order of override: cli options alwayus takes precedence

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Add missing manifest for e2e-test

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

---------

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2024-07-23 14:05:22 +00:00
Jiahao XU
eba07fb147
Fix v1 manifest format for git and local path (#1821)
* Bump simple-git to v0.2.10

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix v1 manifest format for git and local path

Fixed #1815

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix v1 format for custom registry

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Remove unused functions

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix compilation

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Update git.sh

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>

* Fixed git.sh for windows

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>

* fixx git.sh for win

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>

* Update git.sh

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>

* fix git.sh

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>

---------

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>
2024-07-17 05:34:12 +00:00
Jiahao XU
ac7bac651d
Run artifact discover in sequential instead of in parallel (#1796)
* Perform artifact discovery in sequential

Run different `fetcher.find()` in sequential

* FuturesResolver: Fallback to other future if one error

* Fix typo

* Apply cargo fmt

* Parallelise `<QuickInstall as Fetcher>::find`

Check for signature in parallel to the package

* Download signature in `<QuickInstall as Fetcher>::find`

So that the signature download can be done in parallel.

* Bump msrv for binstalk-fetchers to 1.70

* Update crates/binstalk-fetchers/src/futures_resolver.rs

Co-authored-by: Félix Saparelli <felix@passcod.name>
Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>

* cargo fmt

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

---------

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Co-authored-by: Félix Saparelli <felix@passcod.name>
2024-06-23 10:42:03 +00:00
Jiahao XU
fff6aa8122
Improve use of github token (#1769)
* Add new dep zeroize

* Use Zeroizing to avoid leaking the token

* Optimize gh-auth-token

Spawn it as a task, and only await it
when using GhApiClient

* Fix binstalk-git-repo-api unit tests
2024-06-15 05:42:09 +00:00
Jiahao XU
34cca9f415
Use io::Error::downcast in 1.79 (#1754)
* Bump msrv of binstalk-downloader, binstalk and cargo-binstall to 1.79

* Update From<io::Error> for DownloadError

to use io::Error::downcast

* Update From<io::Error> for BinstallError

* fix dmt
2024-06-14 08:00:53 +00:00
Tomas Olvecky
dfa230f039
Use binary name when searching for artifacts (#1747)
* Use binary name when searching for artifacts

When there is a single binary declared in the manifest and
it differs from the package name, add it to the list of handles
used for pre-built artifact fetching.

* Simplify `binary_name` assignment with a `match`

* Add e2e test

* Only attempt to use the binary name with `GhCrateMeta` fetcher

* Avoid too much over-allocating.

Technically it should also check if gh-crate-meta resolver is enabled, but it is unlikely for it to be disabled and overallocating for extra n-target should be fine, it is an improvement over doubling the space allocated if the binary_name is Some.

* Fix fmt in crates/binstalk/src/ops/resolve.rs

---------

Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>
2024-06-14 04:52:37 +00:00
Remo Senekowitsch
250814f530
fix(resolve): prefer official binaries (#1741)
* prefer official binaries with secondary targets over quickinstall binaries

* chore(test): add jj-cli to live e2e test
2024-06-13 18:26:30 +10:00
Jiahao XU
1dbd2460a3
Support private github repository (#1690)
* Refactor: Create new crate binstalk-git-repo-api

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix CI lint warnings

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix `just check`: Rm deleted features from `cargo-hack` check

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Refactor: Extract  new mod error

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Ret artifact url in `has_release_artifact`

So that we can use it to download from private repositories.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Move `test_graph_ql_error_type` to mod `error`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix running `cargo test` in `binstalk-git-repo-api``

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Remove unnecessary import in mod `error::test`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Rename mod `request`` to `release_artifacts`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Impl draft version of fetching repo info

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Refactor: Move `HasReleaseArtifacts` failure variants into `GhApiError`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Refactor: Use `GhRepo` in `GhRelease`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix testing

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Refactor: Return `'static` future

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Refactor: Make sure `'static` Future is returned

To make it easier to create generic function

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Add logging to unit testing

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix unit testing

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Refactor: Extract new fn `GhApiClient::do_fetch`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Rm unused `percent_encode_http_url_path`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix `cargo test` run on CI

`cargo test` run all tests in one process.

As such, `set_global_default` would fail on the second call.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Optimize `GhApiClient::do_fetch`: Avoid unnecessary restful API call

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Refactor: Rm param `auth_token` for restful API fn

which is always set to `None`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Impl new API `GhApiClient::get_repo_info`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix unit test for `GhApiClient::get_repo_info`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Refactor testing: Parameter-ize testing

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Parallelise `test_get_repo_info`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Refactor: Create parameter-ised `test_has_release_artifact`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Parallelize `test_has_release_artifact`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Refactor: `gh_api_client::test::create_client` shall not be `async`

as there is no `.await` in it.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Return `Url` in `GhApiClient::has_release_artifact`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Impl new API `GhApiClient::download_artifact`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Remove unused deps added to binstalk-git-repo-api

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix clippy lints

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Add new API `GhApiClient::remote_client`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Add `GhApiClient::has_gh_token`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Add `GhRepo::try_extract_from_url`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Rename `ReleaseArtifactUrl` to `GhReleaseArtifactUrl`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Add new fn `Download::with_data_verifier`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* feature: Support private repository

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix clippy lints

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Add e2e-test/private-github-repo

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix clippy lints

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix `launch_baseline_find_tasks`: Retry on rate limit

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix test failure: Retry on rate limit

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Temporarily enable debug output for e2e-test-private-github-repo

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix `get_repo_info`: Retry on rate limit

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Improve `debug!` logging

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Add more debug logging

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Add more debugging

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Add more debug logging

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Apply suggestions from code review

* Fix compilation

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix cargo fmt

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Add crate binstalk-git-repo-api to release-pr.yml

* Update crates/binstalk-git-repo-api/Cargo.toml

* Apply suggestions from code review

* Update crates/binstalk/Cargo.toml

---------

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2024-06-10 06:02:12 +00:00
Ilkka Poutanen
6dd4a155fb
Typo fix (#1631) 2024-02-23 11:21:05 +00:00
FlareFlo
857a2caf34
Fix missing spaces in error log (#1577) 2024-01-19 02:20:37 +00:00
Jiahao XU
c08b8d232a
feat: Impl new option --continue-on-failure (#1559)
* feat: Impl new option `--continue-on-failure`

Resolve #1548

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Add new e2e-tests continue-on-failure

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Rm dup line ion `e2e-tests/live.sh`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix shellcheck

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix `BinstallError::crate_errors` if `errors.len()` is 1

In that case, it should return `Some(Self::CrateContext(_))` instead of
`Some(Self::Errors(_))`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Add more tests to `e2e-tests/continue-on-failure.sh`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Propagate crate errors on `confirm()` err

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Test having two errors in `e2e-tests/continue-on-failure.sh`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

---------

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2024-01-08 12:09:45 +00:00
Jiahao XU
8e08c65946
Fix fallback to cargo-install: Use the default target unless user override (#1430)
* Fix fallback to `cargo-install`: Use the default target

which is guaranteed to work, instead of providing a custom `--target`
from `detect-targets`.

The one from `detect-targets` might report musl even if the `rustc`
reports gnu, since OSes like NixOS could use a custom glibc location
that prevent glibc binaries built for other OSes be run for them.

However, if we are compiling the crate and `rustc` defaults to glibc,
then it should be guaranteed to work.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Impl fn `DesiredTargets::get_initialized`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix fallback to `cargo-install`: Use user-provided override targets

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

---------

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-09-30 00:22:21 +00:00
Félix Saparelli
680accd0d3
Check quickinstall signatures (#1382)
* Check quickinstall signatures

* e2e test

* We can no longer check presence of signing section early

* Improve UI a little
2023-09-23 08:35:49 +00:00
Félix Saparelli
32beba507b
Initial signing support (#1345)
* Add CLI options

* Add manifest types

* Thread signature policy through to fetchers

* Thread signing section through from metadata

* Implement signing validation

* Clippy

* Attempt testing

* Yes and

* Why

* fmt

* Update crates/bin/src/args.rs

Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>

* Update crates/binstalk-fetchers/src/gh_crate_meta.rs

Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>

* Update crates/bin/src/args.rs

Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>

* Update crates/binstalk-fetchers/src/signing.rs

Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>

* Update crates/binstalk-fetchers/src/signing.rs

Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>

* Update crates/binstalk-fetchers/src/signing.rs

Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>

* Update crates/binstalk-fetchers/src/signing.rs

Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>

* fixes

* Finish feature

* Document

* Include all fields in the signing.file template

* Readme document

* Review fixes

* Fail on non-utf8 sig

* Thank goodness for tests

* Run test in ci

* Add rsign2 commands

* Log utf8 error

* Update e2e-tests/signing.sh

Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix `e2e-tests/signing.sh` MacOS CI failure

Move the tls cert creation into `signing.sh` and sleep for 10s to wait
for https server to start.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Refactor e2e-tests-signing files

 - Use a tempdir generated by `mktemp` for all certificates-related
   files
 - Put other checked-in files into `e2e-tests/signing`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fixed `e2e-tests-signing` connection err in MacOS CI

Wait for server to start up by trying to connect to it.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix `e2e-tests-signing` passing `-subj` to `openssl` on Windows

Use single quote instead of double quote to avoid automatic expansion
from bash

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix `e2e-tests-signing` waiting for server to startup

Remove `timeout` since it is not supported on MacOS.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Try to fix windows CI by setting `MSYS_NO_PATHCONV=1` on `openssl` cmds

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fixed `e2e-tests-signing` on windows

By using double `//` for the value passed to option `-subj`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fixed infinite loop in `signing/wait-for-server` on Windows

Pass `--ssl-revoke-best-effort` to prevent schannel from checking ssl
revocation status.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Add cap on retry attempt in `signing/wait-for-server.sh`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Let `singing/server.py` print output to stderr

so that we can see the error message there.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix running `signing/server.py` on MacOS CI

use `python3` since macos-latest still has python2 installed and
`python` is a symlink to `python2` there.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

---------

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-09-23 04:02:56 +00:00
Jiahao XU
3c5641610a
feat: Improve resolution logging and verbose logging (#1341)
* feat: Improve resolution logging

Fixed #1336

Log target of the pre-built binaries which will be installed.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix args parsing: `quiet` & `verbose` cannot be set at the same time

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* feat: Implies `--log-level debug` if `--verbose` is set

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

---------

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-09-02 09:38:24 +00:00
Jiahao XU
e5567ae526
Fix clippy lint and format (#1328)
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-08-25 08:53:50 +00:00
Jiahao XU
dc77a1ab93
Refactor: Extract new crate simple-git (#1304)
`binstalk-downloader` contains stuff about http(s) before the
git code is moved into it and now it becomes http and git.

While git indeed uses http stuff, which is why I decided to put
it into binstalk-downloader, it is more than just downloading
since it is stateful (can be cached locally and updated)
where as http is stateless.

Also `binstalk-downloader`'s codegen time now increases
dramatically and it also creates extra dependencies for
binstalk-fetchers, delaying its execution.

The git code also don't use anything from `binstalk-downloader`
at all, it makes sense to be an independent crate.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-08-19 01:08:55 +00:00
Jiahao XU
0f7828569a
Add error logging if achieve doesn't contain bin required (#1298)
* Add `error` logging if achieve doesn't contain bin required

So that users know that this is an upstream issue and will report to
upstream.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Update crates/binstalk/src/ops/resolve.rs

---------

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-08-16 23:13:21 +00:00
Jiahao XU
0c5a65fb35
Refactor: Extract new crate binstalk-bins (#1294)
To reduce `binstalk` codegen and enable reuse of it.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-08-15 21:48:42 +00:00
Jiahao XU
76c72469eb
Refactor: Extract new crate binstalk-fetchers (#1291)
To reduce `binstalk` codegen and enable better reuse.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-08-14 03:20:34 +00:00
Jiahao XU
623f7ff4ed
Refactor: Extract new crate binstalk-registry (#1289)
To speedup codegen of `binstalk` and enable it to be reused.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-08-13 07:16:53 +00:00
Jiahao XU
2375ba48b6
Refactor to reduce compilation time (#1284)
- Make `binstalk::bins` private.
 - Move mod `signal` into `crates/bin`
 - Make items in `crates/bin/src/lib.rs` private if possible to reduce
   its API generation time.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-08-12 14:25:41 +00:00
Jiahao XU
fbed317df5
feat: git::Repository cancellation support (#1288)
feat: `git::Repository` support cancellation.

To make sure users can cancel git operation via signal, e.g. when the
git operation fail or users no longer want to install.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-08-12 14:18:02 +00:00
Jiahao XU
ef99dd795f
Refactor: Extract mod fs as crate atomic-file-install (#1286)
Refactor: Extract mod `fs` as crate `atomic-install`

To speedup codegen of `binstalk` and also publish a new crate that could
be reused.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-08-12 13:24:26 +00:00
Jiahao XU
8ff13c1b36
Refactor: Extract cargo_toml_workspace as a new crate (#1287)
To reduce codegen time of `binstalk` and also enable others to reuse
this crate.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-08-12 12:05:10 +00:00
Jiahao XU
c57356e870
Refactor: Move mod git into binstalk-downloader (#1285)
To speedup codegen time for `binstalk`, also fixed the docs.rs build for
`binstalk-downloader`.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-08-12 07:20:26 +00:00
Jiahao XU
3e80b12748
feat: Verify cksum of crate tarball from cargo registry (#1260)
Fixed #1183

Since the crate tarball could be downloaded from a different set of
servers than where the cargo registry is hosted, verifying the checksum
is necessary to verify its integrity.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-08-09 10:57:47 +00:00
Jiahao XU
7f1ddd1dd7
Reduce public interface of binstalk (#1265)
To reduce amount of breaking changes.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-08-09 07:46:12 +00:00
Jiahao XU
435df675b3
Fix too many 429 response (#1231)
Fixed #1229

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-08-08 00:53:15 +00:00
Jiahao XU
812fb9b0af
Fix subcrate resolution for wasm-bindgen-cli (#1245)
Fixed #1244

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-08-03 21:14:36 +00:00
Jiahao XU
aeacebcf83
feat: Support passing workspace to --manifest-path (#1246)
Previously it will load the root `Cargo.toml` and treat it as the
manifest for the crate, now it will check its `package.name` and would
search for the workspace if the `package.name` does not match the crate
name.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-08-03 21:12:06 +00:00
dependabot[bot]
ec494261c6
build(deps): update gix requirement from 0.49.1 to 0.50.0 in /crates/binstalk (#1230)
build(deps): update gix requirement in /crates/binstalk

Updates the requirements on [gix](https://github.com/Byron/gitoxide) to permit the latest version.
- [Release notes](https://github.com/Byron/gitoxide/releases)
- [Changelog](https://github.com/Byron/gitoxide/blob/main/CHANGELOG.md)
- [Commits](https://github.com/Byron/gitoxide/compare/gix-v0.49.1...gix-v0.50.0)

---
updated-dependencies:
- dependency-name: gix
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-24 07:13:55 +00:00
Jiahao XU
306f761973
Fix failure to send quickinstall report (#1224)
Fixed #1222 by fetching lists of supported targets from quickinstall
repository.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-07-21 05:41:09 +00:00
Jiahao XU
0c5b7f115d
feat: Support --verbose --version/-vV (#1182)
that provides more information:

```
cargo-binstall: 1.0.0
build-date: 2023-07-18
build-target: aarch64-apple-darwin
build-features: default,fancy_no_backtrace,git,rustls,static,trust_dns,zstd_thin
build-commit-hash: 39d8cfc07f2253080ce997e620406c2994dced25
build-commit-date: 2023-07-18
rustc-version: 1.71.0
rustc-commit-hash: 8ede3aae28fe6e4d52b38157d7bfe0d3bceef225
rustc-llvm-version: 16.0
```

Fixed #627

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-07-18 05:22:41 +00:00
Sebastian Thiel
5acfda9379
avoid worktree checkouts (#1207)
* perform a bare git cloen to avoid worktree checkouts

This will be way faster on windows

* feat: use the git repository directly to obtain crate information

* Apply code review changes

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Impl `fmt::Display` for `helpers::git::GitUrl`

and also refactor implementation of `git::Repository::{shallow_clone,
shallow_clone_bare}`.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix clippy lint warnings

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix typo

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

---------

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-07-17 15:46:12 +00:00
Jiahao XU
963e9e97ad
Use reflink_copy::reflink_or_copy in fs::atomic_install* (#1197)
to speedup copy operation `atomic_install*`.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-07-17 11:56:10 +10:00
Jiahao XU
7dea40a99a
Support --registry and more options from .cargo/config.toml (#1195)
Fixed #885

Now we can take advantage of new argument `--registry` and
env overrides:
 - `CARGO_REGISTRIES_DEFAULT` if `--registry` is not specified
 - `CARGO_REGISTRIES_{registry_name}_INDEX` for the registry index url

We can also read from `.cargo/config.toml` for:
 - default registry and registries configurations
 - additional CA bundle `http.cainfo`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-07-10 03:37:41 +00:00
Jiahao XU
01a87ac606
feat: Impl support for alternative registries (#1184)
Fixed #1168

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-06-30 03:52:40 +00:00
Jiahao XU
ca00cbaccc
feat: Support install directly from git repo (#1162)
Fixed #3

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-06-24 01:01:31 +00:00
Jiahao XU
138112cd6e
Optimize TargetTriple: Use Cow<'static, str> (#1161)
instead of `CompactString` since `target_lexicon::{OperatingSystem,
Architecture, Environment}::into_str()` will return a `&'static str`
most of the time.

Also updated `SUPPORT.md`.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-06-21 10:05:19 +00:00
Jiahao XU
d8419ea5a2
feat: Add more variables for template (#1160)
Fixed #775

 - Add dep target-lexicon v0.12.7
 - Add `target-{family, arch, libc, vendor}` to
   `package.metadata.binstall`.

For `{universal, universal2}-apple-darwin`, the `target-arch` is set to
`universal`.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-06-20 22:05:13 +00:00
Jiahao XU
22b3419fce
feat: Add GraphQL support to GhApiClient (#1124)
Fixed #868

 - Add new fn `remote::Client::post`
 - Add new fn `remote::RequestBuilder::body`
 - Re-export `reqwest::Body` in `remote`
 - Add dep percent-encoding v2.2.0 to binstalk-downloader
 - Add dep serde-tuple-vec-map v1.0.1 to binstalk-downloader
 - Add GraphQL to `GhApiClient`, fallback to Restful API if token is not
   provided or authorization failed.
 - Fixed `GhReleaseArtifact::try_extract_artifact_from_str`: decode
   percent encoded http url path and add regression tests
 - Added variant `GhApiError::Context` & `GhApiContextError`
 - Added variant `GhApiError::GraphQLErrors` & `GhGraphQLErrors`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-06-04 14:09:49 +00:00
Jiahao XU
1432093dcc
feat: Add new cmdline option --no-track (#1111)
Same as `cargo-install`'s `--no-track`.
It is also passed to `cargo-install` if it is invoked.

Also fixed `fs::atomic_symlink_file` which on Windows could fallback to
non-atomic install if symlinking failed.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-06-03 09:15:18 +00:00
Jiahao XU
e96477a116
Optimize fetch_crate_cratesio for exact version (#1089)
If `version_req` requests a specific version instead of a range, then
there is no need to pull all versions available from
https://crates.io/api/v1/crates

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-05-25 12:56:31 +00:00
Jiahao XU
0261d12d9d
Support subcrate in repo (#991)
Fixed #838

 - Add new key `subcrate` for rendering `pkg-url`
 - Add new release paths in GitHub, GitLab & SourceForge using key `subcrate` for auto-detection
 - Add subcrate detection for GitHub and GitLab
 - Add `debug!` when using gh api token in `GhApiClient::new`
 - Add subcrate testing to `e2e-tests/subcrate.sh`
 - Bump cargo-release to 0.24.9 in e2e-tests/live.sh
   to fix test failure on MacOS without libssl installed in `/usr/local/`.
 - Optimize GhCrateMeta: Detect subcrate and repo-host in `Data::get_repo_info`
    to cache the result and avoid duplicate works, this also makes the code
    more ergonomic by removing the need to some `unwrap()` plus making it
    more efficient since we don't need to clone the url just to modify it.
 - Add instrument to `Data::get_repo_info`
 - Fix `shellcheck` err in `e2e-tests/*.sh`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-04-24 19:41:20 +10:00
Jiahao XU
5683ca2476
Add new crate leon-macros that provide template! with identical syntax as runtime parsing (#946)
`leon_macros::template!` can parse template at compile-time.
It accepts a utf-8 string literal and uses `leon` internally to parse it, then generate code that evaluates to `Template<'static>`.

 - Exclude fuzz from crate leon when publishing
 - Impl fn-like proc-macro `leon_macros::template!`
 - Add dep `leon-macros` to binstalk
 - Use `leon_macros::template!` in `binstalk::fetchers::gh_crate_meta::hosting`
 - Add doc for `leon-macros` in `leon`
 - Improve `std::fmt::Display` impl for `leon::ParseError`
 - Fixed broken infra link in leon

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-04-17 14:50:58 +10:00