diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e9cfec4d7..3ab76e255 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,10 +78,6 @@ jobs: parallel: true flag-name: ${{ matrix.os }}-unit - - uses: actions/upload-artifact@v4 - with: - path: ./target/release/pkgx - coverage-integration: needs: fmt strategy: @@ -95,6 +91,10 @@ jobs: - uses: dtolnay/rust-toolchain@stable + - uses: taiki-e/install-action@v2 + with: + tool: rustfilt + - name: build run: | RUSTFLAGS="-C instrument-coverage" cargo build @@ -111,6 +111,7 @@ jobs: - run: pkgx +git --json=v1 - run: pkgx +git --json=v2 - run: pkgx git --version + - run: pkgx git@latest --version - run: pkgx --silent +git - run: pkgx --quiet +git - run: pkgx +git -- git --version # lib/utils.rs:find_program @@ -129,6 +130,9 @@ jobs: # testing we correctly handle +pkg syntax for pkgs with no env - run: pkgx +curl.se/ca-certs + - run: '! pkgx flubber-flubbles' # cmd not found machinery + - run: '! pkgx --sync flubber-flubbles' # cmd not found machinery separate if branch + # create a fork bomb, but since it’s via pkgx we prevent it - run: | echo '#!/bin/sh' > foo @@ -158,23 +162,13 @@ jobs: pkgx -Q hyperfine ! test -d ~/.pkgx/crates.io/hyperfine ! pkgx -Q flubber-flubber + ! pkgx -Qqq flubber-flubber + pkgx -Q - run: if [ $(find ~/.pkgx -name .tmp\* -type d | wc -l) -gt 0 ]; then exit 1; fi - - name: generate coverage - run: | - cargo install rustfilt - pkgx +llvm.org -- llvm-profdata merge -sparse default_*.profraw -o default.profdata - pkgx +llvm.org -- llvm-cov export \ - ./target/debug/pkgx \ - --format=lcov \ - --ignore-filename-regex="$HOME/.cargo" \ - --instr-profile=default.profdata \ - -Xdemangler=rustfilt \ - > lcov.info - - name: --shebang test 1 run: | echo "#!/usr/bin/env -S pkgx --shebang echo" > ./stub.sh @@ -188,6 +182,29 @@ jobs: run: | pkgx semverator eq $(pkgx krampus=0.2.0 --version) 0.2.0 pkgx semverator gt $(pkgx krampus@latest --version) 0.2.0 + env: + XDG_DATA_HOME: ${{ github.workspace }}/.data + + - name: PKGX_PANTRY_DIR + run: | + git clone https://github.com/pkgxdev/pantry + pkgx hyperfine --version + PKGX_PANTRY_DIR=pantry pkgx hyperfine --version + env: + PKGX_PANTRY_DIR: ${{ github.workspace }}/pantry + PKGX_DIR: ${{ github.workspace }}/pkgx + PKGX_DIST_URL: https://dist.pkgx.dev + + - name: generate coverage + run: | + pkgx +llvm.org -- llvm-profdata merge -sparse $(find . -name default_\*.prof\*) -o default.profdata + pkgx +llvm.org -- llvm-cov export \ + ./target/debug/pkgx \ + --format=lcov \ + --ignore-filename-regex="$HOME/.cargo" \ + --instr-profile=default.profdata \ + -Xdemangler=rustfilt \ + > lcov.info - uses: coverallsapp/github-action@v2 with: diff --git a/crates/cli/src/args.rs b/crates/cli/src/args.rs index b888b6ed3..09768f037 100644 --- a/crates/cli/src/args.rs +++ b/crates/cli/src/args.rs @@ -52,7 +52,7 @@ pub fn parse() -> Args { "--json" => { if !silent { eprintln!( - "{} use --json={}", + "{} use --json=v{}", style("warning: --json is not stable").yellow(), json_latest_v ); @@ -75,7 +75,7 @@ pub fn parse() -> Args { style("│").red() ); eprintln!( - "{} you need to migrate to the new, isolated `dev` command", + "{} you need to migrate to the new, independent `dev` command", style("│").red() ); eprintln!("{} run the following:", style("│").red()); diff --git a/crates/cli/src/resolve.rs b/crates/cli/src/resolve.rs index 875686e9c..37327ecee 100644 --- a/crates/cli/src/resolve.rs +++ b/crates/cli/src/resolve.rs @@ -8,7 +8,10 @@ use libpkgx::{ }; use rusqlite::Connection; -use crate::{spinner::Spinner, which}; +use crate::{ + spinner::Spinner, + which::{which, WhichError}, +}; pub async fn resolve( args: &mut [String], @@ -32,7 +35,7 @@ pub async fn resolve( .join(pkgspec.project()) .is_dir() { - let project = which::which(&pkgspec.project(), conn, &pkgs).await?; + let project = which(&pkgspec.project(), conn, &pkgs).await?; pkgspec.set_project(project); } @@ -45,15 +48,15 @@ pub async fn resolve( args[0] = cmd.clone(); // invoke eg. `node` rather than eg. `node@20` - let project = match which::which(&cmd, conn, &pkgs).await { - Err(which::WhichError::CmdNotFound(cmd)) => { + let project = match which(&cmd, conn, &pkgs).await { + Err(WhichError::CmdNotFound(cmd)) => { if !did_sync { spinner.set_message(&format!("{} not found, syncing…", cmd)); sync::update(config, conn).await?; // cmd not found ∴ sync in case it is new spinner.set_message("resolving pkg graph…"); - which::which(&cmd, conn, &pkgs).await + which(&cmd, conn, &pkgs).await } else { - Err(which::WhichError::CmdNotFound(cmd)) + Err(WhichError::CmdNotFound(cmd)) } } Err(err) => Err(err), diff --git a/crates/lib/src/inventory.rs b/crates/lib/src/inventory.rs index 654e08c00..dcfdf099b 100644 --- a/crates/lib/src/inventory.rs +++ b/crates/lib/src/inventory.rs @@ -5,25 +5,6 @@ use libsemverator::semver::Semver as Version; use reqwest::Url; use std::error::Error; -// Custom error for download issues -#[derive(Debug)] -pub struct DownloadError { - pub status: u16, - pub src: String, -} - -impl std::fmt::Display for DownloadError { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!( - f, - "Download error: status code {} from {}", - self.status, self.src - ) - } -} - -impl Error for DownloadError {} - // Select function to pick a version pub async fn select(rq: &PackageReq, config: &Config) -> Result, Box> { let versions = ls(&rq.project, config).await?; @@ -45,14 +26,11 @@ pub async fn ls(project: &String, config: &Config) -> Result, Box = releases @@ -63,8 +41,8 @@ pub async fn ls(project: &String, config: &Config) -> Result, Box