Commit graph

402 commits

Author SHA1 Message Date
github-actions[bot]
5b92b43a87
release: detect-targets v0.1.6 (#889)
chore: Release

Co-authored-by: github-actions <github-actions@github.com>
2023-03-12 20:15:31 +11:00
github-actions[bot]
45045041a4
release: binstalk-types v0.3.0 (#887)
chore: Release

Co-authored-by: github-actions <github-actions@github.com>
2023-03-12 08:18:34 +00:00
Jiahao XU
00b8a417e6
Update doc for --github-token (#886) 2023-03-11 23:46:14 +11:00
Jiahao XU
3e0d7363a5
Read from env GH_TOKEN for github_token as a fallback (#883)
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-03-11 18:10:40 +11:00
Félix Saparelli
ff5276f4f4
Squash lint warning on windows (#881)
Squash warning on windows
2023-03-11 19:17:50 +13:00
Jiahao XU
c5d0b84aa6
Perform startup/init code eagerly in entry::install_crates (#880)
The startup/init code in `entry::install_crates` performs a lot of blocking operations, from testing if dir exists to reading from files and there is no `.await` in there until after the startup.

There are also a few cases where `block_in_place` should be called (e.g. loading manifests, loading TLS certificates) but is missing.

Most of the `Args` passed to `entry::install_crates` are actually consumed before the first `.await` point, so performing startup/init code eagerly would make the generated future much smaller, reduce codegen and also makes it easier to optimize.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-03-11 15:06:46 +11:00
Jiahao XU
a22cb3a332
Fix x86_64 fallback for aarch64 MacOS (#875) 2023-03-10 22:09:16 +11:00
dependabot[bot]
cfbdf1181f
Bump serde from 1.0.153 to 1.0.154 (#874) 2023-03-09 02:35:50 +00:00
dependabot[bot]
f5c30c2f8c
Bump serde from 1.0.152 to 1.0.153 (#873) 2023-03-08 02:37:38 +00:00
Jiahao XU
ecd599bfa8
Verify syntax of the github token provided in GhApiClient::new (#870)
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-03-07 18:48:01 +11:00
dependabot[bot]
174b6c8144
Bump file-format from 0.14.0 to 0.15.0 (#872) 2023-03-07 02:44:31 +00:00
Jiahao XU
72789874f0
Use Quickinstall new release schema (#867)
- Refactor: Extract new fn `binstalk::helpers::remote::does_url_exist`
 - Use new quickinstall release schema in `binstalk::fetchers::QuickInstall`
 - Optimize `fetchers::QuickInstall`: Generate url once in `Fetcher::new`
    Avoid repeated string allocation plus `Url` parsing.
    This also makes changing package_url and stats_url easier.
 - Optimize `QuickInstall::report`: Use HEAD instead of GET

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-03-06 08:13:08 +00:00
Jiahao XU
01c8ecb778
Fix zip extraction and bins::infer_bin_dir_template (#869)
- Fix zip extraction code: Ensure dir is rwx and file is readable for curr user
 - Add more integration test for `ExtractedFiles`
 - Fix `bins::infer_bin_dir_template` introduced in #856

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-03-06 17:54:31 +11:00
dependabot[bot]
460522f5bd
Bump thiserror from 1.0.38 to 1.0.39 (#865) 2023-03-06 03:45:37 +00:00
dependabot[bot]
eff8a50d13
Bump command-group from 2.0.1 to 2.1.0 (#864) 2023-03-06 03:36:02 +00:00
dependabot[bot]
a6a42f30af
Bump async-trait from 0.1.64 to 0.1.66 (#866) 2023-03-06 03:16:31 +00:00
dependabot[bot]
7f00d803f7
Bump gh-token from 0.1.0 to 0.1.1 (#863) 2023-03-06 03:14:41 +00:00
dependabot[bot]
1f18deb142
Bump serde_json from 1.0.93 to 1.0.94 (#862)
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.93 to 1.0.94.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.93...v1.0.94)

---
updated-dependencies:
- dependency-name: serde_json
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-06 14:01:17 +11:00
Félix Saparelli
ee909e4045
Rename --roots to --root (with alias for back compat) (#861)
Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-03-06 01:05:32 +00:00
Jiahao XU
44e81c7e1a
Fix: Pass value of --roots to cargo-install as --root (#860)
Pass value of `--roots` to `cargo-install` as `--root`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-03-06 11:52:28 +11:00
Jiahao XU
9c7da6a179
Return a list of files written to disk in binstalk_downloader::download::Download::and_extract (#856)
to avoid collecting extracted files from disk again in resolution stage.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-03-03 23:31:27 +11:00
Jiahao XU
44ac63ce0d
Extract GitHub token from file if --github-token or env variable GITHUB_TOKEN is not present (#849)
- Add option `--no-discover-github-token` for disabling this behavior
 - Add new dep gh-token v0.1.0 to crates/bin
 - Extract github-token from git-credentials or gh config if `--github-token` or
    environment variable `GITHUB_TOKEN` is not present.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-03-03 17:32:50 +13:00
Jiahao XU
75289cc2b4
Only use GET in remote::Client::remote_gettable (#847)
Fixed #835

Using `HEAD` for this would often cause false negative that requires the `Client` to fallback to `GET`, which creates a lot of requests even if the url doesn't exist and then get cargo-binstall rate limited by GitHub/GitLab/etc.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-03-03 13:29:58 +11:00
Jiahao XU
8eee318ccd
Replace dep crates_io_api with in-house solution (#846)
It also uses `max_stable_version` in the json downloaded from https://crates.io/api/v1/crates/$name if possible, which is equivalent to the version shown on https://crates.io/crates/$name .

 - Add new feat `json` to `binstalk-downloader`
 - Impl new async fn `Response::json`
 - use `Response::json` in `GhApiClient` impl
 - Mark all err types in binstalk-downloader as `non_exhaustive`
 - Ret `remote::Error` in `remote::Certificate::{from_pem, from_der}` instead of `ReqwestError`.
 - Refactor `BinstallError`: Merge variant `Unzip`, `Reqwest` & `Http`
    into one variant `Download`.
 - Manually download and parse json from httos://crates.io/api/v1
 - Remove unused deps `crates_io_api`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-03-02 18:25:34 +11:00
dependabot[bot]
c00d648dac
Bump jobslot from 0.2.9 to 0.2.10 (#844) 2023-03-02 05:19:38 +00:00
dependabot[bot]
fcbdfcf04f
Bump tokio from 1.25.0 to 1.26.0 (#843) 2023-03-02 03:02:43 +00:00
Jiahao XU
599bcaf333
Impl GhApiClient and use it in cargo-binstall to speedup resolution process (#832)
Fixed #776

 - Add new feature gh-api-client to binstalk-downloader
 - Impl new type `binstalk_downloader::remote::{RequestBuilder, Response}`
 - Impl `binstalk_downloader::gh_api_client::GhApiClient`, exposed if `cfg(feature = "gh-api-client")` and add e2e and unit tests for it
 - Use `binstalk_downloader::gh_api_client::GhApiClient` to speedup `cargo-binstall`
 - Add new option `--github-token` to supply the token for GitHub restful API, or read from env variable `GITHUB_TOKEN` if not present.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-03-02 12:04:22 +11:00
dependabot[bot]
263c836757
Bump clap from 4.1.7 to 4.1.8 (#840) 2023-03-01 02:35:26 +00:00
dependabot[bot]
5b70e41966
Bump clap from 4.1.6 to 4.1.7 (#837) 2023-02-28 04:35:43 +00:00
dependabot[bot]
e13354e8fa
Bump tempfile from 3.3.0 to 3.4.0 (#834) 2023-02-27 03:35:21 +00:00
dependabot[bot]
fd0166e31b
Bump jobslot from 0.2.8 to 0.2.9 (#833) 2023-02-27 03:29:16 +00:00
dependabot[bot]
809c8e9cad
Bump toml_edit from 0.19.3 to 0.19.4 (#831) 2023-02-23 13:29:33 +11:00
Jiahao XU
96ebcfd08f
Add new option --locked that is passed through to cargo-install (#830)
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-02-22 22:27:17 +11:00
dependabot[bot]
0e055dbb7c
Bump async_zip from 0.0.9 to 0.0.12 (#824) 2023-02-22 08:47:47 +00:00
dependabot[bot]
8f50bab0d8
Bump compact_str from 0.6.1 to 0.7.0 (#825)
Bumps [compact_str](https://github.com/ParkMyCar/compact_str) from 0.6.1 to 0.7.0.
- [Release notes](https://github.com/ParkMyCar/compact_str/releases)
- [Changelog](https://github.com/ParkMyCar/compact_str/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ParkMyCar/compact_str/commits)

---
updated-dependencies:
- dependency-name: compact_str
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-22 17:55:18 +11:00
Jiahao XU
7bc4d4a5c6
Add opt --root-ceritificates & env BINSTALL_HTTPS_ROOT_CERTS (#820)
for specifying root ceritificates used for https connnections.

And remove old environment variable `CARGO_HTTP_CAINFO`, `SSL_CERT_FILE`
and `SSL_CERT_PATH` to avoid accidentally setting them, especially in CI
env.

Also:
 - Rm fn `binstalk_downloader::Certificate::from_env`
 - Enable feature `env` of dep `clap` in `crates/bin`
 - Add new dep `file-format` v0.14.0 to `crates/bin`
 - Use `file-format` to determine pem/der file format when loading root certs
 - Rm fn `binstalk_downloader::Certificate::open` and enum `binstalk_downloader::OpenCertificateError`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-02-20 20:48:33 +11:00
dependabot[bot]
467ba0d854
Bump cargo_toml from 0.15.1 to 0.15.2 (#819)
Bumps [cargo_toml](https://gitlab.com/crates.rs/cargo_toml) from 0.15.1 to 0.15.2.
- [Release notes](https://gitlab.com/crates.rs/cargo_toml/tags)
- [Commits](https://gitlab.com/crates.rs/cargo_toml/compare/v0.15.1...v0.15.2)

---
updated-dependencies:
- dependency-name: cargo_toml
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-20 14:33:12 +11:00
Jiahao XU
3f0107696b
Enable cross-lang-fat-lto on Linux (#817)
Fixed #806

 - Add new feature flag `cross-lang-fat-lto` and enable it on release for linux
 - Enable `-C linker-plugin-lto` for linux
 - Only use `-Z gcc-ld=lld` on non-windows targets when `cargo-zigbuild` is not enabled

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-02-19 15:19:35 +11:00
dependabot[bot]
69a1c26951
Bump clap from 4.1.4 to 4.1.6 (#813) 2023-02-16 02:29:06 +00:00
Jiahao XU
2e118b3044
Optimize GhCrateMeta::find: Cache url resolution result (#810)
So that we don't have to create multiple HEAD/GET http request to get
the final, redirected url.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-02-16 14:51:47 +13:00
Jiahao XU
89b920a876
Inc default interval in --rate-limit to 10ms (#804)
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-02-15 19:07:25 +13:00
Jiahao XU
9874dca454
Fix bin names in .crates.toml on win (#802)
`bins::BinFile::new` does not include `binary_ext` in the
`BinFile::base_name`.

Also add regression e2e-test.

Fixed #801

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-02-15 17:24:50 +13:00
dependabot[bot]
30f7722131
Bump once_cell from 1.17.0 to 1.17.1 (#803) 2023-02-15 02:39:44 +00:00
Jiahao XU
1e49460ac7
Fix use of StreamReadable: Ensure no empty Bytes (#799)
which would cause the `StreamReadable` to return eof even if the
underlying stream is still open and has not sent EOF yet.

Fixed #777

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-02-15 12:01:14 +11:00
Jiahao XU
9635e05d6c
Support adding root cert via env CARGO_HTTP_CAINFO, SSL_CERT_{FILE, PATH} (#774)
* Support for custom root cert in `binstalk_downloader::remote::Client`
* Support adding root cert via env `CARGO_HTTP_CAINFO`, `SSL_CERT_{FILE, PATH}`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-02-15 11:33:59 +13:00
Jiahao XU
3fffe39635
Document environment variable BINSTALL_LOG_LEVEL (#798)
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-02-13 06:26:16 +00:00
dependabot[bot]
28415f7927
Bump tokio-util from 0.7.6 to 0.7.7 (#797)
Bumps [tokio-util](https://github.com/tokio-rs/tokio) from 0.7.6 to 0.7.7.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-util-0.7.6...tokio-util-0.7.7)

---
updated-dependencies:
- dependency-name: tokio-util
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-13 17:14:15 +11:00
Jiahao XU
7c15dd2052
Revert "Read log_level from env CARGO_BINSTALL_LOG_LEVEL if arg not present" (#796)
This reverts commit e84228ba01.
2023-02-13 15:31:15 +11:00
Jiahao XU
04113e9dd9
Rm NOVERSION_FILENAMES "{ name }{ archive-suffix }" (#795)
which does not contain `target`, hence it might report the binary being
available for any target we specified.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-02-13 13:44:24 +11:00
Jiahao XU
87686cb2f7
Feature: Better retry policy in binstalk-downloader (#794)
Fixed #779 #791 

 - Retry request on timeout
 - Retry for `StatusCode::{REQUEST_TIMEOUT, GATEWAY_TIMEOUT}`
 - Add `DEFAULT_RETRY_DURATION_FOR_RATE_LIMIT` for 503/429
   if 503/429 does not give us a header or give us an invalid header on
   when to retry, we would default to
   `DEFAULT_RETRY_DURATION_FOR_RATE_LIMIT`.
 - Fix `Client::get_redirected_final_url`: Retry using `GET` on status code 400..405 + 410
 - Rename remote_exists => remote_gettable & support fallback to GET
   if HEAD fails due to status code 400..405 + 410.
 - Improve `Client::get_stream`: Include url & method in the err of the stream returned

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-02-13 13:43:48 +11:00