Пример #1
0
    def update_starter_project(self) -> None:
        STARTER_PATH_OLD_SINGLE_HEADER = F"{release_constants.starter_project_dir}/lib/{self.details.old_single_header}"
        STARTER_PATH_NEW_SINGLE_HEADER = F"{release_constants.starter_project_dir}/lib/{self.details.new_single_header}"

        # Make sure starter project folder is clean
        project_dir = release_constants.starter_project_dir
        GitUtilities.reset_and_clean_working_directory(project_dir)

        shutil.copyfile(self.details.release_new_single_header,
                        STARTER_PATH_NEW_SINGLE_HEADER)

        # Delete the last release:
        if os.path.exists(STARTER_PATH_OLD_SINGLE_HEADER):
            os.remove(STARTER_PATH_OLD_SINGLE_HEADER)

        # Update the version in the "redirect" header:
        replace_text_in_file(
            F"{release_constants.starter_project_dir}/lib/ApprovalTests.hpp",
            self.details.old_version.get_version_text(),
            self.details.new_version.get_version_text())

        # Update the version number in the Visual Studio project:
        replace_text_in_file(
            F"{release_constants.starter_project_dir}/visual-studio-2017/StarterProject.vcxproj",
            self.details.old_single_header, self.details.new_single_header)
Пример #2
0
    def check_pre_conditions_for_publish(self) -> None:
        if self.details.push_to_production:
            repo = Repo(release_constants.main_project_dir)
            assert_step(not repo.bare)

            assert_step((repo.active_branch.name == 'master'))

            GitUtilities.check_no_uncommitted_changes(repo)

            # From https://stackoverflow.com/questions/15849640/how-to-get-count-of-unpublished-commit-with-gitpython
            assert_step(len(
                list(repo.iter_commits('master@{u}..master'))) == 0, "there are un-pushed changes in ApprovalTests.cpp")

            run(["open", "https://github.com/approvals/ApprovalTests.cpp/commits/master"])
            check_step("the builds are passing")

            run(["open", "https://github.com/approvals/ApprovalTests.cpp/blob/master/build/relnotes_x.y.z.md"])
            run(["open", F"https://github.com/approvals/ApprovalTests.cpp/compare/{self.details.old_version.get_version_text()}...master"])
            check_step("the release notes are ready")

            run(["open", "https://github.com/approvals/ApprovalTests.cpp/issues"])
            check_step("any issues resolved in this release are closed")

            run(["open", "https://github.com/approvals/ApprovalTests.cpp/milestones"])
            check_step("the milestone (if any) is up to date, including actual version number of release")
Пример #3
0
def check_repo() -> None:
    # check we are on a master branch that is in sync
    repo = Repo(".")
    assert_step((repo.active_branch.name == 'master'))
    GitUtilities.check_no_uncommitted_changes(repo)
    assert_step(len(
        list(repo.iter_commits('master@{u}..master'))) == 0,
                f"there are un-pushed changes in approvaltests")
    GitUtilities.pull_active_branch_origin(".")
Пример #4
0
 def update_vcpkg_version_files(details: ReleaseDetails,
                                commit_message: str) -> None:
     run(["brew", "install", "vcpkg"])
     run([
         "vcpkg", "x-add-version",
         f"--vcpkg-root={details.vcpkg_details.vcpkg_repo_dir}",
         details.project_details.vcpkg_directory_name
     ])
     GitUtilities.add_and_commit_everything(
         details.vcpkg_details.vcpkg_repo_dir, commit_message)
Пример #5
0
    def check_pre_conditions_for_main_repo(self) -> None:
        repo = Repo(self.details.locations.main_project_dir)
        assert_step(not repo.bare)
        GitUtilities.check_branch_name(repo, 'master')
        GitUtilities.check_no_uncommitted_changes(repo)

        # From https://stackoverflow.com/questions/15849640/how-to-get-count-of-unpublished-commit-with-gitpython
        assert_step(len(
            list(repo.iter_commits('master@{u}..master'))) == 0,
                    f"there are un-pushed changes in {self.details.project_details.github_project_name}")
