Skip to content

Commit

Permalink
Remove warning banner code (#3407)
Browse files Browse the repository at this point in the history
## Motivation and Context
Remove warning banner related code. The test is broken so this code is
just causing a hassle and will never be used again.

- [ ] A generated code diff should be audited prior to merging.
----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
  • Loading branch information
rcoh authored Feb 13, 2024
1 parent c43fc71 commit fa61448
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 273 deletions.
5 changes: 0 additions & 5 deletions aws/SDK_README.md.hb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ It gets instantiated and copied into the build artifacts by the `aws:sdk:assembl
Available template arguments:
- `{{sdk_version_<crate_name_in_snake_case>}}` (e.g., `{{sdk_version_aws_config}}` for the `aws-config` crate): the version number of the given crate (just the number, no `v` prefix)
- `{{msrv}}`: The MSRV Rust compiler version (just the number, no `v` prefix)
- `{{warning_banner}}`: Show the production warning banner
--}}
<!--
IMPORTANT:
Expand All @@ -17,10 +16,6 @@ To update it, edit the `aws/SDK_README.md.hb` Handlebars template in that reposi

This repo contains the AWS SDK for Rust and its [public roadmap](https://github.com/orgs/awslabs/projects/50/views/1).

{{#if warning_banner}}
**Please Note**: The SDK is currently released as a developer preview, without support or assistance for use on production workloads. Any use in production is at your own risk.
{{/if}}

The SDK is code generated from [Smithy models](https://smithy.io/2.0/index.html) that represent each AWS service.
The code used to generate the SDK can be found in [smithy-rs](https://github.com/smithy-lang/smithy-rs).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ internal class AwsCrateDocGenerator(private val codegenContext: ClientCodegenCon
check(moduleVersion.isNotEmpty() && moduleVersion[0].isDigit())

val moduleName = codegenContext.settings.moduleName
val stableVersion = !moduleVersion.startsWith("0.")
val description =
normalizeDescription(
codegenContext.moduleName,
Expand All @@ -139,18 +138,6 @@ internal class AwsCrateDocGenerator(private val codegenContext: ClientCodegenCon
template(asComments, escape("# $moduleName\n"))
}

// TODO(PostGA): Remove warning banner conditionals.
// NOTE: when you change this, you must also change SDK_README.md.hb
if (!stableVersion) {
template(
asComments,
"""
**Please Note: The SDK is currently released as a developer preview, without support or assistance for use
on production workloads. Any use in production is at your own risk.**${"\n"}
""".trimIndent(),
)
}

if (description.isNotBlank()) {
template(asComments, escape("$description\n"))
}
Expand Down
57 changes: 0 additions & 57 deletions aws/sdk-codegen/src/test/kotlin/AwsCrateDocsDecoratorTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,10 @@
*/

import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertFalse
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
import software.amazon.smithy.model.loader.ModelAssembler
import software.amazon.smithy.model.node.ObjectNode
import software.amazon.smithy.model.shapes.ShapeId
import software.amazon.smithy.rust.codegen.client.testutil.testClientCodegenContext
import software.amazon.smithy.rust.codegen.client.testutil.testClientRustSettings
import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter
import software.amazon.smithy.rust.codegen.core.testutil.asSmithyModel
import software.amazon.smithy.rustsdk.AwsCrateDocGenerator
import software.amazon.smithy.rustsdk.AwsTestRuntimeConfig

class AwsCrateDocsDecoratorTest {
private val codegenContext = testClientCodegenContext(ModelAssembler().assemble().unwrap())
Expand Down Expand Up @@ -114,53 +106,4 @@ class AwsCrateDocsDecoratorTest {
),
)
}

// TODO(PostGA): Remove warning banner conditionals.
@Test
fun warningBanner() {
val context = { version: String ->
testClientCodegenContext(
model =
"""
namespace test
service Foobaz {
}
""".asSmithyModel(),
settings =
testClientRustSettings(
moduleVersion = version,
service = ShapeId.from("test#Foobaz"),
runtimeConfig = AwsTestRuntimeConfig,
customizationConfig =
ObjectNode.parse(
"""
{ "awsSdk": {
"awsConfigVersion": "dontcare" } }
""",
) as ObjectNode,
),
)
}

// Test unstable versions first
var codegenContext = context("0.36.0")
var result =
AwsCrateDocGenerator(codegenContext).docText(includeHeader = false, includeLicense = false, asComments = true).let { writable ->
val writer = RustWriter.root()
writable(writer)
writer.toString()
}
assertTrue(result.contains("The SDK is currently released as a developer preview"))

// And now stable versions
codegenContext = context("1.0.0")
result =
AwsCrateDocGenerator(codegenContext).docText(includeHeader = false, includeLicense = false, asComments = true).let { writable ->
val writer = RustWriter.root()
writable(writer)
writer.toString()
}
assertFalse(result.contains("The SDK is currently released as a developer preview"))
}
}
53 changes: 0 additions & 53 deletions aws/sdk-codegen/src/test/kotlin/SdkCodegenIntegrationTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
*/

import org.junit.jupiter.api.Test
import software.amazon.smithy.rust.codegen.core.rustlang.rust
import software.amazon.smithy.rust.codegen.core.testutil.asSmithyModel
import software.amazon.smithy.rust.codegen.core.testutil.integrationTest
import software.amazon.smithy.rustsdk.awsIntegrationTestParams
import software.amazon.smithy.rustsdk.awsSdkIntegrationTest

class SdkCodegenIntegrationTest {
Expand Down Expand Up @@ -56,54 +53,4 @@ class SdkCodegenIntegrationTest {
// it should compile
}
}

// TODO(PostGA): Remove warning banner conditionals.
@Test
fun warningBanners() {
// Unstable version
awsSdkIntegrationTest(
model,
params = awsIntegrationTestParams().copy(moduleVersion = "0.36.0"),
) { _, rustCrate ->
rustCrate.integrationTest("banner") {
rust(
"""
##[test]
fn banner() {
use std::process::Command;
use std::path::Path;
// Verify we're in the right directory
assert!(Path::new("Cargo.toml").try_exists().unwrap());
let output = Command::new("grep").arg("developer preview").arg("-i").arg("-R").arg(".").output().unwrap();
assert_eq!(0, output.status.code().unwrap(), "it should output the banner");
}
""",
)
}
}

// Stable version
awsSdkIntegrationTest(
model,
params = awsIntegrationTestParams().copy(moduleVersion = "1.0.0"),
) { _, rustCrate ->
rustCrate.integrationTest("no_banner") {
rust(
"""
##[test]
fn banner() {
use std::process::Command;
use std::path::Path;
// Verify we're in the right directory
assert!(Path::new("Cargo.toml").try_exists().unwrap());
let output = Command::new("grep").arg("developer preview").arg("-i").arg("-R").arg(".").output().unwrap();
assert_eq!(1, output.status.code().unwrap(), "it should _not_ output the banner");
}
""",
)
}
}
}
}
145 changes: 0 additions & 145 deletions tools/ci-build/publisher/src/subcommand/hydrate_readme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use fs_err as fs;
use handlebars::Handlebars;
use serde::Serialize;
use serde_json::json;
use smithy_rs_tool_common::package::PackageCategory;
use smithy_rs_tool_common::versions_manifest::VersionsManifest;
use std::path::PathBuf;

Expand Down Expand Up @@ -58,12 +57,6 @@ fn hydrate_template<C: Serialize>(template_string: &str, template_context: &C) -
fn make_context(msrv: &str, versions_manifest: &VersionsManifest) -> serde_json::Value {
let mut context = json!({ "msrv": msrv });

// TODO(PostGA): Remove warning banner conditionals
context.as_object_mut().unwrap().insert(
"warning_banner".into(),
serde_json::Value::Bool(!stable_release(versions_manifest)),
);

for (crate_name, metadata) in &versions_manifest.crates {
let key = format!("sdk_version_{}", crate_name.replace('-', "_"));
context
Expand All @@ -74,23 +67,10 @@ fn make_context(msrv: &str, versions_manifest: &VersionsManifest) -> serde_json:
context
}

// TODO(PostGA): Remove warning banner conditionals
fn stable_release(manifest: &VersionsManifest) -> bool {
manifest.crates.iter().any(|(_name, version)| {
version.category == PackageCategory::AwsSdk && !version.version.starts_with("0.")
})
}

#[cfg(test)]
mod tests {
use super::hydrate_template;
use crate::subcommand::hydrate_readme::make_context;
use serde_json::json;
use smithy_rs_tool_common::package::PackageCategory;
use smithy_rs_tool_common::versions_manifest::{
CrateVersion, ManualInterventions, VersionsManifest,
};
use std::collections::BTreeMap;

#[test]
fn test_hydrate_template() {
Expand All @@ -115,129 +95,4 @@ mod tests {
hydrated,
)
}

fn version(category: PackageCategory, version: &str) -> CrateVersion {
CrateVersion {
category,
version: version.into(),
source_hash: "dontcare".into(),
model_hash: None,
}
}
fn make_manifest(crates: &BTreeMap<String, CrateVersion>) -> VersionsManifest {
VersionsManifest {
smithy_rs_revision: "dontcare".into(),
aws_doc_sdk_examples_revision: "dontcare".into(),
manual_interventions: ManualInterventions::default(),
crates: crates.clone(),
release: None,
}
}

// TODO(PostGA): Remove warning banner conditionals
#[test]
fn test_stable_release() {
// Validate assumptions about package categories with some precondition checks
assert_eq!(
PackageCategory::SmithyRuntime,
PackageCategory::from_package_name("aws-smithy-runtime"),
"precondition"
);
assert_eq!(
PackageCategory::AwsRuntime,
PackageCategory::from_package_name("aws-runtime"),
"precondition"
);
assert_eq!(
PackageCategory::AwsSdk,
PackageCategory::from_package_name("aws-sdk-s3"),
"precondition"
);

// With S3 at 0.36, it is not considered stable
let mut crates = BTreeMap::new();
crates.insert(
"aws-smithy-http".to_string(),
version(PackageCategory::SmithyRuntime, "0.36.0"),
);
crates.insert(
"aws-smithy-runtime".to_string(),
version(PackageCategory::SmithyRuntime, "1.0.0"),
);
crates.insert(
"aws-runtime".to_string(),
version(PackageCategory::AwsRuntime, "1.0.0"),
);
crates.insert(
"aws-sdk-s3".to_string(),
version(PackageCategory::AwsSdk, "0.36.0"),
);
let manifest = make_manifest(&crates);
assert!(
!super::stable_release(&manifest),
"it is not stable since S3 is 0.36"
);

// Now with S3 at 1.0, it is considered stable
crates.insert(
"aws-sdk-s3".to_string(),
version(PackageCategory::AwsSdk, "1.0.0"),
);
let manifest = make_manifest(&crates);
assert!(
super::stable_release(&manifest),
"it is stable since S3 is 1.0"
);
}

// TODO(PostGA): Remove warning banner conditionals
#[test]
fn test_warning_banner() {
// First, test with unstable versions
let mut crates = BTreeMap::new();
crates.insert(
"aws-smithy-runtime".to_string(),
version(PackageCategory::SmithyRuntime, "1.0.0"),
);
crates.insert(
"aws-runtime".to_string(),
version(PackageCategory::AwsRuntime, "1.0.0"),
);
crates.insert(
"aws-sdk-s3".to_string(),
version(PackageCategory::AwsSdk, "0.36.0"),
);
let manifest = make_manifest(&crates);

let context = make_context("dontcare-msrv", &manifest);
assert!(
context
.as_object()
.unwrap()
.get("warning_banner")
.unwrap()
.as_bool()
.unwrap(),
"it should have the warning banner because it's unstable"
);

// Next, test with stable versions
crates.insert(
"aws-sdk-s3".to_string(),
version(PackageCategory::AwsSdk, "1.0.0"),
);
let manifest = make_manifest(&crates);

let context = make_context("dontcare-msrv", &manifest);
assert!(
!context
.as_object()
.unwrap()
.get("warning_banner")
.unwrap()
.as_bool()
.unwrap(),
"it should _not_ have the warning banner because it's unstable"
);
}
}

0 comments on commit fa61448

Please sign in to comment.