A v-tag releases Luxe with installers, Homebrew and crates.io, SECURITY.md says how to report a hole, and luxe update runs the installer's updater
- release.yml, generated by dist from dist-workspace.toml, builds macOS, Linux and Windows, attests every artifact, and publishes shell and PowerShell installers with their updater, a luxe formula in evanwhittaker/homebrew-tap, and the crates through Trusted Publishing (publish-crates.yml, which skips versions crates.io already has). - luxe update recognizes an installer copy by luxe-cli-update beside it and runs that. - The README, the install guide and the site lead with the installer, Homebrew and Windows. - SECURITY.md: report privately through a GitHub advisory or contact@luxe.dev.
This commit is contained in:
@@ -52,7 +52,9 @@ async fn run_steps(steps: &[&[&str]]) -> anyhow::Result<()> {
|
||||
let Some((program, args)) = step.split_first() else { continue };
|
||||
let line = step.join(" ");
|
||||
println!("Running: {line}");
|
||||
let status = tokio::process::Command::new(program)
|
||||
let beside =
|
||||
std::env::current_exe().ok().and_then(|exe| exe.parent().map(Path::to_path_buf));
|
||||
let status = tokio::process::Command::new(program_path(program, beside.as_deref()))
|
||||
.args(args)
|
||||
.status()
|
||||
.await
|
||||
@@ -64,6 +66,16 @@ async fn run_steps(steps: &[&[&str]]) -> anyhow::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Where to run `program` from: `beside` this binary when it is there, which is where the
|
||||
/// installer put its updater, whether or not that directory is on `PATH`; by name otherwise.
|
||||
fn program_path(program: &str, beside: Option<&Path>) -> PathBuf {
|
||||
let name = format!("{program}{}", std::env::consts::EXE_SUFFIX);
|
||||
beside
|
||||
.map(|dir| dir.join(name))
|
||||
.filter(|path| path.is_file())
|
||||
.unwrap_or_else(|| PathBuf::from(program))
|
||||
}
|
||||
|
||||
/// How the update landed, read from the `luxe` a shell would run now.
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
enum Outcome {
|
||||
|
||||
@@ -11,6 +11,18 @@ fn copies() -> (tempfile::TempDir, PathBuf, PathBuf) {
|
||||
(dir, updated, other)
|
||||
}
|
||||
|
||||
/// The installer's updater runs from beside the binary even off `PATH`; anything not there, cargo
|
||||
/// or brew, is found by name.
|
||||
#[test]
|
||||
fn a_program_beside_the_binary_runs_from_there() {
|
||||
let dir = tempfile::tempdir().expect("tempdir");
|
||||
let updater = dir.path().join(format!("luxe-cli-update{}", std::env::consts::EXE_SUFFIX));
|
||||
std::fs::write(&updater, b"").expect("a stand-in updater");
|
||||
assert_eq!(program_path("luxe-cli-update", Some(dir.path())), updater);
|
||||
assert_eq!(program_path("brew", Some(dir.path())), PathBuf::from("brew"));
|
||||
assert_eq!(program_path("luxe-cli-update", None), PathBuf::from("luxe-cli-update"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_version_is_the_last_word_when_it_is_semver() {
|
||||
assert_eq!(parse_version("luxe 0.2.0\n").as_deref(), Some("0.2.0"));
|
||||
|
||||
@@ -857,14 +857,15 @@ it, showing each one before it runs:
|
||||
|
||||
| Installed with | `luxe update` runs |
|
||||
| --- | --- |
|
||||
| Cargo | `cargo install --locked --force luxe-cli` |
|
||||
| The install script | `luxe-cli-update`, the updater it put beside `luxe` |
|
||||
| Homebrew | `brew update`, then `brew upgrade luxe` |
|
||||
| Cargo | `cargo install --locked --force luxe-cli` |
|
||||
|
||||
Luxe never downloads or replaces its own program; the package manager that installed it does. A
|
||||
copy your system's package manager owns is left to it, and a downloaded one points you at the
|
||||
releases page. On Windows, Luxe can't be replaced while it runs, so it prints the command to run
|
||||
once it has exited. Afterwards it checks that the `luxe` your shell finds is the new version, and
|
||||
says so if another copy earlier on your `PATH` is in the way. `luxe update --check` only reports.
|
||||
Luxe never downloads or replaces its own program; whatever installed it does. A copy your system's
|
||||
package manager owns is left to it, and a downloaded archive points you at the releases page. On
|
||||
Windows, Luxe can't be replaced while it runs, so it prints the command to run once it has exited.
|
||||
Afterwards it checks that the `luxe` your shell finds is the new version, and says so if another
|
||||
copy earlier on your `PATH` is in the way. `luxe update --check` only reports.
|
||||
|
||||
To stop the daily check:
|
||||
|
||||
@@ -2129,20 +2130,49 @@ order: 1
|
||||
group: "Get started"
|
||||
---
|
||||
|
||||
## Install with Cargo
|
||||
## Install
|
||||
|
||||
On macOS and Linux, the install script puts `luxe` in `~/.local/bin`, or in `$LUXE_INSTALL_DIR`
|
||||
when it is set, and adds that to your `PATH`:
|
||||
|
||||
```bash
|
||||
cargo install luxe-cli
|
||||
luxe --version
|
||||
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/evanwhittaker/luxe/releases/latest/download/luxe-cli-installer.sh | sh
|
||||
```
|
||||
|
||||
This installs the `luxe` command. You need a recent stable Rust; [rustup](https://rustup.rs)
|
||||
installs one.
|
||||
On Windows, in PowerShell:
|
||||
|
||||
```powershell
|
||||
powershell -ExecutionPolicy Bypass -c "irm https://github.com/evanwhittaker/luxe/releases/latest/download/luxe-cli-installer.ps1 | iex"
|
||||
```
|
||||
|
||||
With Homebrew, on macOS or Linux:
|
||||
|
||||
```bash
|
||||
brew install evanwhittaker/tap/luxe
|
||||
```
|
||||
|
||||
With Cargo, which builds it, so you need Rust 1.89 or newer ([rustup](https://rustup.rs) installs
|
||||
one):
|
||||
|
||||
```bash
|
||||
cargo install --locked luxe-cli
|
||||
```
|
||||
|
||||
Any of them installs the `luxe` command; `luxe --version` checks it worked.
|
||||
|
||||
To update, run `luxe update`, or `/update` inside Luxe. Luxe checks once a day for a newer release
|
||||
and says so on the start screen; see [Updates](configuration.md#updates) for how it updates and how
|
||||
to turn the check off.
|
||||
|
||||
### Check a download
|
||||
|
||||
Every file on a release carries a build attestation, so you can confirm it came from this
|
||||
repository's release workflow and nowhere else:
|
||||
|
||||
```bash
|
||||
gh attestation verify luxe-cli-x86_64-unknown-linux-gnu.tar.xz --repo evanwhittaker/luxe
|
||||
```
|
||||
|
||||
## Build from source
|
||||
|
||||
```bash
|
||||
|
||||
@@ -51,7 +51,7 @@ fn a_search_lists_pull_requests_and_issues_with_where_they_are() {
|
||||
|
||||
pub(super) const MERGED_NONE: &str = include_str!("../../fixtures/merged_below_none.json");
|
||||
|
||||
/// Real answers from restacking a scratch stack on luxe-dev: the bottom squash-merged with its
|
||||
/// Real answers from restacking a scratch stack: the bottom squash-merged with its
|
||||
/// branch kept, and a layer with nothing merged below it. A retargeted one names the base it
|
||||
/// was moved from.
|
||||
#[test]
|
||||
@@ -72,7 +72,7 @@ fn what_merged_below_a_stack_is_read_with_where_it_went() {
|
||||
|
||||
pub(super) const STATUS_UNSTACKED: &str =
|
||||
include_str!("../../fixtures/branch_status_unstacked.json");
|
||||
/// Luxe's own chain on luxe-dev, read from the middle: seven below down to `master`, two above,
|
||||
/// A real chain of Luxe's own, read from the middle: seven below down to `master`, two above,
|
||||
/// and the evidence that checks wait for trunk — the bottom one has them, this one none.
|
||||
#[test]
|
||||
fn a_pull_request_in_the_middle_of_a_stack_knows_where_it_sits() {
|
||||
|
||||
@@ -28,7 +28,7 @@ fn gh_names_a_repository_off_github_com_by_host() {
|
||||
assert!(!repository.is("nora-quinn/luxe"));
|
||||
}
|
||||
|
||||
// From the scratch pull request nora-quinn/luxe-dev#141, posted to and closed for this.
|
||||
// From a scratch pull request, posted to and closed for this.
|
||||
pub(super) const PR_FILES: &str = include_str!("../../fixtures/pr_files.jsonl");
|
||||
pub(super) const THREADS_OWN: &str = include_str!("../../fixtures/review_threads_own.json");
|
||||
pub(super) const THREAD_REPLY: &str = include_str!("../../fixtures/thread_reply.json");
|
||||
@@ -135,8 +135,8 @@ fn the_conversation_comes_with_the_threads() {
|
||||
assert!(before.conversation.is_empty() && !before.threads.is_empty());
|
||||
}
|
||||
|
||||
/// On luxe-dev#169 the reader answered the first comment from Luxe, so it and the answer stay
|
||||
/// quiet, and the review's summary is what is still asked.
|
||||
/// On a real pull request the reader answered the first comment from Luxe, so it and the answer
|
||||
/// stay quiet, and the review's summary is what is still asked.
|
||||
#[test]
|
||||
fn an_answered_comment_on_a_real_pull_request_asks_nothing() {
|
||||
let read = parse_review_threads(THREADS_CONVERSATION).unwrap();
|
||||
|
||||
@@ -272,8 +272,8 @@ fn the_on_disk_entry_shape_is_frozen() {
|
||||
r#"{"id":"e3","parent_id":"e2","ts":7,"kind":{"kind":"header","data":{"cwd":"/w","created":7}}}"#
|
||||
);
|
||||
|
||||
// A link to the pull request a session worked on, copied from the round trip that closed
|
||||
// #146 on luxe-dev: `luxe --from-pr` reads exactly this
|
||||
// A link to the pull request a session worked on, copied from a real round trip that closed
|
||||
// one: `luxe --from-pr` reads exactly this
|
||||
let stored = r#"{"id":"f25fd65c-ee99-4db8-9ed9-76aa08ed7fd9","parent_id":"035e7a31-2d6b-410a-b1d1-361920bf0615","ts":1790289080,"kind":{"kind":"pull_request_link","data":{"number":146,"url":"https://github.com/nora-quinn/luxe-dev/pull/146"}}}"#;
|
||||
let entry: Entry = serde_json::from_str(stored).unwrap();
|
||||
assert_eq!(
|
||||
|
||||
@@ -47,16 +47,32 @@ pub enum InstallSource {
|
||||
Homebrew,
|
||||
/// A path a distribution's package manager owns (`/usr/bin`, `/bin`).
|
||||
SystemPackage,
|
||||
/// A release archive, an installer script, `/usr/local/bin`, or a local build.
|
||||
/// Luxe's own installer script, known by the updater it puts beside the binary.
|
||||
Installer,
|
||||
/// A release archive, `/usr/local/bin`, or a local build.
|
||||
Archive,
|
||||
}
|
||||
|
||||
/// The updater Luxe's installer script puts beside the binary, named `<package>-update` by dist.
|
||||
pub const INSTALLER_UPDATER: &str = "luxe-cli-update";
|
||||
|
||||
impl InstallSource {
|
||||
/// Classify the running binary. Falls back to [`InstallSource::Archive`], which is the state
|
||||
/// that gives the most cautious advice ("download the new release") rather than the most
|
||||
/// confident.
|
||||
pub fn detect() -> Self {
|
||||
std::env::current_exe().map(|path| Self::from_path(&path)).unwrap_or(Self::Archive)
|
||||
std::env::current_exe().map(|path| Self::from_install(&path)).unwrap_or(Self::Archive)
|
||||
}
|
||||
|
||||
/// Classify a binary by what sits beside it, then by its path. The installer's updater beside
|
||||
/// it decides first: the installer puts it wherever it installs, `~/.cargo/bin` included when
|
||||
/// told to, and no path says "installer" on its own.
|
||||
pub fn from_install(binary: &Path) -> Self {
|
||||
let updater = format!("{INSTALLER_UPDATER}{}", std::env::consts::EXE_SUFFIX);
|
||||
match binary.parent().map(|dir| dir.join(updater)) {
|
||||
Some(path) if path.is_file() => Self::Installer,
|
||||
_ => Self::from_path(binary),
|
||||
}
|
||||
}
|
||||
|
||||
/// Classify a path. Split out from [`Self::detect`] because a function that can only be
|
||||
@@ -94,6 +110,7 @@ impl InstallSource {
|
||||
match self {
|
||||
Self::Cargo => Some(&[&["cargo", "install", "--locked", "--force", "luxe-cli"]]),
|
||||
Self::Homebrew => Some(&[&["brew", "update"], &["brew", "upgrade", "luxe"]]),
|
||||
Self::Installer => Some(&[&[INSTALLER_UPDATER]]),
|
||||
// Which package manager owns it is not knowable without querying one, and guessing
|
||||
// `apt` on an Arch machine is the failure this whole function exists to avoid.
|
||||
Self::SystemPackage => None,
|
||||
|
||||
@@ -31,6 +31,36 @@ fn the_update_steps_are_the_owners_own_commands() {
|
||||
assert_eq!(InstallSource::Archive.update_steps(), None, "a download has no owner to ask");
|
||||
}
|
||||
|
||||
/// The installer's updater beside the binary marks an installer copy wherever it lives, a
|
||||
/// `~/.cargo/bin` it was told to use included, and that updater is its update. Without it the
|
||||
/// path decides, as before.
|
||||
#[test]
|
||||
fn the_installers_updater_beside_the_binary_marks_an_installer_copy() {
|
||||
let dir = tempfile::tempdir().expect("tempdir");
|
||||
let bin = dir.path().join(".cargo/bin");
|
||||
std::fs::create_dir_all(&bin).expect("bin dir");
|
||||
let luxe = bin.join(format!("luxe{}", std::env::consts::EXE_SUFFIX));
|
||||
std::fs::write(&luxe, b"").expect("a stand-in luxe");
|
||||
assert_eq!(InstallSource::from_install(&luxe), InstallSource::Cargo, "no updater: the path");
|
||||
|
||||
let updater = bin.join(format!("{INSTALLER_UPDATER}{}", std::env::consts::EXE_SUFFIX));
|
||||
std::fs::write(&updater, b"").expect("a stand-in updater");
|
||||
assert_eq!(InstallSource::from_install(&luxe), InstallSource::Installer);
|
||||
let steps: &[&[&str]] = &[&["luxe-cli-update"]];
|
||||
assert_eq!(InstallSource::Installer.update_steps(), Some(steps));
|
||||
}
|
||||
|
||||
/// A directory named like the updater is not the updater.
|
||||
#[test]
|
||||
fn a_directory_named_like_the_updater_does_not_count() {
|
||||
let dir = tempfile::tempdir().expect("tempdir");
|
||||
let luxe = dir.path().join("luxe");
|
||||
std::fs::write(&luxe, b"").expect("a stand-in luxe");
|
||||
let name = format!("{INSTALLER_UPDATER}{}", std::env::consts::EXE_SUFFIX);
|
||||
std::fs::create_dir(dir.path().join(name)).expect("a directory");
|
||||
assert_ne!(InstallSource::from_install(&luxe), InstallSource::Installer);
|
||||
}
|
||||
|
||||
/// Homebrew is checked first because its Linux and Intel-macOS prefixes sit *inside* paths the
|
||||
/// other arms would otherwise claim.
|
||||
#[test]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! `git` `checks` — why CI is failing, bounded.
|
||||
//!
|
||||
//! `gh run view --log-failed` prints every line of every failing step: 3,671 lines for one Clippy
|
||||
//! step on luxe-dev, with the error in the last dozen. This reads the same logs through GitHub
|
||||
//! step of Luxe's own, with the error in the last dozen. This reads the same logs through GitHub
|
||||
//! and keeps the tail of each failing step, says how much it left out, and also lists the failing
|
||||
//! checks that are not Actions jobs at all — a commit status from another CI, which that command
|
||||
//! cannot see. Reading only; re-running a job stays behind the permission engine's `ask`.
|
||||
|
||||
@@ -331,14 +331,17 @@ async fn without_a_pull_request_the_checks_on_head_are_read() {
|
||||
);
|
||||
}
|
||||
|
||||
/// Against the real `gh` and luxe-dev's #119, whose getrandom bump failed three jobs: each
|
||||
/// comes back with the compiler's error at the end of its tail. `cargo test -- --ignored`.
|
||||
/// Against the real `gh` and a pull request of this checkout's repository whose CI failed: each
|
||||
/// failing job comes back with the compiler's error at the end of its tail. Run with
|
||||
/// `LUXE_FAILED_PR=<number> cargo test -- --ignored`.
|
||||
#[tokio::test]
|
||||
#[ignore = "needs a signed-in gh and the network"]
|
||||
#[ignore = "needs a signed-in gh, the network, and LUXE_FAILED_PR"]
|
||||
async fn a_real_failed_run_ends_in_its_error() {
|
||||
let number = std::env::var("LUXE_FAILED_PR")
|
||||
.expect("LUXE_FAILED_PR names a pull request in this repository whose checks failed");
|
||||
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");
|
||||
let github = luxe_core::github::GhCli::new();
|
||||
let text = checks(&github, &root, &["119".into()]).await.unwrap();
|
||||
assert!(text.starts_with("1 check failing on #119"), "{text}");
|
||||
let text = checks(&github, &root, std::slice::from_ref(&number)).await.unwrap();
|
||||
assert!(text.contains(&format!("failing on #{number}")), "{text}");
|
||||
assert!(text.contains("##[error]Process completed with exit code"), "{text}");
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ fn collapse_blank_runs(text: &str) -> String {
|
||||
mod tests {
|
||||
use super::readable;
|
||||
|
||||
/// Dependabot's commit list, from luxe-dev #197's real body: a summary heading, then a list
|
||||
/// Dependabot's commit list, from a real pull request's body: a summary heading, then a list
|
||||
/// of linked commit ids, with an entity decoded and no tag left.
|
||||
#[test]
|
||||
fn a_dependabot_commit_list_reads_as_a_list() {
|
||||
|
||||
Reference in New Issue
Block a user