Skip to content

Commit

Permalink
Switch to new changelog format and teach sdk-lints
Browse files Browse the repository at this point in the history
  • Loading branch information
ysaito1001 committed Jul 23, 2024
1 parent 2645049 commit 01bd59d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 30 deletions.
14 changes: 14 additions & 0 deletions .changelog/5308844.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
applies_to:
- aws-sdk-rust
- client
authors:
- landonxjames
references:
- smithy-rs#3765
- smithy-rs#3757
breaking: false
new_feature: false
bug_fix: true
---
Fix incorrect redaction of `@sensitive` types in maps and lists.
24 changes: 0 additions & 24 deletions CHANGELOG.next.toml

This file was deleted.

3 changes: 2 additions & 1 deletion tools/ci-build/changelogger/src/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ fn new_entry(markdown: Markdown) -> anyhow::Result<String> {
// This doesn't present practical issues when rendering changelogs. See
// https://github.com/dtolnay/serde-yaml/issues/355
let front_matter = serde_yaml::to_string(&markdown.front_matter)?;
let changelog_entry = format!("---\n{}---\n{}", front_matter, markdown.message);
// the last `\n` is crucial, without it `fix end of files` in `sdk-lints` would complain
let changelog_entry = format!("---\n{}---\n{}\n", front_matter, markdown.message);
let changelog_entry = if any_required_field_needs_to_be_filled(&markdown) {
edit::edit(changelog_entry).context("failed while editing changelog entry)")?
} else {
Expand Down
31 changes: 26 additions & 5 deletions tools/ci-build/sdk-lints/src/changelog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,30 @@ impl Lint for ChangelogNext {
}

impl Check for ChangelogNext {
fn check(&self, path: impl AsRef<Path>) -> Result<Vec<LintError>> {
if path.as_ref().exists() {
Ok(vec![LintError::new(
"the legacy `CHANGELOG.next.toml` should no longer exist",
)])
} else {
Ok(vec![])
}
}
}

pub(crate) struct DotChangelog;

impl Lint for DotChangelog {
fn name(&self) -> &str {
".changelog"
}

fn files_to_check(&self) -> Result<Vec<PathBuf>> {
Ok(vec![repo_root().join(".changelog")])
}
}

impl Check for DotChangelog {
fn check(&self, path: impl AsRef<Path>) -> Result<Vec<LintError>> {
match check_changelog_next(path) {
Ok(_) => Ok(vec![]),
Expand All @@ -30,13 +54,10 @@ impl Check for ChangelogNext {
}
}

// TODO(file-per-change-changelog): Use `.load_from_dir` to read from the `.changelog` directory
// and run the validation only when the directory has at least one changelog entry file, otherwise
// a default constructed `ChangeLog` won't pass the validation.
/// Validate that `CHANGELOG.next.toml` follows best practices
/// Validate that changelog entries in the `.changelog` directory follows best practices
fn check_changelog_next(path: impl AsRef<Path>) -> std::result::Result<(), Vec<LintError>> {
let parsed = ChangelogLoader::default()
.load_from_file(path)
.load_from_dir(path)
.map_err(|e| vec![LintError::via_display(e)])?;
parsed
.validate(ValidationSet::Development)
Expand Down

0 comments on commit 01bd59d

Please sign in to comment.