Пример #6
0
    def test_vcpkg_and_create_pr(details: ReleaseDetails) -> None:
        if not details.project_details.update_vcpkg:
            return

        new_version_without_v = details.new_version.get_version_text_without_v(
        )
        commit_message = F'[{details.project_details.vcpkg_directory_name}] Update to {new_version_without_v}'
        GitUtilities.add_and_commit_everything(
            details.vcpkg_details.vcpkg_repo_dir, commit_message)
        DeployVcpkgRelease.update_vcpkg_version_files(details, commit_message)
        GitUtilities.push_active_branch_origin(
            details.vcpkg_details.vcpkg_repo_dir)
        DeployVcpkgRelease.create_pull_request(details)
Пример #7
0
    def prepare_release(details: ReleaseDetails) -> None:
        GitUtilities.reset_and_clean_working_directory(
            ConanReleaseDetails().conan_repo_dir)

        response = input(
            "  Conan: Has the previous pull request been accepted? [Y/y] ")
        if response in ['Y', 'y']:
            PrepareConanRelease.sync_conan_repo(details.new_version)
        else:
            # Do nothing - we are adding to our previous Pull Request
            # This does assume the same user is doing the previous and current release.
            print('Staying on current branch in conan repo')
        PrepareConanRelease.update_conan_recipe(details)
Пример #8
0
    def test_conan_and_create_pr(details: ReleaseDetails) -> None:
        if not details.project_details.update_conan:
            return

        new_version_without_v = details.new_version.get_version_text_without_v()
        # See test_conan_release.py's disabled_test_all_conan_versions_build() if you want to test
        # that conan builds against all supported library versions.
        DeployConanRelease.test_conan_build_passes(details.conan_details, new_version_without_v)

        GitUtilities.add_and_commit_everything(details.conan_details.conan_repo_dir,
                                               F'Add {details.project_details.conan_directory_name} {new_version_without_v}')
        GitUtilities.push_active_branch_origin(details.conan_details.conan_repo_dir)

        DeployConanRelease.create_pull_request(details)
Пример #9
0
    def prepare_release(details: ReleaseDetails) -> None:
        if not details.project_details.update_conan:
            return

        GitUtilities.reset_and_clean_working_directory(details.conan_details.conan_repo_dir)

        accepted = details.old_version.get_version_text_without_v() in PrepareConanRelease.get_accepted_approval_releases(
            details.project_details)
        if accepted:
            PrepareConanRelease.sync_conan_repo(details.conan_details, details.project_details, details.new_version)
        else:
            # Do nothing - we are adding to our previous Pull Request
            # This does assume the same user is doing the previous and current release.
            print('Staying on current branch in conan repo')
        PrepareConanRelease.update_conan_recipe(details)
Пример #10
0
def build(update_version: Callable[[Version], Version]) -> None:
    old_version = load_current_version()
    new_version = update_version(old_version)
    release_details = ReleaseDetails(old_version, new_version)

    check_repo()
    publish_to_maven(release_details)
    PrepareDocumentationRelease.prepare_documentation(release_details)
    new_version.write("./build")
    GitUtilities.add_and_commit_everything(".", new_version.get_version_text())
    set_snapshot(release_details)
    GitUtilities.add_and_commit_everything(".", "set Snapshot")
    # update command line git to authenticate github
    #GitUtilities.push_active_branch_origin(".")
    PrepareStarterProjectRelease.prepare_starter_project(release_details)

    print("Done")
    def update_starter_project(details: ReleaseDetails) -> None:
        STARTER_PATH_OLD_SINGLE_HEADER = F"{details.locations.starter_project_dir}/lib/{details.old_single_header}"
        STARTER_PATH_NEW_SINGLE_HEADER = F"{details.locations.starter_project_dir}/lib/{details.new_single_header}"

        # Make sure starter project folder is clean
        project_dir = details.locations.starter_project_dir
        GitUtilities.reset_and_clean_working_directory(project_dir)

        shutil.copyfile(details.release_new_single_header,
                        STARTER_PATH_NEW_SINGLE_HEADER)

        # Delete the last release:
        if os.path.exists(STARTER_PATH_OLD_SINGLE_HEADER):
            os.remove(STARTER_PATH_OLD_SINGLE_HEADER)
        else:
            raise RuntimeError(F"""
    ----------------------------------------------------------------
    ERROR: Old header file does not exist:
    {STARTER_PATH_OLD_SINGLE_HEADER}
    Starting state of Starter Project does not match '{details.old_version.get_version_text()}'
    Check whether:
    1. There were uncommitted changes to version.ini in main project,
       from a previous release preparation step.
    2. The Starter Project repo needs pulling.
    3. This is a CI build of a release tag - in which case the
       updated Starter Project has not yet been pushed, and this 
       failure can be ignored.
    ----------------------------------------------------------------
    
    """)

        # Update the version in the "redirect" header:
        replace_text_in_file(
            F"{details.locations.starter_project_dir}/lib/{details.project_details.simulated_single_header_file}",
            details.old_version.get_version_text(),
            details.new_version.get_version_text())

        # Update the version number in the Visual Studio projects:
        PrepareStarterProjectRelease.update_solution_file(
            details,
            F"{details.locations.starter_project_dir}/visual-studio-2017/StarterProject.vcxproj"
        )
        PrepareStarterProjectRelease.update_solution_file(
            details,
            F"{details.locations.starter_project_dir}/visual-studio-2019/StarterProject2019.vcxproj"
        )
