-
-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add custom registry support #1048
Open
fujiapple852
wants to merge
5
commits into
obi1kenobi:main
Choose a base branch
from
fujiapple852:feat-custom-registry
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7152321
Fixed regex for 'CPU features'
fujiapple852 696d91a
Add third party registry support
drewkett 89085e7
Update README with respect to now supported custom registries
drewkett 08933bb
Fixup after rebasing third party registry support on latest `main`
fujiapple852 fd93369
Add custom registry test
fujiapple852 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[registries] | ||
custom-registry = { index = "sparse+http://127.0.0.1:5000/" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# needed for this test | ||
!.cargo/config.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
publish = false | ||
name = "custom_registry" | ||
version = "0.1.1" | ||
edition = "2021" | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub struct Dummy; | ||
pub struct DummyNew; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[registries] | ||
custom-registry = { index = "sparse+http://127.0.0.1:5000/" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# needed for this test | ||
!.cargo/config.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
publish = false | ||
name = "custom_registry" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub struct Dummy; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"dl":"http://127.0.0.1:5000/crates/{lowerprefix}/{crate}/{version}.crate","api":null,"auth-required":false} |
Binary file added
BIN
+886 Bytes
test_crates/custom_registry/registry/crates/cu/st/custom_registry/0.1.0.crate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"name":"custom_registry","vers":"0.1.0","deps":[],"cksum":"d0ad6b64ea3140e5d859432285042abe32bf3ec332b0d7d8869074bc9c159d7f","features":{},"yanked":false,"v":2} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
version = "1" | ||
base_url = "http://127.0.0.1:5000/" | ||
auth_required = false | ||
|
||
[html] | ||
enabled = false | ||
suggested_registry_name = "custom-registry" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
use assert_cmd::Command; | ||
use axum::Router; | ||
use std::net::SocketAddr; | ||
use std::str::FromStr; | ||
use std::time::Duration; | ||
use tokio_util::sync::CancellationToken; | ||
use tower_http::services::ServeDir; | ||
use tower_http::timeout::TimeoutLayer; | ||
|
||
const HOST: &str = "127.0.0.1"; | ||
const PORT: u16 = 5000; | ||
|
||
#[tokio::test] | ||
async fn test_custom_registry() { | ||
let token = CancellationToken::new(); | ||
let cloned_token = token.clone(); | ||
tokio::join!( | ||
async { | ||
tokio::time::timeout(Duration::from_secs(10), async { | ||
while reqwest::get(format!("http://{HOST}:{PORT}")).await.is_err() { | ||
tokio::time::sleep(Duration::from_millis(100)).await; | ||
} | ||
tokio::task::spawn_blocking(move || verify_custom_registry(token)) | ||
.await | ||
.expect("registry failure"); | ||
}) | ||
.await | ||
.expect("timeout failure"); | ||
}, | ||
serve(using_serve_dir(), cloned_token) | ||
); | ||
} | ||
|
||
async fn serve(app: Router, token: CancellationToken) { | ||
let addr = SocketAddr::from_str(&format!("{HOST}:{PORT}")).expect("Failed to parse HOST:PORT"); | ||
let listener = tokio::net::TcpListener::bind(addr) | ||
.await | ||
.expect("failed to bind"); | ||
axum::serve( | ||
listener, | ||
app.layer(TimeoutLayer::new(Duration::from_secs(10))), | ||
) | ||
.with_graceful_shutdown(shutdown_signal(token)) | ||
.await | ||
.expect("failed to serve"); | ||
} | ||
|
||
fn using_serve_dir() -> Router { | ||
Router::new().nest_service("/", ServeDir::new("test_crates/custom_registry/registry")) | ||
} | ||
|
||
fn verify_custom_registry(token: CancellationToken) { | ||
let mut cmd = | ||
Command::cargo_bin("cargo-semver-checks").expect("failed to execute cargo-semver-checks"); | ||
let result = cmd | ||
.current_dir("test_crates/custom_registry/new") | ||
.args(["semver-checks", "--registry", "custom-registry"]) | ||
.assert(); | ||
token.cancel(); | ||
result.success(); | ||
} | ||
|
||
async fn shutdown_signal(token: CancellationToken) { | ||
tokio::select! { | ||
_ = token.cancelled() => {} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@drewkett @obi1kenobi I wasn't sure what to do here, thoughts?