Skip to content

Commit

Permalink
Test default pkg-url for GitLab and BitBucket (rust-lang#322)
Browse files Browse the repository at this point in the history
* Test default `pkt-url` for GitLab and BitBucket
* Fail if `cargo-build` is called when testing GitLab/BitBucket
* Fix use of `remote_exists` in `GhCrateMeta::launch_baseline_find_tasks`
   
   If `Method::HEAD` fails, try `Method::GET` since some servers reject
   `Method::HEAD`, e.g. bbuseruploads.s3.amazonaws.com

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
  • Loading branch information
NobodyXu authored Aug 27, 2022
1 parent f973d32 commit e39a02a
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 3 deletions.
15 changes: 15 additions & 0 deletions .github/scripts/bitbucket-test-Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "cargo-binstall"
description = "Rust binary package installer for CI integration"
repository = "https://bitbucket.org/nobodyxusdcdc/hello-world"
version = "0.12.0"
rust-version = "1.61.0"
authors = ["ryan <ryan@kurte.nz>"]
edition = "2021"
license = "GPL-3.0"

[package.metadata.binstall]
bin-dir = "{ bin }{ binary-ext }"

[[bin]]
name = "cargo-binstall"
4 changes: 4 additions & 0 deletions .github/scripts/fake-cargo/cargo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

echo Always returns 1 to prevent use of "cargo-build"
exit 1
15 changes: 15 additions & 0 deletions .github/scripts/gitlab-test-Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "cargo-binstall"
description = "Rust binary package installer for CI integration"
repository = "https://gitlab.kitware.com/NobodyXu/hello-world"
version = "0.2.0"
rust-version = "1.61.0"
authors = ["ryan <ryan@kurte.nz>"]
edition = "2021"
license = "GPL-3.0"

[package.metadata.binstall]
bin-dir = "{ bin }{ binary-ext }"

[[bin]]
name = "cargo-binstall"
19 changes: 19 additions & 0 deletions .github/scripts/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,22 @@ cargo binstall --help >/dev/null
"./$1" binstall --no-confirm cargo-binstall@0.11.0
"./$1" binstall --no-confirm cargo-binstall@0.11.0 | grep -q 'cargo-binstall v0.11.0 is already installed'
"./$1" binstall --no-confirm cargo-binstall@^0.11.0 | grep -q -v 'cargo-binstall v0.11.0 is already installed'

# Test default GitLab pkg-url templates
test_resources=".github/scripts"
PATH="$test_resources/fake-cargo:$PATH"

"./$1" binstall \
--force \
--manifest-path "$test_resources/gitlab-test-Cargo.toml" \
--log-level debug \
--no-confirm \
cargo-binstall

# Test default BitBucket pkg-url templates
"./$1" binstall \
--force \
--manifest-path "$test_resources/bitbucket-test-Cargo.toml" \
--log-level debug \
--no-confirm \
cargo-binstall
8 changes: 5 additions & 3 deletions crates/lib/src/fetchers/gh_crate_meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ impl GhCrateMeta {
AutoAbortJoinHandle::spawn(async move {
debug!("Checking for package at: '{url}'");

remote_exists(client, url.clone(), Method::HEAD)
.await
.map(|exists| exists.then_some((url, pkg_fmt)))
Ok(
(remote_exists(client.clone(), url.clone(), Method::HEAD).await?
|| remote_exists(client, url.clone(), Method::GET).await?)
.then_some((url, pkg_fmt)),
)
})
})
}
Expand Down

0 comments on commit e39a02a

Please sign in to comment.