|
6 | 6 | anyhow::{anyhow, Result},
|
7 | 7 | clap::ArgMatches,
|
8 | 8 | futures::StreamExt,
|
9 |
| - octocrab::{Octocrab, OctocrabBuilder}, |
| 9 | + octocrab::{models::workflows::WorkflowListArtifact, Octocrab, OctocrabBuilder}, |
10 | 10 | once_cell::sync::Lazy,
|
11 |
| - serde::Deserialize, |
12 | 11 | std::{
|
13 | 12 | collections::{BTreeMap, BTreeSet},
|
14 | 13 | io::Read,
|
@@ -50,30 +49,10 @@ static SUFFIXES_BY_TRIPLE: Lazy<BTreeMap<&'static str, Vec<&'static str>>> = Laz
|
50 | 49 | h
|
51 | 50 | });
|
52 | 51 |
|
53 |
| -#[derive(Clone, Debug, Deserialize)] |
54 |
| -struct Artifact { |
55 |
| - archive_download_url: String, |
56 |
| - created_at: String, |
57 |
| - expired: bool, |
58 |
| - expires_at: String, |
59 |
| - id: u64, |
60 |
| - name: String, |
61 |
| - node_id: String, |
62 |
| - size_in_bytes: u64, |
63 |
| - updated_at: String, |
64 |
| - url: String, |
65 |
| -} |
66 |
| - |
67 |
| -#[derive(Clone, Debug, Deserialize)] |
68 |
| -struct Artifacts { |
69 |
| - artifacts: Vec<Artifact>, |
70 |
| - total_count: u64, |
71 |
| -} |
72 |
| - |
73 |
| -async fn fetch_artifact(client: &Octocrab, artifact: Artifact) -> Result<bytes::Bytes> { |
| 52 | +async fn fetch_artifact(client: &Octocrab, artifact: WorkflowListArtifact) -> Result<bytes::Bytes> { |
74 | 53 | println!("downloading {}", artifact.name);
|
75 | 54 | let res = client
|
76 |
| - .execute(client.request_builder(&artifact.archive_download_url, reqwest::Method::GET)) |
| 55 | + .execute(client.request_builder(artifact.archive_download_url, reqwest::Method::GET)) |
77 | 56 | .await?;
|
78 | 57 |
|
79 | 58 | Ok(res.bytes().await?)
|
@@ -125,17 +104,19 @@ pub async fn command_fetch_release_distributions(args: &ArgMatches<'_>) -> Resul
|
125 | 104 | let mut fs = vec![];
|
126 | 105 |
|
127 | 106 | for run in runs {
|
128 |
| - let res = client |
129 |
| - .execute(client.request_builder(run.artifacts_url, reqwest::Method::GET)) |
| 107 | + let page = client |
| 108 | + .actions() |
| 109 | + .list_workflow_run_artifacts(org, repo, run.id) |
| 110 | + .send() |
130 | 111 | .await?;
|
131 | 112 |
|
132 |
| - if !res.status().is_success() { |
133 |
| - return Err(anyhow!("non-HTTP 200 fetching artifacts")); |
134 |
| - } |
135 |
| - |
136 |
| - let artifacts: Artifacts = res.json().await?; |
| 113 | + let artifacts = client |
| 114 | + .all_pages::<octocrab::models::workflows::WorkflowListArtifact>( |
| 115 | + page.value.expect("untagged request should have page"), |
| 116 | + ) |
| 117 | + .await?; |
137 | 118 |
|
138 |
| - for artifact in artifacts.artifacts { |
| 119 | + for artifact in artifacts { |
139 | 120 | if matches!(
|
140 | 121 | artifact.name.as_str(),
|
141 | 122 | "pythonbuild" | "sccache" | "toolchain"
|
|
0 commit comments