mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 13:05:32 +09:00
fix(ci): retry the release history read in desktop builds (#3457)
This commit is contained in:
1 parent
abcb5cb814
commit
8d8a29377c
1 file changed
+23
-11
+23
-11
@@ -725,29 +725,35 @@ struct GitRef {
|
|||||||
name: String,
|
name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
const PUBLISH_ATTEMPTS: u64 = 3;
|
const GITHUB_ATTEMPTS: u64 = 3;
|
||||||
|
|
||||||
|
fn wait_before_retry(attempt: u64) {
|
||||||
|
thread::sleep(Duration::from_secs(attempt * 15));
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn run(args: ReleaseArgs) -> Result<()> {
|
pub async fn run(args: ReleaseArgs) -> Result<()> {
|
||||||
match args.command {
|
match args.command {
|
||||||
ReleaseCommand::Publish(args) => retry_publish(
|
ReleaseCommand::Publish(args) => retry(
|
||||||
PUBLISH_ATTEMPTS,
|
"Release publish",
|
||||||
|attempt| thread::sleep(Duration::from_secs(attempt * 15)),
|
GITHUB_ATTEMPTS,
|
||||||
|
wait_before_retry,
|
||||||
|| publish(args.clone()),
|
|| publish(args.clone()),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn retry_publish(
|
fn retry<T>(
|
||||||
|
label: &str,
|
||||||
attempts: u64,
|
attempts: u64,
|
||||||
mut wait: impl FnMut(u64),
|
mut wait: impl FnMut(u64),
|
||||||
mut publish: impl FnMut() -> Result<()>,
|
mut operation: impl FnMut() -> Result<T>,
|
||||||
) -> Result<()> {
|
) -> Result<T> {
|
||||||
let mut attempt = 1;
|
let mut attempt = 1;
|
||||||
loop {
|
loop {
|
||||||
match publish() {
|
match operation() {
|
||||||
Ok(()) => return Ok(()),
|
Ok(value) => return Ok(value),
|
||||||
Err(error) if attempt < attempts => {
|
Err(error) if attempt < attempts => {
|
||||||
eprintln!("Release publish attempt {attempt} of {attempts} failed: {error:#}");
|
eprintln!("{label} attempt {attempt} of {attempts} failed: {error:#}");
|
||||||
wait(attempt);
|
wait(attempt);
|
||||||
attempt += 1;
|
attempt += 1;
|
||||||
}
|
}
|
||||||
@@ -948,7 +954,13 @@ fn release_summaries() -> Result<Vec<ReleaseSummary>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn desktop_releases(channel: &str) -> Result<Vec<DesktopPublishedRelease>> {
|
pub(crate) fn desktop_releases(channel: &str) -> Result<Vec<DesktopPublishedRelease>> {
|
||||||
desktop_releases_from(&release_summaries()?, channel)
|
let summaries = retry(
|
||||||
|
"Release history read",
|
||||||
|
GITHUB_ATTEMPTS,
|
||||||
|
wait_before_retry,
|
||||||
|
release_summaries,
|
||||||
|
)?;
|
||||||
|
desktop_releases_from(&summaries, channel)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn desktop_releases_from(
|
fn desktop_releases_from(
|
||||||
|
|||||||
Reference in new issue
Block a user