Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade semver checks to 0.24.1 #3102

Merged
merged 6 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tools/ci-build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ RUN yum -y install --allowerasing \
automake \
binutils \
ca-certificates \
cmake \
curl \
gcc \
gcc-c++ \
Expand Down Expand Up @@ -132,9 +133,8 @@ ARG cargo_wasi_version=0.1.27
RUN cargo install cargo-wasi --locked --version ${cargo_wasi_version}

FROM install_rust AS cargo_semver_checks
ARG cargo_semver_checks_version=0.20.0
ARG rust_nightly_version
RUN cargo +${rust_nightly_version} -Z sparse-registry install cargo-semver-checks --locked --version ${cargo_semver_checks_version}
ARG cargo_semver_checks_version=0.24.1
RUN cargo install cargo-semver-checks --locked --version ${cargo_semver_checks_version}

FROM install_rust AS cargo_mdbook
ARG cargo_mdbook_version=0.4.30
Expand Down
42 changes: 35 additions & 7 deletions tools/ci-scripts/codegen-diff/semver-checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,63 @@ def main(skip_generation=False):
sdk_directory = os.path.join(OUTPUT_PATH, 'aws-sdk', 'sdk')
os.chdir(sdk_directory)

failed = False
failures = []
deny_list = [
# add crate names here to exclude them from the semver checks
]
for path in os.listdir():
for path in list(os.listdir())[:10]:
eprint(f'checking {path}...', end='')
if path not in deny_list and get_cmd_status(f'git cat-file -e base:{sdk_directory}/{path}/Cargo.toml') == 0:
get_cmd_output('cargo generate-lockfile', quiet=True)
(_, out, _) = get_cmd_output('cargo pkgid', cwd=path, quiet=True)
pkgid = parse_package_id(out)
(status, out, err) = get_cmd_output(f'cargo semver-checks check-release '
f'--baseline-rev {BASE_BRANCH} '
# in order to get semver-checks to work with publish-false crates, need to specify
# package and manifest path explicitly
f'--manifest-path {path}/Cargo.toml '
f'-p {path} '
'-v '
f'-p {pkgid} '
f'--release-type minor', check=False, quiet=True)
if status == 0:
eprint('ok!')
else:
failed = True
failures.append(f"{out}{err}")
eprint('failed!')
if out:
eprint(out)
eprint(err)
else:
eprint(f'skipping {path} because it does not exist in base')
if failed:
if failures:
eprint('One or more crates failed semver checks!')
eprint("\n".join(failures))
exit(1)


def parse_package_id(id):
if '#' in id and '@' in id:
return id.split('#')[1].split('@')[0]
elif '#' in id:
return id.split('/')[-1].split('#')[0]
else:
eprint(id)
raise Exception("unknown format")


import unittest


class SelfTest(unittest.TestCase):
def test_foo(self):
self.assertEqual(parse_package_id("file:///Users/rcoh/code/smithy-rs-ci/smithy-rs/tmp-codegen-diff/aws-sdk/sdk/aws-smithy-runtime-api#0.56.1"), "aws-smithy-runtime-api")
self.assertEqual(parse_package_id("file:///Users/rcoh/code/smithy-rs-ci/smithy-rs/tmp-codegen-diff/aws-sdk/sdk/s3#[email protected]"), "aws-sdk-s3")


if __name__ == "__main__":
skip_generation = bool(os.environ.get('SKIP_GENERATION') or False)
main(skip_generation=skip_generation)
if len(sys.argv) > 1 and sys.argv[1] == "--self-test":
sys.argv.pop()
unittest.main()
else:
skip_generation = bool(os.environ.get('SKIP_GENERATION') or False)
main(skip_generation=skip_generation)