From d2e688c4c27e08e76e580b2925dac7de2a132e59 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Fri, 10 Jun 2022 15:49:54 +1000 Subject: [PATCH 01/20] Fix `untar` when `desired_outputs` is not `None` Signed-off-by: Jiahao XU --- src/helpers/extracter.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/helpers/extracter.rs b/src/helpers/extracter.rs index 41797210..cc2fa495 100644 --- a/src/helpers/extracter.rs +++ b/src/helpers/extracter.rs @@ -1,5 +1,5 @@ use std::borrow::Cow; -use std::fs::File; +use std::fs::{self, File}; use std::io::Read; use std::path::Path; @@ -29,6 +29,8 @@ fn untar( if desired_outputs.contains(&entry_path) { let dst = path.join(entry_path); + fs::create_dir_all(dst.parent().unwrap())?; + entry.unpack(dst)?; } } From fb5f61559b9b7c1449b3758329b923f28dc195df Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Fri, 10 Jun 2022 15:50:56 +1000 Subject: [PATCH 02/20] Fix use of `download_and_extract` in `find_crate_cratesio` Signed-off-by: Jiahao XU --- src/drivers.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/drivers.rs b/src/drivers.rs index 3ddf654d..355ce3f7 100644 --- a/src/drivers.rs +++ b/src/drivers.rs @@ -102,16 +102,17 @@ pub async fn fetch_crate_cratesio( debug!("Fetching crate from: {crate_url} and extracting Cargo.toml from it"); + let crate_dir = format!("{name}-{version_name}"); + let crate_path = temp_dir.join(&crate_dir); + download_and_extract( Url::parse(&crate_url)?, PkgFmt::Tgz, &temp_dir, - Some([Path::new("Cargo.toml").into()]), + Some([Path::new(&crate_dir).join("Cargo.toml").into()]), ) .await?; - let crate_path = temp_dir.join(format!("{name}-{version_name}")); - // Return crate directory Ok(crate_path) } From a681f3a156728651e221c15396a2ee0898577f3c Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Fri, 10 Jun 2022 16:18:01 +1000 Subject: [PATCH 03/20] Add `debug!` logging to `untar` Signed-off-by: Jiahao XU --- src/helpers/extracter.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/helpers/extracter.rs b/src/helpers/extracter.rs index cc2fa495..dd5831f4 100644 --- a/src/helpers/extracter.rs +++ b/src/helpers/extracter.rs @@ -22,11 +22,15 @@ fn untar( let mut tar = Archive::new(dat); if let Some(desired_outputs) = desired_outputs { + debug!("Untaring only {desired_outputs:#?}"); + for res in tar.entries()? { let mut entry = res?; let entry_path = entry.path()?; if desired_outputs.contains(&entry_path) { + debug!("Extracting {entry_path:#?}"); + let dst = path.join(entry_path); fs::create_dir_all(dst.parent().unwrap())?; @@ -35,6 +39,7 @@ fn untar( } } } else { + debug!("Untaring entire tar"); tar.unpack(path)?; } From 1d139324c7a1f5a4a43c80821c20186b9951f6c0 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Fri, 10 Jun 2022 16:35:51 +1000 Subject: [PATCH 04/20] Rewrite `untar`: Takes a `filter` fn instead of array Signed-off-by: Jiahao XU --- src/drivers.rs | 9 ++++++-- src/fetchers/gh_crate_meta.rs | 2 +- src/fetchers/quickinstall.rs | 3 ++- src/helpers.rs | 14 ++++++------ src/helpers/async_extracter.rs | 40 ++++++++++++++++------------------ src/helpers/extracter.rs | 35 +++++++++++++++-------------- 6 files changed, 55 insertions(+), 48 deletions(-) diff --git a/src/drivers.rs b/src/drivers.rs index 355ce3f7..9c36b051 100644 --- a/src/drivers.rs +++ b/src/drivers.rs @@ -102,14 +102,19 @@ pub async fn fetch_crate_cratesio( debug!("Fetching crate from: {crate_url} and extracting Cargo.toml from it"); - let crate_dir = format!("{name}-{version_name}"); + let crate_dir: PathBuf = format!("{name}-{version_name}").into(); let crate_path = temp_dir.join(&crate_dir); + let cargo_toml = crate_dir.join("Cargo.toml"); + let src = crate_dir.join("src"); + let main = src.join("main.rs"); + let bin = src.join("bin"); + download_and_extract( Url::parse(&crate_url)?, PkgFmt::Tgz, &temp_dir, - Some([Path::new(&crate_dir).join("Cargo.toml").into()]), + Some(move |path: &Path| path == cargo_toml || path == main || path.starts_with(&bin)), ) .await?; diff --git a/src/fetchers/gh_crate_meta.rs b/src/fetchers/gh_crate_meta.rs index c6ed669b..bc4575e6 100644 --- a/src/fetchers/gh_crate_meta.rs +++ b/src/fetchers/gh_crate_meta.rs @@ -43,7 +43,7 @@ impl super::Fetcher for GhCrateMeta { async fn fetch_and_extract(&self, dst: &Path) -> Result<(), BinstallError> { let url = self.url()?; info!("Downloading package from: '{url}'"); - download_and_extract::<_, 0>(url, self.pkg_fmt(), dst, None).await + download_and_extract:: bool, _>(url, self.pkg_fmt(), dst, None).await } fn pkg_fmt(&self) -> PkgFmt { diff --git a/src/fetchers/quickinstall.rs b/src/fetchers/quickinstall.rs index f048de03..7d597d15 100644 --- a/src/fetchers/quickinstall.rs +++ b/src/fetchers/quickinstall.rs @@ -40,7 +40,8 @@ impl super::Fetcher for QuickInstall { async fn fetch_and_extract(&self, dst: &Path) -> Result<(), BinstallError> { let url = self.package_url(); info!("Downloading package from: '{url}'"); - download_and_extract::<_, 0>(Url::parse(&url)?, self.pkg_fmt(), dst, None).await + download_and_extract:: bool, _>(Url::parse(&url)?, self.pkg_fmt(), dst, None) + .await } fn pkg_fmt(&self) -> PkgFmt { diff --git a/src/helpers.rs b/src/helpers.rs index da0a54c0..d81bb775 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -1,5 +1,4 @@ use std::{ - borrow::Cow, io::{stderr, stdin, Write}, path::{Path, PathBuf}, }; @@ -46,14 +45,15 @@ pub async fn remote_exists(url: Url, method: Method) -> Result, const N: usize>( +/// * `filter` - If Some, then it will pass the path of the file to it +/// and only extract ones which filter returns `true`. +/// Note that this is a best-effort and it only works when `fmt` +/// is not `PkgFmt::Bin` or `PkgFmt::Zip`. +pub async fn download_and_extract bool + Send + 'static, P: AsRef>( url: Url, fmt: PkgFmt, path: P, - desired_outputs: Option<[Cow<'static, Path>; N]>, + filter: Option, ) -> Result<(), BinstallError> { debug!("Downloading from: '{url}'"); @@ -69,7 +69,7 @@ pub async fn download_and_extract, const N: usize>( let path = path.as_ref(); debug!("Downloading to file: '{}'", path.display()); - extract_archive_stream(resp.bytes_stream(), path, fmt, desired_outputs).await?; + extract_archive_stream(resp.bytes_stream(), path, fmt, filter).await?; debug!("Download OK, written to file: '{}'", path.display()); diff --git a/src/helpers/async_extracter.rs b/src/helpers/async_extracter.rs index 4eed3276..0b399ab4 100644 --- a/src/helpers/async_extracter.rs +++ b/src/helpers/async_extracter.rs @@ -1,4 +1,3 @@ -use std::borrow::Cow; use std::fs; use std::io::{self, Seek, Write}; use std::path::Path; @@ -29,12 +28,14 @@ struct AsyncExtracterInner { } impl AsyncExtracterInner { - /// * `desired_outputs - If Some(_), then it will filter the tar - /// and only extract files specified in it. - fn new( + /// * `filter` - If Some, then it will pass the path of the file to it + /// and only extract ones which filter returns `true`. + /// Note that this is a best-effort and it only works when `fmt` + /// is not `PkgFmt::Bin` or `PkgFmt::Zip`. + fn new bool + Send + 'static>( path: &Path, fmt: PkgFmt, - desired_outputs: Option<[Cow<'static, Path>; N]>, + filter: Option, ) -> Self { let path = path.to_owned(); let (tx, rx) = mpsc::channel::(100); @@ -73,12 +74,9 @@ impl AsyncExtracterInner { unzip(file, &path)?; } - _ => extract_compressed_from_readable( - ReadableRx::new(&mut rx), - fmt, - &path, - desired_outputs.as_ref().map(|arr| &arr[..]), - )?, + _ => { + extract_compressed_from_readable(ReadableRx::new(&mut rx), fmt, &path, filter)? + } } Ok(()) @@ -181,16 +179,16 @@ impl AsyncExtracter { /// for the bin. /// Otherwise, it is the directory where the extracted content will be put. /// * `fmt` - The format of the archive to feed in. - /// * `desired_outputs - If Some(_), then it will filter the tar and - /// only extract files specified in it. + /// * `filter` - If Some, then it will pass the path of the file to it + /// and only extract ones which filter returns `true`. /// Note that this is a best-effort and it only works when `fmt` /// is not `PkgFmt::Bin` or `PkgFmt::Zip`. - fn new( + fn new bool + Send + 'static>( path: &Path, fmt: PkgFmt, - desired_outputs: Option<[Cow<'static, Path>; N]>, + filter: Option, ) -> Self { - let inner = AsyncExtracterInner::new(path, fmt, desired_outputs); + let inner = AsyncExtracterInner::new(path, fmt, filter); Self(guard(inner, AsyncExtracterInner::abort)) } @@ -209,20 +207,20 @@ impl AsyncExtracter { /// for the bin. /// Otherwise, it is the directory where the extracted content will be put. /// * `fmt` - The format of the archive to feed in. -/// * `desired_outputs - If Some(_), then it will filter the tar and -/// only extract files specified in it. +/// * `filter` - If Some, then it will pass the path of the file to it +/// and only extract ones which filter returns `true`. /// Note that this is a best-effort and it only works when `fmt` /// is not `PkgFmt::Bin` or `PkgFmt::Zip`. -pub async fn extract_archive_stream( +pub async fn extract_archive_stream bool + Send + 'static, E>( mut stream: impl Stream> + Unpin, output: &Path, fmt: PkgFmt, - desired_outputs: Option<[Cow<'static, Path>; N]>, + filter: Option, ) -> Result<(), BinstallError> where BinstallError: From, { - let mut extracter = AsyncExtracter::new(output, fmt, desired_outputs); + let mut extracter = AsyncExtracter::new(output, fmt, filter); while let Some(res) = stream.next().await { extracter.feed(res?).await?; diff --git a/src/helpers/extracter.rs b/src/helpers/extracter.rs index dd5831f4..fbb9d5c0 100644 --- a/src/helpers/extracter.rs +++ b/src/helpers/extracter.rs @@ -1,4 +1,3 @@ -use std::borrow::Cow; use std::fs::{self, File}; use std::io::Read; use std::path::Path; @@ -12,23 +11,25 @@ use zstd::stream::Decoder as ZstdDecoder; use crate::{BinstallError, PkgFmt}; -/// * `desired_outputs - If Some(_), then it will filter the tar -/// and only extract files specified in it. -fn untar( +/// * `filter` - If Some, then it will pass the path of the file to it +/// and only extract ones which filter returns `true`. +/// Note that this is a best-effort and it only works when `fmt` +/// is not `PkgFmt::Bin` or `PkgFmt::Zip`. +fn untar bool>( dat: impl Read, path: &Path, - desired_outputs: Option<&[Cow<'_, Path>]>, + filter: Option, ) -> Result<(), BinstallError> { let mut tar = Archive::new(dat); - if let Some(desired_outputs) = desired_outputs { - debug!("Untaring only {desired_outputs:#?}"); + if let Some(mut filter) = filter { + debug!("Untaring with filter"); for res in tar.entries()? { let mut entry = res?; let entry_path = entry.path()?; - if desired_outputs.contains(&entry_path) { + if filter(&entry_path) { debug!("Extracting {entry_path:#?}"); let dst = path.join(entry_path); @@ -49,34 +50,36 @@ fn untar( /// Extract files from the specified source onto the specified path. /// /// * `fmt` - must not be `PkgFmt::Bin` or `PkgFmt::Zip`. -/// * `desired_outputs - If Some(_), then it will filter the tar -/// and only extract files specified in it. -pub(crate) fn extract_compressed_from_readable( +/// * `filter` - If Some, then it will pass the path of the file to it +/// and only extract ones which filter returns `true`. +/// Note that this is a best-effort and it only works when `fmt` +/// is not `PkgFmt::Bin` or `PkgFmt::Zip`. +pub(crate) fn extract_compressed_from_readable bool>( dat: impl Read, fmt: PkgFmt, path: &Path, - desired_outputs: Option<&[Cow<'_, Path>]>, + filter: Option, ) -> Result<(), BinstallError> { match fmt { PkgFmt::Tar => { // Extract to install dir debug!("Extracting from tar archive to `{path:?}`"); - untar(dat, path, desired_outputs)? + untar(dat, path, filter)? } PkgFmt::Tgz => { // Extract to install dir debug!("Decompressing from tgz archive to `{path:?}`"); let tar = GzDecoder::new(dat); - untar(tar, path, desired_outputs)?; + untar(tar, path, filter)?; } PkgFmt::Txz => { // Extract to install dir debug!("Decompressing from txz archive to `{path:?}`"); let tar = XzDecoder::new(dat); - untar(tar, path, desired_outputs)?; + untar(tar, path, filter)?; } PkgFmt::Tzstd => { // Extract to install dir @@ -87,7 +90,7 @@ pub(crate) fn extract_compressed_from_readable( // as &[] by ZstdDecoder::new, thus ZstdDecoder::new // should not return any error. let tar = ZstdDecoder::new(dat)?; - untar(tar, path, desired_outputs)?; + untar(tar, path, filter)?; } PkgFmt::Zip => panic!("Unexpected PkgFmt::Zip!"), PkgFmt::Bin => panic!("Unexpected PkgFmt::Bin!"), From 62be22256b73ca15437d3bf5b7066a08b1b4ea72 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Fri, 10 Jun 2022 16:37:48 +1000 Subject: [PATCH 05/20] Refactor: Extract `download_and_extract_with_filter` Signed-off-by: Jiahao XU --- src/drivers.rs | 2 +- src/fetchers/gh_crate_meta.rs | 2 +- src/fetchers/quickinstall.rs | 3 +-- src/helpers.rs | 17 +++++++++++++++-- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/drivers.rs b/src/drivers.rs index 9c36b051..b16513d9 100644 --- a/src/drivers.rs +++ b/src/drivers.rs @@ -110,7 +110,7 @@ pub async fn fetch_crate_cratesio( let main = src.join("main.rs"); let bin = src.join("bin"); - download_and_extract( + download_and_extract_with_filter( Url::parse(&crate_url)?, PkgFmt::Tgz, &temp_dir, diff --git a/src/fetchers/gh_crate_meta.rs b/src/fetchers/gh_crate_meta.rs index bc4575e6..82bdf3bc 100644 --- a/src/fetchers/gh_crate_meta.rs +++ b/src/fetchers/gh_crate_meta.rs @@ -43,7 +43,7 @@ impl super::Fetcher for GhCrateMeta { async fn fetch_and_extract(&self, dst: &Path) -> Result<(), BinstallError> { let url = self.url()?; info!("Downloading package from: '{url}'"); - download_and_extract:: bool, _>(url, self.pkg_fmt(), dst, None).await + download_and_extract(url, self.pkg_fmt(), dst).await } fn pkg_fmt(&self) -> PkgFmt { diff --git a/src/fetchers/quickinstall.rs b/src/fetchers/quickinstall.rs index 7d597d15..7d6ed14a 100644 --- a/src/fetchers/quickinstall.rs +++ b/src/fetchers/quickinstall.rs @@ -40,8 +40,7 @@ impl super::Fetcher for QuickInstall { async fn fetch_and_extract(&self, dst: &Path) -> Result<(), BinstallError> { let url = self.package_url(); info!("Downloading package from: '{url}'"); - download_and_extract:: bool, _>(Url::parse(&url)?, self.pkg_fmt(), dst, None) - .await + download_and_extract(Url::parse(&url)?, self.pkg_fmt(), dst).await } fn pkg_fmt(&self) -> PkgFmt { diff --git a/src/helpers.rs b/src/helpers.rs index d81bb775..679328cd 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -43,13 +43,26 @@ pub async fn remote_exists(url: Url, method: Method) -> Result>( + url: Url, + fmt: PkgFmt, + path: P, +) -> Result<(), BinstallError> { + download_and_extract_with_filter:: bool, _>(url, fmt, path.as_ref(), None).await +} + +/// Download a file from the provided URL and extract part of it to +/// the provided path. /// /// * `filter` - If Some, then it will pass the path of the file to it /// and only extract ones which filter returns `true`. /// Note that this is a best-effort and it only works when `fmt` /// is not `PkgFmt::Bin` or `PkgFmt::Zip`. -pub async fn download_and_extract bool + Send + 'static, P: AsRef>( +pub async fn download_and_extract_with_filter< + Filter: FnMut(&Path) -> bool + Send + 'static, + P: AsRef, +>( url: Url, fmt: PkgFmt, path: P, From b0598a1fad8cb02a103f17ff152a561f4875f07b Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Fri, 10 Jun 2022 16:38:45 +1000 Subject: [PATCH 06/20] Update workflow rust: Test `find_crate_cratesio` by removing `--manifest-path` Signed-off-by: Jiahao XU --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 3b26bb66..7b0ed8af 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -164,4 +164,4 @@ jobs: run: unzip cargo-binstall-${{ matrix.target }}.zip - name: "Run binstall" - run: ./${{ matrix.output }} cargo-binstall --manifest-path . --no-confirm + run: ./${{ matrix.output }} cargo-binstall --no-confirm From 3e5c7ec43fcfadcb4da9ebcb272570c66839ebf9 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Fri, 10 Jun 2022 16:49:09 +1000 Subject: [PATCH 07/20] Add back testing of `--manifest-path` in workflow `rust` Signed-off-by: Jiahao XU --- .github/workflows/rust.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 7b0ed8af..abe55e7b 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -165,3 +165,6 @@ jobs: - name: "Run binstall" run: ./${{ matrix.output }} cargo-binstall --no-confirm + + - name: "Run binstall with manifest" + run: ./${{ matrix.output }} cargo-binstall --manifest-path . --no-confirm From d4495cc3bb128703b38ebc122dd209d716d1df59 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Fri, 10 Jun 2022 16:52:24 +1000 Subject: [PATCH 08/20] Merge job test into job build to speedup workflow so that testing does not have to wait for all build jobs with different configurations to finish before starting. Signed-off-by: Jiahao XU --- .github/workflows/rust.yml | 61 ++++++-------------------------------- 1 file changed, 9 insertions(+), 52 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index abe55e7b..e0067ac1 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -12,7 +12,7 @@ env: jobs: build: - name: Build + name: Build and Test runs-on: ${{ matrix.os }} strategy: @@ -90,6 +90,14 @@ jobs: - name: Copy and rename utility run: cp target/${{ matrix.target }}/release/${{ matrix.output }} ${{ matrix.output }} + - name: Test + run: for bin in $bins; do ./${{ matrix.output }} cargo-binstall --no-confirm $bin; $done + env: + bins: cargo-binstall + + - name: "Test binstall with manifest" + run: ./${{ matrix.output }} cargo-binstall --manifest-path . --no-confirm + - name: Create archive (tgz, linux) if: ${{ matrix.os != 'macos-latest' && matrix.os != 'windows-latest' }} run: tar -czvf cargo-binstall-${{ matrix.target }}.tgz ${{ matrix.output }} @@ -117,54 +125,3 @@ jobs: asset_name: cargo-binstall-${{ matrix.target }}.${{ matrix.archive }} tag: ${{ github.ref }} overwrite: true - - test: - name: Test - runs-on: ${{ matrix.os }} - needs: build - strategy: - fail-fast: false - matrix: - include: - - target: x86_64-unknown-linux-gnu - os: ubuntu-latest - output: cargo-binstall - archive: tgz - - target: x86_64-apple-darwin - os: macos-latest - output: cargo-binstall - archive: zip - - target: x86_64-pc-windows-msvc - os: windows-latest - output: cargo-binstall.exe - archive: zip - - target: x86_64-unknown-linux-musl - os: ubuntu-latest - output: cargo-binstall - archive: tgz - - steps: - - uses: actions/checkout@v2 - - uses: FranzDiebold/github-env-vars-action@v1.2.1 - - - uses: actions/download-artifact@v2 - with: - name: cargo-binstall-${{ matrix.target }}.${{ matrix.archive }} - - - name: "Extract build artifact (tgz, linux)" - if: ${{ matrix.os != 'windows-latest' && matrix.os != 'macos-latest' }} - run: tar -xvf cargo-binstall-${{ matrix.target }}.tgz - - - name: "Extract build artifact (zip, windows)" - if: ${{ matrix.os == 'windows-latest' }} - run: tar.exe -xvf cargo-binstall-${{ matrix.target }}.zip - - - name: "Extract build artifact (zip, macos)" - if: ${{ matrix.os == 'macos-latest' }} - run: unzip cargo-binstall-${{ matrix.target }}.zip - - - name: "Run binstall" - run: ./${{ matrix.output }} cargo-binstall --no-confirm - - - name: "Run binstall with manifest" - run: ./${{ matrix.output }} cargo-binstall --manifest-path . --no-confirm From 4ff64dee34abe9e8882a09aeb70dcf7f4baad5f1 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Fri, 10 Jun 2022 16:53:34 +1000 Subject: [PATCH 09/20] Fix caching: Only cache `.cargo/{git, registry}` Signed-off-by: Jiahao XU --- .github/workflows/rust.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index e0067ac1..fc05a41e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -73,7 +73,8 @@ jobs: with: key: ${{ matrix.os }}-${{ matrix.target }} path: | - ${{ env.HOME }}/.cargo + ${{ env.HOME }}/.cargo/git + ${{ env.HOME }}/.cargo/registry target - name: Install musl-tools From 665564420ac79138920876aafbae45d6a4316e6c Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Fri, 10 Jun 2022 16:54:55 +1000 Subject: [PATCH 10/20] Add more bins to test in job "Test installing bins" Signed-off-by: Jiahao XU --- .github/workflows/rust.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index fc05a41e..df27f99e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -91,12 +91,12 @@ jobs: - name: Copy and rename utility run: cp target/${{ matrix.target }}/release/${{ matrix.output }} ${{ matrix.output }} - - name: Test + - name: Test installing bins run: for bin in $bins; do ./${{ matrix.output }} cargo-binstall --no-confirm $bin; $done env: - bins: cargo-binstall + bins: cargo-bindgen cbindgen cargo-deb cargo-llvm-cov cargo-binstall - - name: "Test binstall with manifest" + - name: Test binstall with manifest run: ./${{ matrix.output }} cargo-binstall --manifest-path . --no-confirm - name: Create archive (tgz, linux) From 53c9d667ce08d7494f0c1f1b9f6fc91c27a85623 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Fri, 10 Jun 2022 16:55:21 +1000 Subject: [PATCH 11/20] Enable caching on macos as issue has been fixed Signed-off-by: Jiahao XU --- .github/workflows/rust.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index df27f99e..cf525e4a 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -68,8 +68,6 @@ jobs: - name: Configure caching uses: actions/cache@v2 - # Caching disabled on macos due to https://github.com/actions/cache/issues/403 - if: ${{ matrix.os != 'macos-latest' }} with: key: ${{ matrix.os }}-${{ matrix.target }} path: | From d038e77978f40a8d73d73ce35072dae0b7dedf97 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Fri, 10 Jun 2022 17:02:18 +1000 Subject: [PATCH 12/20] Fix typo in step "Test installing bins" Signed-off-by: Jiahao XU --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index cf525e4a..be604263 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -90,7 +90,7 @@ jobs: run: cp target/${{ matrix.target }}/release/${{ matrix.output }} ${{ matrix.output }} - name: Test installing bins - run: for bin in $bins; do ./${{ matrix.output }} cargo-binstall --no-confirm $bin; $done + run: for bin in $bins; do ./${{ matrix.output }} cargo-binstall --no-confirm $bin; done env: bins: cargo-bindgen cbindgen cargo-deb cargo-llvm-cov cargo-binstall From 57d2b4c3b4d5a2960b0545e0402673c104fdd2b3 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Fri, 10 Jun 2022 17:07:59 +1000 Subject: [PATCH 13/20] Run job "Test binstall" only natively Signed-off-by: Jiahao XU --- .github/workflows/rust.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index be604263..f31346a8 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -24,36 +24,43 @@ jobs: output: cargo-binstall archive: tgz use-cross: false + test: true - target: x86_64-apple-darwin os: macos-latest output: cargo-binstall archive: zip use-cross: false + test: true - target: aarch64-apple-darwin os: macos-latest output: cargo-binstall archive: zip use-cross: false + test: false - target: x86_64-pc-windows-msvc os: windows-latest output: cargo-binstall.exe archive: zip use-cross: false + test: true - target: x86_64-unknown-linux-musl os: ubuntu-latest output: cargo-binstall archive: tgz use-cross: false + test: true - target: armv7-unknown-linux-musleabihf os: ubuntu-20.04 output: cargo-binstall archive: tgz use-cross: true + test: false - target: aarch64-unknown-linux-musl os: ubuntu-latest output: cargo-binstall archive: tgz use-cross: true + test: false steps: - uses: actions/checkout@v2 @@ -90,11 +97,13 @@ jobs: run: cp target/${{ matrix.target }}/release/${{ matrix.output }} ${{ matrix.output }} - name: Test installing bins + if: ${{ matrix.test == 'true' }} run: for bin in $bins; do ./${{ matrix.output }} cargo-binstall --no-confirm $bin; done env: bins: cargo-bindgen cbindgen cargo-deb cargo-llvm-cov cargo-binstall - name: Test binstall with manifest + if: ${{ matrix.test == 'true' }} run: ./${{ matrix.output }} cargo-binstall --manifest-path . --no-confirm - name: Create archive (tgz, linux) From 68942f56e48ca59e4234745d2095c773f4fd777d Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Fri, 10 Jun 2022 17:08:54 +1000 Subject: [PATCH 14/20] Merge two testing step into one in workflow `rust` Signed-off-by: Jiahao XU --- .github/workflows/rust.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index f31346a8..246485ff 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -96,16 +96,14 @@ jobs: - name: Copy and rename utility run: cp target/${{ matrix.target }}/release/${{ matrix.output }} ${{ matrix.output }} - - name: Test installing bins + - name: Test if: ${{ matrix.test == 'true' }} - run: for bin in $bins; do ./${{ matrix.output }} cargo-binstall --no-confirm $bin; done + run: | + for bin in $bins; do ./${{ matrix.output }} cargo-binstall --no-confirm $bin; done + ./${{ matrix.output }} cargo-binstall --manifest-path . --no-confirm env: bins: cargo-bindgen cbindgen cargo-deb cargo-llvm-cov cargo-binstall - - name: Test binstall with manifest - if: ${{ matrix.test == 'true' }} - run: ./${{ matrix.output }} cargo-binstall --manifest-path . --no-confirm - - name: Create archive (tgz, linux) if: ${{ matrix.os != 'macos-latest' && matrix.os != 'windows-latest' }} run: tar -czvf cargo-binstall-${{ matrix.target }}.tgz ${{ matrix.output }} From dc5978e73737e94ddbbc713e466d89422d41bb19 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Fri, 10 Jun 2022 17:12:35 +1000 Subject: [PATCH 15/20] Fix step "Test": Fix invoking `cargo-binstall` directly Signed-off-by: Jiahao XU --- .github/workflows/rust.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 246485ff..72ad6eee 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -99,8 +99,8 @@ jobs: - name: Test if: ${{ matrix.test == 'true' }} run: | - for bin in $bins; do ./${{ matrix.output }} cargo-binstall --no-confirm $bin; done - ./${{ matrix.output }} cargo-binstall --manifest-path . --no-confirm + for bin in $bins; do ./${{ matrix.output }} binstall --no-confirm $bin; done + ./${{ matrix.output }} binstall --manifest-path . --no-confirm cargo-binstall env: bins: cargo-bindgen cbindgen cargo-deb cargo-llvm-cov cargo-binstall From e312a22ba200fbf99a48ae819a512acb52dea2e6 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Fri, 10 Jun 2022 17:19:21 +1000 Subject: [PATCH 16/20] `set -euxo pipefail` in step "Test" Signed-off-by: Jiahao XU --- .github/workflows/rust.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 72ad6eee..294df150 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -99,6 +99,7 @@ jobs: - name: Test if: ${{ matrix.test == 'true' }} run: | + set -euxo pipefail for bin in $bins; do ./${{ matrix.output }} binstall --no-confirm $bin; done ./${{ matrix.output }} binstall --manifest-path . --no-confirm cargo-binstall env: From ea71cede42337a08311c3003d86b3220c88521af Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Fri, 10 Jun 2022 17:28:23 +1000 Subject: [PATCH 17/20] Fix `if` cond for step "Test" Signed-off-by: Jiahao XU --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 294df150..926d6bd6 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -97,7 +97,7 @@ jobs: run: cp target/${{ matrix.target }}/release/${{ matrix.output }} ${{ matrix.output }} - name: Test - if: ${{ matrix.test == 'true' }} + if: ${{ matrix.test }} run: | set -euxo pipefail for bin in $bins; do ./${{ matrix.output }} binstall --no-confirm $bin; done From cfa6090e6e71f21c437c6e4174bfee6cbb163c87 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Fri, 10 Jun 2022 17:32:38 +1000 Subject: [PATCH 18/20] Rm non-existent crate in step "Test" Signed-off-by: Jiahao XU --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 926d6bd6..4efb2cd7 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -103,7 +103,7 @@ jobs: for bin in $bins; do ./${{ matrix.output }} binstall --no-confirm $bin; done ./${{ matrix.output }} binstall --manifest-path . --no-confirm cargo-binstall env: - bins: cargo-bindgen cbindgen cargo-deb cargo-llvm-cov cargo-binstall + bins: cbindgen cargo-deb cargo-llvm-cov cargo-binstall - name: Create archive (tgz, linux) if: ${{ matrix.os != 'macos-latest' && matrix.os != 'windows-latest' }} From fbcfe369da4386a40e187ffa934d2ae05ed21370 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Fri, 10 Jun 2022 18:16:28 +1000 Subject: [PATCH 19/20] Rm cbindgen from `bins` in step "Test" Signed-off-by: Jiahao XU --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 4efb2cd7..0ab5c628 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -103,7 +103,7 @@ jobs: for bin in $bins; do ./${{ matrix.output }} binstall --no-confirm $bin; done ./${{ matrix.output }} binstall --manifest-path . --no-confirm cargo-binstall env: - bins: cbindgen cargo-deb cargo-llvm-cov cargo-binstall + bins: cargo-deb cargo-llvm-cov cargo-binstall - name: Create archive (tgz, linux) if: ${{ matrix.os != 'macos-latest' && matrix.os != 'windows-latest' }} From 4297b13ed95be042a6c34bf0ec8e1d877787b433 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Fri, 10 Jun 2022 18:20:59 +1000 Subject: [PATCH 20/20] Fix testing on Windows Signed-off-by: Jiahao XU --- .github/workflows/rust.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 0ab5c628..ad99d9a5 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -42,7 +42,7 @@ jobs: output: cargo-binstall.exe archive: zip use-cross: false - test: true + test: false - target: x86_64-unknown-linux-musl os: ubuntu-latest output: cargo-binstall @@ -96,8 +96,8 @@ jobs: - name: Copy and rename utility run: cp target/${{ matrix.target }}/release/${{ matrix.output }} ${{ matrix.output }} - - name: Test - if: ${{ matrix.test }} + - name: Test (Unix) + if: ${{ matrix.test && matrix.os != 'windows-latest' }} run: | set -euxo pipefail for bin in $bins; do ./${{ matrix.output }} binstall --no-confirm $bin; done @@ -105,6 +105,12 @@ jobs: env: bins: cargo-deb cargo-llvm-cov cargo-binstall + - name: Test (Windows) + if: ${{ matrix.os == 'windows-latest' }} + run: | + ./${{ matrix.output }} binstall --no-confirm cargo-binstall + ./${{ matrix.output }} binstall --manifest-path . --no-confirm cargo-binstall + - name: Create archive (tgz, linux) if: ${{ matrix.os != 'macos-latest' && matrix.os != 'windows-latest' }} run: tar -czvf cargo-binstall-${{ matrix.target }}.tgz ${{ matrix.output }}