Commit graph

201 commits

Author SHA1 Message Date
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
Jiahao XU
35b32c43e0
Run release-build.yml unconditionally for consistency & inc cache hits (#982)
Since it is run on PR anyway, we should also run it on main just in case
it fails, i.e. merging of PRs without rebasing against main to test out
latest changes.

It will now also be run on draft PR so that they can test out the
changes and find out bugs before making it ready to review.

This change will also increase cache hits on PR, thus speeding up the CI.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-04-06 18:08:14 +10:00
Jiahao XU
f134df548d
Optimize release-build.yml: Avoid building benchmark dependencies (#981)
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-04-06 16:19:15 +10:00
Jiahao XU
f384088fd1
Avoid checking dev-deps for jobs *-check and lint in workflow ci.yml (#978)
Avoid checking dev-deps for jobs `*-check` and lint in workflow `ci.yml`

We just want to make sure cargo-binstall can compile for the target, we
don't want to pull in the extra dependencies.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-04-04 01:51:13 +10:00
Jiahao XU
8dd7aa5688
Speedup ci.yml: Do not run tests on x86_64-unknown-linux-musl (#976)
Speedup ci.yml: Do not run tests on x86_64-unknown-linux-musl

Since we already run test on x86_64-unknown-linux-musl in
release-build.yml and x86_64-unknown-linux-musl is almost identical to
x86_64-unknown-linux-gnu except for the libc, there's no need to run the
tests in ci.yml

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-04-04 01:40:26 +10:00
Jiahao XU
24634b2de1
Speedup workflow lipo in release-build.yml (#975)
Speedup workflow lipo in release-build

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-04-04 01:40:13 +10:00
Jiahao XU
6a224da9ee
Run unit tests in release-build.yml (#977)
Since release build enables a lot of optimization, disable debug assert
and possibly change the code to be run, it's better to run the tests
again.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-04-04 01:40:01 +10:00
Jiahao XU
a403c99d3f
Upgrade CI to use sccache v0.4.0 for caching (#934)
Remove `mozilla-actions/sccache-action@v0.0.2` and instead use `taiki-ie/install-action` to install `sccache`, since we already use `taiki-e/install-action` for installing crates.

This PR also refactor just-setup.yml and use pass `GITHUB_TOKEN` to `taiki-e/install-action` which uses `cargo-binstall` for installing `cargo-auditable` and `sccache`.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-03-26 17:28:35 +11:00
Jiahao XU
47d4aeaa96
Run cache-cleanup at 3am & 4:30am AEST instead of after every PR (#944)
since cache-cleanup will issue a lot of gh api requests, running the
workflow right after the PRs would cause the GH API to rate limit all
workflows (including our CI for testing and release) that they can no
longer upload artifacts and `cargo-binstall` would have to fallback to
sending GET requests instead of using GH API, which makes it a lot
slower and more likely to fail.

This PR changes it to be run at 3am and 4:30am AEST which nobody would submit
any PR at that time and then remove all caches of the top 20 closed prs.

The workflow can also now be triggered manually.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-03-23 18:10:30 +11:00
Jiahao XU
9a59119163
Fully remove all caches for PR in cache-cleanup.yml (#942)
Previously it only removes 30 caches for the PR because gh actions-cache list defaults to only listing 30 cache entries.

In this PR, I changed the limit to the maximum allowed 100 cache entries and I also added a loop to keep getting the next 100 cache entries until there is none.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-03-23 02:50:13 +13:00
Félix Saparelli
2227d363f7
Leon template library (#766)
* leon: first implementation

* Update crates/leon/src/values.rs

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

* Workaround orphan rules to make API more intuitive

* Fmt

* Clippy

* Use CoW

* Use cow for items too

* Test that const construction works

* leon: Initial attempt at O(n) parser

* leon: finish parser (except escapes)

* leon: Improve ergonomics of compile-time templates

* Document helpers

* leon: Docs tweaks

* leon: Use macro to minimise parser tests

* leon: add escapes to parser

* leon: test escapes preceding keys

* leon: add multibyte tests

* leon: test escapes following keys

* Format

* Debug

* leon: Don't actually need to keep track of the key

* leon: Parse to vec first

* leon: there's actually no need for string cows

* leon: reorganise and redo macro now that there's no coww

* Well that was silly

* leon: Adjust text end when pushing

* leon: catch unbalanced keys

* Add error tests

* leon: Catch unfinished escape

* Comment out debugging

* leon: fuzz

* Clippy

* leon: Box parse error

* leon: &dyn instead of impl

* Can't impl FromStr, so rename to parse

* Add Vec<> to values

* leon: Add benches for ways to supply values

* leon: Add bench comparing to std and tt

* Fix fuzz

* Fmt

* Split ParseError and RenderError

* Make miette optional

* Remove RenderError lifetime

* Simplify ParseError type schema

* Write concrete Values types instead of generics

* Add license files

* Reduce criterion deps

* Make default a cow

* Add a CLI leon tool

* Fix tests

* Clippy

* Disable cli by default

* Avoid failing the build when cli is off

* Add to ci

* Update crates/leon/src/main.rs

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

* Update crates/leon/Cargo.toml

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

* Bump version

* Error not transparent

* Diagnostic can do forwarding

* Simplify error type

* Expand doc examples

* Generic Values for Hash and BTree maps

* One more borrowed

* Forward implementations

* More generics

* Add has_keys

* Lock stdout in leon tool

* No more debug comments in parser

* Even more generics

* Macros to reduce bench duplication

* Further simplify error

* Fix leon main

* Stable support

* Clippy

---------

Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-03-21 01:36:02 +00:00
Félix Saparelli
48b85cc38f
Cleanup caches for closed PRs (#915)
As suggested here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#managing-caches
2023-03-15 15:44:06 +11:00
Jiahao XU
42bffef98c
Use sccache for build cache and disable incremental mode in CI (#914)
Fixed #911

sccache cannot cache build artifacts if incremental mode is enabled.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-03-15 15:42:42 +11:00
Jiahao XU
235d324d3d
Add job windows-aarch64-check to workflow ci (#882)
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-03-11 23:46:26 +11:00
Jiahao XU
18bc81f46f
Use cargo-auditable for release build (#878)
to make the pre-built artifacts auditable by `cargo-audit` and other
tools.

* Add new env `JUST_USE_AUDITABLE` to enable use of `cargo-auditable`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-03-11 15:57:14 +13:00
Félix Saparelli
ac414df5be
Use stable sparse registry option (#879) 2023-03-11 01:58:58 +00:00
Jiahao XU
44eaff97dc
Fix use of hashFiles in key of bulid-cache (#845)
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-03-02 15:40:39 +11:00
Jiahao XU
c8b92b1985
Speedup CI (#842)
- Remove `tools: cross` input to `actions/just-setup`
    since we use `cargo-zigbuild` for cross compiling instead of `cross-rs`
    now.
 - Only install `cargo-zigbuild` in `just ci-install-deps` if `JUST_USE_CARGO_ZIGBUILD` is enabled
 - Include hash of `rustc -vV` in `build-cache`
    Switching between different versions of `rustc` will cause all crates to be
    rebuilt using new `rustc`.
 - Replace input `cache` with `index-cache` and `build-cache` in `actions/just-setup`
    for better control of caching behavior
 -  Reuse workflow `test`'s `build-cache` in workflow `lint`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-03-02 13:09:25 +11: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
Jiahao XU
2bf70b6a01
Run e2e test for release build and fix it by switching back to stable (#818)
* Run e2e-tests for release build
* Print `RUSTFLAGS` for justfile target build & check
* Fix CI: Disable miropt level 4
* Fix CI: Disable -Zbuild-std
* Disable `-Zgcc-ld=lld` and `-Zshare-generics` so that we can switch back to stable

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-02-28 11:53:57 +00:00
Jiahao XU
e76a4dff62
Improve CI: All in cargo-zigbuild for linux targets (#816) 2023-02-18 13:41:17 +11:00
Jiahao XU
9923788f07
Fix CI: Only turn on feature pkg-config on linux and fix cross compilation (#815)
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-02-18 00:07:24 +13:00
Jiahao XU
61c992612c
Switch to cargo-zigbuild for aarch64-unknown-linux-gnu and x86_64-unknown-linux-musl (#814)
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-02-17 09:36:45 +13:00
Jiahao XU
93f15ea1c4
Ignore README.md and SUPPORT.md in workflow "ci" (#812)
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-02-16 11:58:16 +13:00
Jiahao XU
647f02bb59
Use cargo-zigbuild for cross compilation (#767)
* Disable link arg `-lgcc` for musl builds when `cargo-zigbuild` is used

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-02-15 11:19:59 +13: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
Jiahao XU
f46de3714a
Add step to relase-build to make sure it's runnable (#792)
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-02-12 14:48:28 +11:00
Félix Saparelli
939f17dcd0
Fix "Tests pass" step (#726) 2023-01-18 03:13:49 +13:00
Félix Saparelli
ba91777faf
Fix name of release (#723) 2023-01-18 00:22:49 +13:00
Félix Saparelli
aed3d9d71c
Use release action with explicit support for being called multiple times (#693) 2023-01-12 00:48:03 +00:00
Félix Saparelli
64c359a86f
Run CI on auto-merge enable (#692) 2023-01-12 02:45:04 +13:00
Félix Saparelli
ede976d650
Fix typo (#691) 2023-01-11 01:21:16 +00:00
Félix Saparelli
6033e30db5
Remove old jq script (#676) 2023-01-10 22:36:35 +00:00
Félix Saparelli
9821caa6d0
Use release-meta action instead of parsing commits (#675) 2023-01-11 09:22:53 +11:00
dependabot[bot]
4ebf7cb421
Bump tokio from 1.23.0 to 1.24.1 (#658)
* Bump tokio from 1.23.0 to 1.24.1

Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.23.0 to 1.24.1.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.23.0...tokio-1.24.1)

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

Signed-off-by: dependabot[bot] <support@github.com>

* Don't reuse build cache

* fix index cache

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Félix Saparelli <felix@passcod.name>
2023-01-09 20:39:39 +11:00
Félix Saparelli
211cb3ceb0
Add release metadata in PR (from release-pr v2) (#668) 2023-01-09 11:53:55 +11:00
Félix Saparelli
4b2deb19b9
Try build-std with arm64 gnu (#667) 2023-01-09 12:35:00 +13:00
Félix Saparelli
aea9df602c
Migrate CI and builds to Just, add "full" builds (#660) 2023-01-08 16:27:36 +11:00
dependabot[bot]
611485de52
Bump taiki-e/install-action from 1 to 2 (#630) 2022-12-27 11:43:56 +00:00
Noa
597e092774
CI: Build -gnu targets on ubuntu-20.04 (#607)
This commit pins it to 20.04, so the glibc version required by the release binaries can be run on docker image `rust:1.65` which uses glibc 2.31.
2022-12-14 11:14:20 +11:00
Jiahao XU
75d2fc4d42
Optimize pre-built artifact size: Set compression level for zip to 9 (max) (#596)
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-12-09 15:14:37 +13:00
dependabot[bot]
f45c18ff81
Bump softprops/action-gh-release from 0.1.14 to 0.1.15 (#583) 2022-12-02 14:46:59 +13:00
Jiahao XU
44316e1f02
Fix workflow release-pr: Install nightly toolchain (#560)
Default rust/cargo in ubuntu-latest is too old.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-11-22 09:59:24 +00:00
Jiahao XU
bd3f1d598c
Enable feature thin of dep zstd for any target built natively (#480)
* Add new feature `binstalk-downloader/zstd-thin`
* Add new feature `binstalk/zstd-thin`
* Add new feature `binstalk/zstd-thin`
* Enable feature zstd-thin for targets built natively

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-11-22 06:52:41 +00:00
Jiahao XU
707b173de1
Create universal binary for MacOS in workflow release (#551)
* Create universal binary for MacOS in workflow build
* Update README

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-11-22 16:52:36 +11:00
Jiahao XU
d9cc3ce219
Refactor: Extract new crate binstalk-types plus other misc refactor and optimization (#535)
* Refactor: Extract new crate binstalk-types
* Optimize: Rm field `CrateInfo::other`
   which also removes dep serde-tuple-vec-map and serde-json from
   binstalk-types.
   
   This also makes `CrateInfo` easier to use, more generic and can be used
   over any `Serializer`, not just `serde_json::Value`.
* Mark all errors in `binstalk-manifests` as non_exhaustive
* Reduce size of `CvsParseError` by using `Box<str>`
   instead of `String` for variant `UnknownSourceType`.
* Reduce size of `CratesTomlParseError` to 16 bytes on 64bit platform
   by boxing variants `TomlWrite` and `CvsParse` as these two fields are
   significantly larger than other variants.
* Unify import style in mod `binstall_crates_v1`
* Replace dep binstalk-manifests with binstalk-types in binstalk-downloader
   to reduce its transitive dependencies and enables binstalk-downloader to
   be built in parallel to binstak-manifests.
* Replace dep binstalk-manifests with binstalk-types in binstalk
   to reduce transitive dependencies and enables binstalk to be built in
   parallel to binstalk-manifests.
   
   This is benefitial because binstalk-manifests pulls in toml_edit, which
   could takes up to 15s to be built on M1 (7-9s for codegen).
* Add dep binstalk-manifests to crates/bin
* Update dependabot and GHA release-pr

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-11-17 13:46:27 +13:00
dependabot[bot]
4ee0c9160f
Bump cargo-bins/release-pr from 1 to 2 (#531)
Bumps [cargo-bins/release-pr](https://github.com/cargo-bins/release-pr) from 1 to 2.
- [Release notes](https://github.com/cargo-bins/release-pr/releases)
- [Commits](https://github.com/cargo-bins/release-pr/compare/v1...v2)

---
updated-dependencies:
- dependency-name: cargo-bins/release-pr
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-15 12:45:31 +11:00
Jiahao XU
9e80cf0700
Feature: Impl opt-out options (#510)
Fixed #136

* Impl opt-out optioins in binstalk
* Replace field `Options::{gh_crate, quickinstall}_fetcher` with `resolver`
  which can determine order of resolver used.
* Add new field `Args::{disable_}strategies`
* Add new variant `BinstallError::InvalidStrategies`
* Add variant `BinstallError::NoFallbackToCargoInstall`
* Add code for supporting strategies in mod entry
* Test `--disable-strategies` in `tests.sh`
* Test for `--strategies` in `tests.sh`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-11-11 05:24:46 +00:00
Jiahao XU
89fa5b1769
Refactor: Extract new crate binstalk-{signal, downloader} (#518)
* Refactor: Extract new crate binstalk-downloader
* Re-export `PkgFmt` from `binstalk_manifests`
* Update release-pr.yml
* Update dependabot

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-11-11 04:02:54 +00:00
Jiahao XU
e62abb442e
Enable dependabot for binstalk-manifests (#523)
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-11-10 08:37:18 +13:00