Merge pull request #767 from aya-rs/fix-ci-again

github: fix CI
pull/766/head
Tamir Duberstein 1 year ago committed by GitHub
commit 116ddbd18d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -198,9 +198,10 @@ jobs:
run: | run: |
set -euxo pipefail set -euxo pipefail
brew update brew update
brew install dpkg findutils gnu-tar llvm pkg-config # https://github.com/actions/setup-python/issues/577
# Workaround for https://github.com/Homebrew/homebrew-core/pull/139492. find /usr/local/bin -type l -exec sh -c 'readlink -f "$1" \
brew reinstall qemu | grep -q ^/Library/Frameworks/Python.framework/Versions/' _ {} \; -exec rm -v {} \;
brew install dpkg findutils gnu-tar llvm pkg-config qemu
echo /usr/local/opt/findutils/libexec/gnubin >> $GITHUB_PATH echo /usr/local/opt/findutils/libexec/gnubin >> $GITHUB_PATH
echo /usr/local/opt/gnu-tar/libexec/gnubin >> $GITHUB_PATH echo /usr/local/opt/gnu-tar/libexec/gnubin >> $GITHUB_PATH
echo /usr/local/opt/llvm/bin >> $GITHUB_PATH echo /usr/local/opt/llvm/bin >> $GITHUB_PATH
@ -222,7 +223,7 @@ jobs:
# linux-image-5.10.0-23-cloud-arm64-unsigned_5.10.179-3_arm64.deb \ # linux-image-5.10.0-23-cloud-arm64-unsigned_5.10.179-3_arm64.deb \
printf '%s\0' \ printf '%s\0' \
linux-image-6.1.0-10-cloud-arm64-unsigned_6.1.38-2_arm64.deb \ linux-image-6.1.0-10-cloud-arm64-unsigned_6.1.38-2_arm64.deb \
linux-image-6.4.0-2-cloud-arm64-unsigned_6.4.4-3_arm64.deb \ linux-image-6.4.0-3-cloud-arm64-unsigned_6.4.11-1_arm64.deb \
| xargs -0 -t -P0 -I {} wget -nd -nv -P test/.tmp/debian-kernels/arm64 ftp://ftp.us.debian.org/debian/pool/main/l/linux/{} | xargs -0 -t -P0 -I {} wget -nd -nv -P test/.tmp/debian-kernels/arm64 ftp://ftp.us.debian.org/debian/pool/main/l/linux/{}
- name: Download debian kernels - name: Download debian kernels
@ -235,7 +236,7 @@ jobs:
# linux-image-5.10.0-23-cloud-amd64-unsigned_5.10.179-3_amd64.deb \ # linux-image-5.10.0-23-cloud-amd64-unsigned_5.10.179-3_amd64.deb \
printf '%s\0' \ printf '%s\0' \
linux-image-6.1.0-10-cloud-amd64-unsigned_6.1.38-2_amd64.deb \ linux-image-6.1.0-10-cloud-amd64-unsigned_6.1.38-2_amd64.deb \
linux-image-6.4.0-2-cloud-amd64-unsigned_6.4.4-3_amd64.deb \ linux-image-6.4.0-3-cloud-amd64-unsigned_6.4.11-1_amd64.deb \
| xargs -0 -t -P0 -I {} wget -nd -nv -P test/.tmp/debian-kernels/amd64 ftp://ftp.us.debian.org/debian/pool/main/l/linux/{} | xargs -0 -t -P0 -I {} wget -nd -nv -P test/.tmp/debian-kernels/amd64 ftp://ftp.us.debian.org/debian/pool/main/l/linux/{}
- name: Extract debian kernels - name: Extract debian kernels

@ -78,7 +78,7 @@ num_enum = { version = "0.7", default-features = false }
object = { version = "0.32", default-features = false } object = { version = "0.32", default-features = false }
proc-macro-error = { version = "1.0", default-features = false } proc-macro-error = { version = "1.0", default-features = false }
proc-macro2 = { version = "1", default-features = false } proc-macro2 = { version = "1", default-features = false }
public-api = { version = "0.31.2", default-features = false } public-api = { version = "0.32.0", default-features = false }
quote = { version = "1", default-features = false } quote = { version = "1", default-features = false }
rbpf = { version = "0.2.0", default-features = false } rbpf = { version = "0.2.0", default-features = false }
rustdoc-json = { version = "0.8.6", default-features = false } rustdoc-json = { version = "0.8.6", default-features = false }

