mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-24 22:30:03 +00:00
Speedup ci (#1724)
* Optimize binstalk-git-repo-api Use a dedicated github token in CI Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Speedup CI using `cargo-nextest` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Fix release profile override on Windows Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Optimize unit test in binstalk-registry Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Use `secrets.CI_RELEASE_TEST_GITHUB_TOKEN` for just-setup Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Fix unit testing in justfile Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Add retry on rate limit in unit testing Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Only use `CI_UNIT_TEST_GITHUB_TOKEN` in unit testing Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Fix `test_get_repo_info`: Retry on rate limit Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Fix `test_has_release_artifact_and_download_artifacts` Retry on rate limit Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> --------- Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
52f172c713
commit
3aae883467
5 changed files with 356 additions and 308 deletions
14
.github/workflows/ci.yml
vendored
14
.github/workflows/ci.yml
vendored
|
@ -56,11 +56,14 @@ jobs:
|
||||||
env:
|
env:
|
||||||
# just-setup use binstall to install sccache,
|
# just-setup use binstall to install sccache,
|
||||||
# which works better when we provide it with GITHUB_TOKEN.
|
# which works better when we provide it with GITHUB_TOKEN.
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.CI_RELEASE_TEST_GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
tools: cargo-nextest
|
||||||
|
|
||||||
- run: just test
|
- run: just test
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.CI_TEST_GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.CI_TEST_GITHUB_TOKEN }}
|
||||||
|
CI_UNIT_TEST_GITHUB_TOKEN: ${{ secrets.CI_UNIT_TEST_GITHUB_TOKEN }}
|
||||||
|
|
||||||
cross-check:
|
cross-check:
|
||||||
strategy:
|
strategy:
|
||||||
|
@ -97,7 +100,7 @@ jobs:
|
||||||
env:
|
env:
|
||||||
# just-setup use binstall to install sccache,
|
# just-setup use binstall to install sccache,
|
||||||
# which works better when we provide it with GITHUB_TOKEN.
|
# which works better when we provide it with GITHUB_TOKEN.
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.CI_RELEASE_TEST_GITHUB_TOKEN }}
|
||||||
|
|
||||||
- run: just avoid-dev-deps
|
- run: just avoid-dev-deps
|
||||||
- run: just check
|
- run: just check
|
||||||
|
@ -118,6 +121,10 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: ./.github/actions/just-setup
|
- uses: ./.github/actions/just-setup
|
||||||
|
env:
|
||||||
|
# just-setup use binstall to install sccache,
|
||||||
|
# which works better when we provide it with GITHUB_TOKEN.
|
||||||
|
GITHUB_TOKEN: ${{ secrets.CI_RELEASE_TEST_GITHUB_TOKEN }}
|
||||||
|
|
||||||
- run: just toolchain rustfmt,clippy
|
- run: just toolchain rustfmt,clippy
|
||||||
- run: just avoid-dev-deps
|
- run: just avoid-dev-deps
|
||||||
|
@ -135,7 +142,7 @@ jobs:
|
||||||
uses: cargo-bins/release-meta@v1
|
uses: cargo-bins/release-meta@v1
|
||||||
with:
|
with:
|
||||||
event-data: ${{ toJSON(github.event) }}
|
event-data: ${{ toJSON(github.event) }}
|
||||||
extract-notes-under: '### Release notes'
|
extract-notes-under: "### Release notes"
|
||||||
|
|
||||||
release-dry-run:
|
release-dry-run:
|
||||||
needs: pr-info
|
needs: pr-info
|
||||||
|
@ -283,7 +290,6 @@ jobs:
|
||||||
# and build quite a few unused dependencies.
|
# and build quite a few unused dependencies.
|
||||||
working-directory: crates/detect-targets
|
working-directory: crates/detect-targets
|
||||||
|
|
||||||
|
|
||||||
# Dummy job to have a stable name for the "all tests pass" requirement
|
# Dummy job to have a stable name for the "all tests pass" requirement
|
||||||
tests-pass:
|
tests-pass:
|
||||||
name: Tests pass
|
name: Tests pass
|
||||||
|
|
23
.github/workflows/release-packages.yml
vendored
23
.github/workflows/release-packages.yml
vendored
|
@ -28,10 +28,21 @@ jobs:
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- { o: macos-14, t: x86_64-apple-darwin, r: true }
|
- { o: macos-14, t: x86_64-apple-darwin, r: true }
|
||||||
- { o: macos-14, t: x86_64h-apple-darwin, }
|
- { o: macos-14, t: x86_64h-apple-darwin }
|
||||||
- { o: macos-14, t: aarch64-apple-darwin }
|
- { o: macos-14, t: aarch64-apple-darwin }
|
||||||
- { o: ubuntu-latest, t: x86_64-unknown-linux-gnu, g: 2.17, r: true, c: true }
|
- {
|
||||||
- { o: ubuntu-latest, t: armv7-unknown-linux-gnueabihf, g: 2.17, c: true }
|
o: ubuntu-latest,
|
||||||
|
t: x86_64-unknown-linux-gnu,
|
||||||
|
g: 2.17,
|
||||||
|
r: true,
|
||||||
|
c: true,
|
||||||
|
}
|
||||||
|
- {
|
||||||
|
o: ubuntu-latest,
|
||||||
|
t: armv7-unknown-linux-gnueabihf,
|
||||||
|
g: 2.17,
|
||||||
|
c: true,
|
||||||
|
}
|
||||||
- { o: ubuntu-latest, t: aarch64-unknown-linux-gnu, g: 2.17, c: true }
|
- { o: ubuntu-latest, t: aarch64-unknown-linux-gnu, g: 2.17, c: true }
|
||||||
- { o: ubuntu-latest, t: x86_64-unknown-linux-musl, r: true, c: true }
|
- { o: ubuntu-latest, t: x86_64-unknown-linux-musl, r: true, c: true }
|
||||||
- { o: ubuntu-latest, t: armv7-unknown-linux-musleabihf, c: true }
|
- { o: ubuntu-latest, t: armv7-unknown-linux-musleabihf, c: true }
|
||||||
|
@ -57,16 +68,20 @@ jobs:
|
||||||
- name: Override release profile lto settings
|
- name: Override release profile lto settings
|
||||||
if: inputs.CARGO_PROFILE_RELEASE_LTO
|
if: inputs.CARGO_PROFILE_RELEASE_LTO
|
||||||
run: echo "CARGO_PROFILE_RELEASE_LTO=${{ inputs.CARGO_PROFILE_RELEASE_LTO }}" >> "$GITHUB_ENV"
|
run: echo "CARGO_PROFILE_RELEASE_LTO=${{ inputs.CARGO_PROFILE_RELEASE_LTO }}" >> "$GITHUB_ENV"
|
||||||
|
shell: bash
|
||||||
|
|
||||||
- name: Override release profile codegen-units settings
|
- name: Override release profile codegen-units settings
|
||||||
if: inputs.CARGO_PROFILE_RELEASE_CODEGEN_UNITS
|
if: inputs.CARGO_PROFILE_RELEASE_CODEGEN_UNITS
|
||||||
run: echo "CARGO_PROFILE_RELEASE_CODEGEN_UNITS=${{ inputs.CARGO_PROFILE_RELEASE_CODEGEN_UNITS }}" >> "$GITHUB_ENV"
|
run: echo "CARGO_PROFILE_RELEASE_CODEGEN_UNITS=${{ inputs.CARGO_PROFILE_RELEASE_CODEGEN_UNITS }}" >> "$GITHUB_ENV"
|
||||||
|
shell: bash
|
||||||
|
|
||||||
- uses: ./.github/actions/just-setup
|
- uses: ./.github/actions/just-setup
|
||||||
with:
|
with:
|
||||||
tools: cargo-auditable,rsign2,rage
|
tools: cargo-auditable,rsign2,rage
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
# just-setup use binstall to install sccache,
|
||||||
|
# which works better when we provide it with GITHUB_TOKEN.
|
||||||
|
GITHUB_TOKEN: ${{ secrets.CI_RELEASE_TEST_GITHUB_TOKEN }}
|
||||||
|
|
||||||
- run: just toolchain rust-src
|
- run: just toolchain rust-src
|
||||||
|
|
||||||
|
|
|
@ -508,7 +508,7 @@ mod test {
|
||||||
|
|
||||||
let mut gh_clients = vec![GhApiClient::new(client.clone(), None)];
|
let mut gh_clients = vec![GhApiClient::new(client.clone(), None)];
|
||||||
|
|
||||||
if let Ok(token) = env::var("GITHUB_TOKEN") {
|
if let Ok(token) = env::var("CI_UNIT_TEST_GITHUB_TOKEN") {
|
||||||
gh_clients.push(GhApiClient::new(client, Some(token.into())));
|
gh_clients.push(GhApiClient::new(client, Some(token.into())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -535,30 +535,8 @@ mod test {
|
||||||
let mut tests: Vec<(_, _)> = Vec::new();
|
let mut tests: Vec<(_, _)> = Vec::new();
|
||||||
|
|
||||||
for client in create_client() {
|
for client in create_client() {
|
||||||
for repo in PUBLIC_REPOS {
|
let spawn_get_repo_info_task = |repo| {
|
||||||
let client = client.clone();
|
let client = client.clone();
|
||||||
|
|
||||||
tests.push((
|
|
||||||
Some(RepoInfo::new(repo.clone(), false)),
|
|
||||||
tokio::spawn(async move { client.get_repo_info(&repo).await }),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
for repo in NON_EXISTENT_REPOS {
|
|
||||||
let client = client.clone();
|
|
||||||
|
|
||||||
tests.push((
|
|
||||||
None,
|
|
||||||
tokio::spawn(async move { client.get_repo_info(&repo).await }),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
if client.has_gh_token() {
|
|
||||||
for repo in PRIVATE_REPOS {
|
|
||||||
let client = client.clone();
|
|
||||||
|
|
||||||
tests.push((
|
|
||||||
Some(RepoInfo::new(repo.clone(), true)),
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
loop {
|
loop {
|
||||||
match client.get_repo_info(&repo).await {
|
match client.get_repo_info(&repo).await {
|
||||||
|
@ -568,7 +546,25 @@ mod test {
|
||||||
res => break res,
|
res => break res,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}),
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
for repo in PUBLIC_REPOS {
|
||||||
|
tests.push((
|
||||||
|
Some(RepoInfo::new(repo.clone(), false)),
|
||||||
|
spawn_get_repo_info_task(repo),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
for repo in NON_EXISTENT_REPOS {
|
||||||
|
tests.push((None, spawn_get_repo_info_task(repo)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if client.has_gh_token() {
|
||||||
|
for repo in PRIVATE_REPOS {
|
||||||
|
tests.push((
|
||||||
|
Some(RepoInfo::new(repo.clone(), true)),
|
||||||
|
spawn_get_repo_info_task(repo),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -606,6 +602,20 @@ mod test {
|
||||||
let mut tasks = Vec::new();
|
let mut tasks = Vec::new();
|
||||||
|
|
||||||
for client in create_client() {
|
for client in create_client() {
|
||||||
|
async fn has_release_artifact(
|
||||||
|
client: &GhApiClient,
|
||||||
|
artifact: &GhReleaseArtifact,
|
||||||
|
) -> Result<Option<GhReleaseArtifactUrl>, GhApiError> {
|
||||||
|
loop {
|
||||||
|
match client.has_release_artifact(artifact.clone()).await {
|
||||||
|
Err(GhApiError::RateLimit { retry_after }) => {
|
||||||
|
sleep(retry_after.unwrap_or(DEFAULT_RETRY_AFTER)).await
|
||||||
|
}
|
||||||
|
res => break res,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (release, artifacts) in RELEASES {
|
for (release, artifacts) in RELEASES {
|
||||||
for artifact_name in artifacts {
|
for artifact_name in artifacts {
|
||||||
let client = client.clone();
|
let client = client.clone();
|
||||||
|
@ -632,15 +642,10 @@ mod test {
|
||||||
.into_bytes(),
|
.into_bytes(),
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
let artifact_url = has_release_artifact(&client, &artifact)
|
||||||
let artifact_url = loop {
|
.await
|
||||||
match client.has_release_artifact(artifact.clone()).await {
|
.unwrap()
|
||||||
Err(GhApiError::RateLimit { retry_after }) => {
|
.unwrap();
|
||||||
sleep(retry_after.unwrap_or(DEFAULT_RETRY_AFTER)).await
|
|
||||||
}
|
|
||||||
res => break res.unwrap().unwrap(),
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Some(browser_download_task) = browser_download_task {
|
if let Some(browser_download_task) = browser_download_task {
|
||||||
let artifact_download_data = loop {
|
let artifact_download_data = loop {
|
||||||
|
@ -666,11 +671,13 @@ mod test {
|
||||||
let client = client.clone();
|
let client = client.clone();
|
||||||
tasks.push(tokio::spawn(async move {
|
tasks.push(tokio::spawn(async move {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
client
|
has_release_artifact(
|
||||||
.has_release_artifact(GhReleaseArtifact {
|
&client,
|
||||||
|
&GhReleaseArtifact {
|
||||||
release,
|
release,
|
||||||
artifact_name: "123z".to_compact_string(),
|
artifact_name: "123z".to_compact_string(),
|
||||||
})
|
}
|
||||||
|
)
|
||||||
.await
|
.await
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
None
|
None
|
||||||
|
@ -683,11 +690,13 @@ mod test {
|
||||||
|
|
||||||
tasks.push(tokio::spawn(async move {
|
tasks.push(tokio::spawn(async move {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
client
|
has_release_artifact(
|
||||||
.has_release_artifact(GhReleaseArtifact {
|
&client,
|
||||||
|
&GhReleaseArtifact {
|
||||||
release,
|
release,
|
||||||
artifact_name: "1234".to_compact_string(),
|
artifact_name: "1234".to_compact_string(),
|
||||||
})
|
}
|
||||||
|
)
|
||||||
.await
|
.await
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
None
|
None
|
||||||
|
|
|
@ -218,7 +218,7 @@ mod test {
|
||||||
|
|
||||||
/// Mark this as an async fn so that you won't accidentally use it in
|
/// Mark this as an async fn so that you won't accidentally use it in
|
||||||
/// sync context.
|
/// sync context.
|
||||||
async fn create_client() -> Client {
|
fn create_client() -> Client {
|
||||||
Client::new(
|
Client::new(
|
||||||
concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")),
|
concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")),
|
||||||
None,
|
None,
|
||||||
|
@ -231,8 +231,16 @@ mod test {
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_crates_io_sparse_registry() {
|
async fn test_crates_io_sparse_registry() {
|
||||||
let client = create_client().await;
|
let client = create_client();
|
||||||
|
|
||||||
|
let crate_name = "cargo-binstall";
|
||||||
|
let version_req = &VersionReq::parse("=1.0.0").unwrap();
|
||||||
|
|
||||||
|
let serialized_manifest_from_sparse_task = tokio::spawn({
|
||||||
|
let client = client.clone();
|
||||||
|
let version_req = version_req.clone();
|
||||||
|
|
||||||
|
async move {
|
||||||
let sparse_registry: Registry = Registry::crates_io_sparse_registry();
|
let sparse_registry: Registry = Registry::crates_io_sparse_registry();
|
||||||
assert!(
|
assert!(
|
||||||
matches!(sparse_registry, Registry::Sparse(_)),
|
matches!(sparse_registry, Registry::Sparse(_)),
|
||||||
|
@ -240,22 +248,23 @@ mod test {
|
||||||
sparse_registry
|
sparse_registry
|
||||||
);
|
);
|
||||||
|
|
||||||
let crate_name = "cargo-binstall";
|
|
||||||
let version_req = &VersionReq::parse("=1.0.0").unwrap();
|
|
||||||
let manifest_from_sparse = sparse_registry
|
let manifest_from_sparse = sparse_registry
|
||||||
.fetch_crate_matched(client.clone(), crate_name, version_req)
|
.fetch_crate_matched(client, crate_name, &version_req)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
to_string(&manifest_from_sparse).unwrap()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let manifest_from_cratesio_api = fetch_crate_cratesio_api(client, crate_name, version_req)
|
let manifest_from_cratesio_api = fetch_crate_cratesio_api(client, crate_name, version_req)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let serialized_manifest_from_sparse = to_string(&manifest_from_sparse).unwrap();
|
|
||||||
let serialized_manifest_from_cratesio_api = to_string(&manifest_from_cratesio_api).unwrap();
|
let serialized_manifest_from_cratesio_api = to_string(&manifest_from_cratesio_api).unwrap();
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
serialized_manifest_from_sparse,
|
serialized_manifest_from_sparse_task.await.unwrap(),
|
||||||
serialized_manifest_from_cratesio_api
|
serialized_manifest_from_cratesio_api
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -263,8 +272,16 @@ mod test {
|
||||||
#[cfg(feature = "git")]
|
#[cfg(feature = "git")]
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_crates_io_git_registry() {
|
async fn test_crates_io_git_registry() {
|
||||||
let client = create_client().await;
|
let client = create_client();
|
||||||
|
|
||||||
|
let crate_name = "cargo-binstall";
|
||||||
|
let version_req = &VersionReq::parse("=1.0.0").unwrap();
|
||||||
|
|
||||||
|
let serialized_manifest_from_git_task = tokio::spawn({
|
||||||
|
let version_req = version_req.clone();
|
||||||
|
let client = client.clone();
|
||||||
|
|
||||||
|
async move {
|
||||||
let git_registry: Registry = "https://github.com/rust-lang/crates.io-index"
|
let git_registry: Registry = "https://github.com/rust-lang/crates.io-index"
|
||||||
.parse()
|
.parse()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -274,23 +291,23 @@ mod test {
|
||||||
git_registry
|
git_registry
|
||||||
);
|
);
|
||||||
|
|
||||||
let crate_name = "cargo-binstall";
|
|
||||||
let version_req = &VersionReq::parse("=1.0.0").unwrap();
|
|
||||||
let manifest_from_git = git_registry
|
let manifest_from_git = git_registry
|
||||||
.fetch_crate_matched(client.clone(), crate_name, version_req)
|
.fetch_crate_matched(client, crate_name, &version_req)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
to_string(&manifest_from_git).unwrap()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let manifest_from_cratesio_api = Registry::default()
|
let manifest_from_cratesio_api = Registry::default()
|
||||||
.fetch_crate_matched(client, crate_name, version_req)
|
.fetch_crate_matched(client, crate_name, version_req)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let serialized_manifest_from_git = to_string(&manifest_from_git).unwrap();
|
|
||||||
let serialized_manifest_from_cratesio_api = to_string(&manifest_from_cratesio_api).unwrap();
|
let serialized_manifest_from_cratesio_api = to_string(&manifest_from_cratesio_api).unwrap();
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
serialized_manifest_from_git,
|
serialized_manifest_from_git_task.await.unwrap(),
|
||||||
serialized_manifest_from_cratesio_api
|
serialized_manifest_from_cratesio_api
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
3
justfile
3
justfile
|
@ -260,7 +260,8 @@ e2e-test-tls: (e2e-test "tls" "1.2") (e2e-test "tls" "1.3")
|
||||||
e2e-tests: e2e-test-live e2e-test-manifest-path e2e-test-git e2e-test-other-repos e2e-test-strategies e2e-test-version-syntax e2e-test-upgrade e2e-test-tls e2e-test-self-upgrade-no-symlink e2e-test-uninstall e2e-test-subcrate e2e-test-no-track e2e-test-registries e2e-test-signing e2e-test-continue-on-failure e2e-test-private-github-repo
|
e2e-tests: e2e-test-live e2e-test-manifest-path e2e-test-git e2e-test-other-repos e2e-test-strategies e2e-test-version-syntax e2e-test-upgrade e2e-test-tls e2e-test-self-upgrade-no-symlink e2e-test-uninstall e2e-test-subcrate e2e-test-no-track e2e-test-registries e2e-test-signing e2e-test-continue-on-failure e2e-test-private-github-repo
|
||||||
|
|
||||||
unit-tests: print-env
|
unit-tests: print-env
|
||||||
{{cargo-bin}} test {{cargo-build-args}}
|
cargo nextest run {{cargo-build-args}}
|
||||||
|
cargo test --doc {{cargo-build-args}}
|
||||||
|
|
||||||
test: unit-tests build e2e-tests
|
test: unit-tests build e2e-tests
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue