Unverified Commit 11c61f65 authored by John DiSanti's avatar John DiSanti Committed by GitHub
Browse files

Fix SDK canary by pinning SDK versions to smithy-rs versions (#1145)

* Move canary-runner tool from aws-sdk-rust

* Commonize git shell operations

* Centralize package categorization logic

* Pin smithy-rs revisions to SDK versions for the canary

* Incorporate feedback
parent 4c7515f6
Loading
Loading
Loading
Loading
+1917 −0

File added.

Preview size limit exceeded, changes collapsed.

+28 −0
Original line number Diff line number Diff line
[package]
name = "canary-runner"
version = "0.1.0"
authors = ["AWS Rust SDK Team <aws-sdk-rust@amazon.com>"]
description = "Tool used to run the canary tests in CI"
edition = "2018"
license = "Apache-2.0"
publish = false

[workspace]

[dependencies]
anyhow = "1"
aws-config = "0.3"
aws-sdk-cloudwatch = "0.3"
aws-sdk-lambda = "0.3"
aws-sdk-s3 = "0.3"
base64 = "0.13"
crates_io_api = "0.7"
lazy_static = "1"
semver = "1"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
structopt = "0.3"
tokio = { version = "1", features = ["full"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] }
smithy-rs-tool-common = { version = "0.1", path = "../../smithy-rs-tool-common", features = ["async-shell"] }
+11 −0
Original line number Diff line number Diff line
#!/bin/bash
#
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0.
#
# Run by CI to check the canary-lambda
set -e
cd "$(dirname $0)"

cargo test
cargo clippy
+51 −0
Original line number Diff line number Diff line
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0.
 */

use anyhow::Result;
use crates_io_api::AsyncClient;
use lazy_static::lazy_static;
use serde::Serialize;
use std::time::Duration;
use structopt::StructOpt;

#[derive(StructOpt, Debug)]
pub struct GenerateMatrixOpt {
    #[structopt(short, long)]
    sdk_versions: u8,

    #[structopt(short, long)]
    rust_versions: Vec<String>,
}

lazy_static! {
    static ref CRATES_IO_CLIENT: AsyncClient = AsyncClient::new(
        "AWS_RUST_SDK_PUBLISHER (aws-sdk-rust@amazon.com)",
        Duration::from_secs(1)
    )
    .expect("valid client");
}

#[derive(Debug, Serialize)]
struct Output {
    sdk_version: Vec<String>,
    rust_version: Vec<String>,
}

pub async fn generate_matrix(opt: GenerateMatrixOpt) -> Result<()> {
    let crate_response = CRATES_IO_CLIENT.get_crate("aws-config").await?;
    let output = Output {
        // The versions from the Crates IO client come back in descending order by version number
        sdk_version: crate_response
            .versions
            .into_iter()
            .filter(|v| !v.yanked)
            .map(|v| v.num)
            .take(opt.sdk_versions as usize)
            .collect(),
        rust_version: opt.rust_versions,
    };
    println!("{}", serde_json::to_string(&output)?);
    Ok(())
}
+37 −0
Original line number Diff line number Diff line
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0.
 */

use structopt::StructOpt;
use tracing_subscriber::{filter::EnvFilter, prelude::*};

mod generate_matrix;
mod run;

#[derive(StructOpt, Debug)]
#[structopt(name = "canary-runner")]
enum Opt {
    #[structopt(alias = "generate-matrix")]
    GenerateMatrix(generate_matrix::GenerateMatrixOpt),

    #[structopt(alias = "run")]
    Run(run::RunOpt),
}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let filter_layer = EnvFilter::try_from_default_env()
        .or_else(|_| EnvFilter::try_new("warn,canary_runner=info"))
        .unwrap();
    tracing_subscriber::registry()
        .with(filter_layer)
        .with(tracing_subscriber::fmt::layer().with_target(false))
        .init();

    let opt = Opt::from_args();
    match opt {
        Opt::GenerateMatrix(subopt) => generate_matrix::generate_matrix(subopt).await,
        Opt::Run(subopt) => run::run(subopt).await,
    }
}
Loading