xtask: Use reqwest to fetch gen_init_cpio.c

pull/1208/head
WANG Rui 3 months ago
parent 50ae0ee099
commit 4f1cea3a51

@ -316,7 +316,7 @@ jobs:
run: | run: |
set -euxo pipefail set -euxo pipefail
find test/.tmp -name 'vmlinuz-*' -print0 | xargs -t -0 \ find test/.tmp -name 'vmlinuz-*' -print0 | xargs -t -0 \
cargo xtask integration-test vm --cache-dir test/.tmp --github-api-token ${{ secrets.GITHUB_TOKEN }} cargo xtask integration-test vm --cache-dir test/.tmp
# Provides a single status check for the entire build workflow. # Provides a single status check for the entire build workflow.
# This is used for merge automation, like Mergify, since GH actions # This is used for merge automation, like Mergify, since GH actions

@ -60,7 +60,6 @@ edition = "2024"
# them to do that, but in the meantime we need to be careful. # them to do that, but in the meantime we need to be careful.
[workspace.dependencies] [workspace.dependencies]
anyhow = { version = "1", default-features = false } anyhow = { version = "1", default-features = false }
base64 = { version = "0.22.1", default-features = false }
assert_matches = { version = "1.5.0", default-features = false } assert_matches = { version = "1.5.0", default-features = false }
async-io = { version = "2.0", default-features = false } async-io = { version = "2.0", default-features = false }
bindgen = { version = "0.71", default-features = false } bindgen = { version = "0.71", default-features = false }
@ -82,7 +81,6 @@ netns-rs = { version = "0.1", default-features = false }
nix = { version = "0.29.0", default-features = false } nix = { version = "0.29.0", default-features = false }
num_enum = { version = "0.7", default-features = false } num_enum = { version = "0.7", default-features = false }
object = { version = "0.36", default-features = false } object = { version = "0.36", default-features = false }
octorust = { version = "0.9.0", default-features = false }
once_cell = { version = "1.20.1", default-features = false } once_cell = { version = "1.20.1", default-features = false }
proc-macro2 = { version = "1", default-features = false } proc-macro2 = { version = "1", default-features = false }
proc-macro2-diagnostics = { version = "0.10.1", default-features = false } proc-macro2-diagnostics = { version = "0.10.1", default-features = false }
@ -90,6 +88,7 @@ public-api = { version = "0.44.0", default-features = false }
quote = { version = "1", default-features = false } quote = { version = "1", default-features = false }
rand = { version = "0.9", default-features = false } rand = { version = "0.9", default-features = false }
rbpf = { version = "0.3.0", default-features = false } rbpf = { version = "0.3.0", default-features = false }
reqwest = { version = "0.12", default-features = false }
rustdoc-json = { version = "0.9.0", default-features = false } rustdoc-json = { version = "0.9.0", default-features = false }
rustup-toolchain = { version = "0.1.5", default-features = false } rustup-toolchain = { version = "0.1.5", default-features = false }
rustversion = { version = "1.0.0", default-features = false } rustversion = { version = "1.0.0", default-features = false }

@ -12,16 +12,15 @@ edition.workspace = true
[dependencies] [dependencies]
anyhow = { workspace = true, features = ["std"] } anyhow = { workspace = true, features = ["std"] }
aya-tool = { path = "../aya-tool", version = "0.1.0", default-features = false } aya-tool = { path = "../aya-tool", version = "0.1.0", default-features = false }
base64 = { workspace = true, features = ["std"] }
cargo_metadata = { workspace = true } cargo_metadata = { workspace = true }
clap = { workspace = true, features = ["derive"] } clap = { workspace = true, features = ["derive"] }
dialoguer = { workspace = true } dialoguer = { workspace = true }
diff = { workspace = true } diff = { workspace = true }
indoc = { workspace = true } indoc = { workspace = true }
octorust = { workspace = true, features = ["rustls-tls"] }
proc-macro2 = { workspace = true } proc-macro2 = { workspace = true }
public-api = { workspace = true } public-api = { workspace = true }
quote = { workspace = true } quote = { workspace = true }
reqwest = { workspace = true, features = ["rustls-tls"] }
rustdoc-json = { workspace = true } rustdoc-json = { workspace = true }
rustup-toolchain = { workspace = true } rustup-toolchain = { workspace = true }
syn = { workspace = true } syn = { workspace = true }

@ -10,7 +10,6 @@ use std::{
}; };
use anyhow::{Context as _, Result, anyhow, bail}; use anyhow::{Context as _, Result, anyhow, bail};
use base64::engine::Engine as _;
use cargo_metadata::{Artifact, CompilerMessage, Message, Target}; use cargo_metadata::{Artifact, CompilerMessage, Message, Target};
use clap::Parser; use clap::Parser;
use xtask::{AYA_BUILD_INTEGRATION_BPF, Errors}; use xtask::{AYA_BUILD_INTEGRATION_BPF, Errors};
@ -29,12 +28,6 @@ enum Environment {
#[clap(long)] #[clap(long)]
cache_dir: PathBuf, cache_dir: PathBuf,
/// The Github API token to use if network requests to Github are made.
///
/// This may be required if Github rate limits are exceeded.
#[clap(long)]
github_api_token: Option<String>,
/// The kernel images to use. /// The kernel images to use.
/// ///
/// You can download some images with: /// You can download some images with:
@ -180,7 +173,6 @@ pub fn run(opts: Options) -> Result<()> {
} }
Environment::VM { Environment::VM {
cache_dir, cache_dir,
github_api_token,
kernel_image, kernel_image,
} => { } => {
// The user has asked us to run the tests on a VM. This is involved; strap in. // The user has asked us to run the tests on a VM. This is involved; strap in.
@ -206,31 +198,17 @@ pub fn run(opts: Options) -> Result<()> {
.try_exists() .try_exists()
.context("failed to check existence of gen_init_cpio")? .context("failed to check existence of gen_init_cpio")?
{ {
// TODO(https://github.com/oxidecomputer/third-party-api-clients/issues/96): Use ETag-based caching. let content = tokio::runtime::Builder::new_current_thread()
let client = octorust::Client::new(
String::from("aya-xtask-integration-test-run"),
github_api_token.map(octorust::auth::Credentials::Token),
)?;
let octorust::Response {
status: _,
headers: _,
body: octorust::types::ContentFile { mut content, .. },
} = tokio::runtime::Builder::new_current_thread()
.enable_all() .enable_all()
.build() .build()
.unwrap() .unwrap()
.block_on(client.repos().get_content_file( .block_on(async {
"torvalds", reqwest::get("https://github.com/torvalds/linux/raw/refs/heads/master/usr/gen_init_cpio.c")
"linux", .await?
"usr/gen_init_cpio.c", .bytes()
"master", .await
)) })
.context("failed to download gen_init_cpio.c")?; .context("failed to download gen_init_cpio.c")?;
// Github very helpfully wraps their base64 at 10 columns /s.
content.retain(|c| !c.is_whitespace());
let content = base64::engine::general_purpose::STANDARD
.decode(content)
.context("failed to decode gen_init_cpio.c")?;
let mut clang = Command::new("clang"); let mut clang = Command::new("clang");
clang clang

Loading…
Cancel
Save