Пример #12
0
    def update_starter_project(self) -> None:
        STARTER_PATH_OLD_SINGLE_HEADER = F"{self.details.locations.starter_project_dir}/lib/{self.details.old_single_header}"
        STARTER_PATH_NEW_SINGLE_HEADER = F"{self.details.locations.starter_project_dir}/lib/{self.details.new_single_header}"

        # Make sure starter project folder is clean
        project_dir = self.details.locations.starter_project_dir
        GitUtilities.reset_and_clean_working_directory(project_dir)

        shutil.copyfile(self.details.release_new_single_header, STARTER_PATH_NEW_SINGLE_HEADER)

        # Delete the last release:
        if os.path.exists(STARTER_PATH_OLD_SINGLE_HEADER):
            os.remove(STARTER_PATH_OLD_SINGLE_HEADER)
        else:
            raise RuntimeError(F"""
----------------------------------------------------------------
ERROR: Old header file does not exist:
{STARTER_PATH_OLD_SINGLE_HEADER}
Starting state of Starter Project does not match '{self.details.old_version.get_version_text()}'
Check whether:
1. There were uncommitted changes to version.ini in main project,
   from a previous release preparation step.
2. The Starter Project repo needs pulling.
----------------------------------------------------------------

""")

        # Update the version in the "redirect" header:
        replace_text_in_file(
            F"{self.details.locations.starter_project_dir}/lib/{self.details.project_details.simulated_single_header_file}",
            self.details.old_version.get_version_text(),
            self.details.new_version.get_version_text())

        # Update the version number in the Visual Studio project:
        visual_studio_2017_sln = F"{self.details.locations.starter_project_dir}/visual-studio-2017/StarterProject.vcxproj"
        if os.path.isfile(visual_studio_2017_sln):
            replace_text_in_file(visual_studio_2017_sln,
                                 self.details.old_single_header,
                                 self.details.new_single_header)
        else:
            print(f"Info: No Visual Studio solution file: {visual_studio_2017_sln}")
 def disabled_test_entry_point_for_uncommitted_changes(self) -> None:
     set_home_directory()
     repo = Repo(ConanReleaseDetails().conan_repo_dir)
     GitUtilities.check_no_uncommitted_changes(repo)
Пример #14
0
 def prepare_starter_project(details: ReleaseDetails) -> None:
     project_dir = release_constants.starter_project_dir
     GitUtilities.reset_and_clean_working_directory(project_dir)
     PrepareStarterProjectRelease.update_pom(details)
     GitUtilities.add_and_commit_everything(project_dir, details.new_version.get_version_text())
     GitUtilities.push_active_branch_origin(project_dir)
Пример #15
0
 def commit_main_project(self) -> None:
     message = F"{self.details.new_version_as_text()} release"
     GitUtilities.commit_everything(self.details.locations.main_project_dir,
                                    message)
Пример #16
0
 def check_pre_conditions_for_starter_project_repo(self) -> None:
     repo = Repo(self.details.locations.starter_project_dir)
     assert_step(not repo.bare)
     GitUtilities.check_branch_name(repo, 'master')
 def commit_starter_project(details: ReleaseDetails) -> None:
     message = F"Update to {details.project_details.github_project_name} {details.new_version_as_text()}"
     GitUtilities.commit_everything(details.locations.starter_project_dir, message)