Unverified Commit 7768e03e authored by Russell Cohen's avatar Russell Cohen Committed by GitHub
Browse files

Upgrade semver checks to 0.24.1 (#3102)

## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here -->

## Description
<!--- Describe your changes in detail -->

## Testing
<!--- Please describe in detail how you tested your changes -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the AWS
SDK, generated SDK code, or SDK runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
parent a5f1653c
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ RUN yum -y install --allowerasing \
        automake \
        binutils \
        ca-certificates \
        cmake \
        curl \
        gcc \
        gcc-c++ \
@@ -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
+35 −7
Original line number Diff line number Diff line
@@ -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#aws-sdk-s3@0.0.0-local"), "aws-sdk-s3")


if __name__ == "__main__":
    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)