@ -13,3 +13,30 @@ pub fn exec(cmd: &mut Command) -> Result<()> {
} }
Ok(()) Ok(())
} }
#[derive(Debug)]
pub struct Errors<E>(Vec<E>);
impl<E> Errors<E> {
pub fn new(errors: Vec<E>) -> Self {
Self(errors)
}
}
impl<E> std::fmt::Display for Errors<E>
where
E: std::fmt::Debug,
{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let Self(errors) = self;
for (i, error) in errors.iter().enumerate() {
if i != 0 {
writeln!(f)?;
}
write!(f, "{:?}", error)?;
}
Ok(())
}
}
impl<E> std::error::Error for Errors<E> where E: std::fmt::Debug {}

@ -10,6 +10,7 @@ use cargo_metadata::{Metadata, Package};
use clap::Parser; use clap::Parser;
use dialoguer::{theme::ColorfulTheme, Confirm}; use dialoguer::{theme::ColorfulTheme, Confirm};
use diff::{lines, Result as Diff}; use diff::{lines, Result as Diff};
use xtask::Errors;
#[derive(Debug, Parser)] #[derive(Debug, Parser)]
pub struct Options { pub struct Options {
@ -37,34 +38,36 @@ pub fn public_api(options: Options, metadata: Metadata) -> Result<()> {
workspace_root, workspace_root,
packages, packages,
.. ..
} = &metadata; } = metadata;
let errors = packages let errors: Vec<_> = packages
.iter() .into_iter()
.fold(String::new(), |mut buf, Package { name, publish, .. }| { .map(|Package { name, publish, .. }| {
if !matches!(publish, Some(publish) if publish.is_empty()) { if matches!(publish, Some(publish) if publish.is_empty()) {
match check_package_api(name, toolchain, bless, workspace_root.as_std_path()) { Ok(())
Ok(diff) => { } else {
if !diff.is_empty() { let diff = check_package_api(&name, toolchain, bless, workspace_root.as_std_path())
writeln!( .with_context(|| format!("{name} failed to check public API"))?;
&mut buf, if diff.is_empty() {
"{name} public API changed; re-run with --bless. diff:\n{diff}" Ok(())
) } else {
.unwrap(); Err(anyhow::anyhow!(
} "{name} public API changed; re-run with --bless. diff:\n{diff}"
} ))
Err(err) => {
writeln!(&mut buf, "{name} failed to check public API: {err}").unwrap();
}
} }
} }
buf })
}); .filter_map(|result| match result {
Ok(()) => None,
Err(err) => Some(err),
})
.collect();
if !errors.is_empty() { if errors.is_empty() {
bail!("public API errors:\n{errors}") Ok(())
} else {
Err(Errors::new(errors).into())
} }
Ok(())
} }
fn check_package_api( fn check_package_api(

@ -13,7 +13,7 @@ use std::{
use anyhow::{anyhow, bail, Context as _, Result}; use anyhow::{anyhow, bail, Context as _, Result};
use cargo_metadata::{Artifact, CompilerMessage, Message, Target}; use cargo_metadata::{Artifact, CompilerMessage, Message, Target};
use clap::Parser; use clap::Parser;
use xtask::{exec, AYA_BUILD_INTEGRATION_BPF}; use xtask::{exec, Errors, AYA_BUILD_INTEGRATION_BPF};
#[derive(Parser)] #[derive(Parser)]
enum Environment { enum Environment {
@ -104,24 +104,6 @@ where
Ok(executables) Ok(executables)
} }
#[derive(Debug)]
struct Errors(Vec<anyhow::Error>);
impl std::fmt::Display for Errors {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let Self(errors) = self;
for (i, error) in errors.iter().enumerate() {
if i != 0 {
writeln!(f)?;
}
write!(f, "{:?}", error)?;
}
Ok(())
}
}
impl std::error::Error for Errors {}
/// Build and run the project. /// Build and run the project.
pub fn run(opts: Options) -> Result<()> { pub fn run(opts: Options) -> Result<()> {
let Options { let Options {
@ -547,7 +529,7 @@ pub fn run(opts: Options) -> Result<()> {
if errors.is_empty() { if errors.is_empty() {
Ok(()) Ok(())
} else { } else {
Err(Errors(errors).into()) Err(Errors::new(errors).into())
} }
} }
} }

Loading…
Cancel
Save