← Back to team overview

launchpad-reviewers team mailing list archive

Re: [Merge] ~jugmac00/launchpad:create-lpcraft-jobs-on-push into launchpad:master

 

Ready for the next review!

Diff comments:

> diff --git a/lib/lp/code/model/tests/test_cibuild.py b/lib/lp/code/model/tests/test_cibuild.py
> index 133bed2..c8e9721 100644
> --- a/lib/lp/code/model/tests/test_cibuild.py
> +++ b/lib/lp/code/model/tests/test_cibuild.py
> @@ -350,3 +697,157 @@ class TestCIBuildSet(TestCaseWithFactory):
>              [], ci_build_set.findByGitRepository(repositories[0]))
>          self.assertContentEqual(
>              builds[2:], ci_build_set.findByGitRepository(repositories[1]))
> +
> +
> +class TestCIBuildHelpers(TestCaseWithFactory):
> +
> +    layer = LaunchpadZopelessLayer
> +
> +    def test_determine_DASes_to_build(self):
> +        ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
> +        distro_serieses = [
> +            self.factory.makeDistroSeries(ubuntu) for _ in range(2)]
> +        dases = []
> +        for distro_series in distro_serieses:
> +            for _ in range(2):
> +                dases.append(self.factory.makeBuildableDistroArchSeries(
> +                    distroseries=distro_series))
> +        configuration = load_configuration(dedent("""\
> +            pipeline:
> +                - [build]
> +                - [test]
> +            jobs:
> +                build:
> +                    series: {distro_serieses[1].name}
> +                    architectures:
> +                        - {dases[2].architecturetag}
> +                        - {dases[3].architecturetag}
> +                test:
> +                    series: {distro_serieses[1].name}
> +                    architectures:
> +                        - {dases[2].architecturetag}
> +            """.format(distro_serieses=distro_serieses, dases=dases)))
> +        logger = BufferLogger()
> +
> +        dases_to_build = list(
> +            determine_DASes_to_build(configuration, logger=logger))
> +
> +        self.assertContentEqual(dases[2:], dases_to_build)
> +        self.assertEqual("", logger.getLogBuffer())
> +
> +
> +    def test_determine_DASes_to_build_logs_missing_job_definition(self):
> +        ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
> +        distro_series = self.factory.makeDistroSeries(ubuntu)
> +        das = self.factory.makeBuildableDistroArchSeries(
> +            distroseries=distro_series)
> +        configuration = load_configuration(dedent("""\
> +            pipeline:
> +                - [test]
> +            jobs:
> +                build:
> +                    series: {distro_series.name}
> +                    architectures:
> +                        - {das.architecturetag}
> +            """.format(distro_series=distro_series, das=das)))
> +        logger = BufferLogger()
> +
> +        dases_to_build = list(
> +            determine_DASes_to_build(configuration, logger=logger))
> +
> +        self.assertEqual(0, len(dases_to_build))
> +        self.assertEqual(
> +            "ERROR No job definition for 'test'\n", logger.getLogBuffer()
> +        )
> +
> +
> +    def test_determine_DASes_to_build_logs_missing_series(self):
> +        ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
> +        distro_series = self.factory.makeDistroSeries(ubuntu)
> +        das = self.factory.makeBuildableDistroArchSeries(
> +            distroseries=distro_series)
> +        configuration = load_configuration(dedent("""\
> +            pipeline:
> +                - [build]
> +            jobs:
> +                build:
> +                    series: unknown-series
> +                    architectures:
> +                        - {das.architecturetag}
> +            """.format(das=das)))
> +        logger = BufferLogger()
> +
> +        dases_to_build = list(
> +            determine_DASes_to_build(configuration, logger=logger))
> +
> +        self.assertEqual(0, len(dases_to_build))
> +        self.assertEqual(
> +            "ERROR Unknown Ubuntu series name unknown-series\n",
> +            logger.getLogBuffer()
> +        )
> +
> +
> +    def test_determine_DASes_to_build_logs_non_buildable_architecture(self):
> +        ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
> +        distro_series = self.factory.makeDistroSeries(ubuntu)
> +        configuration = load_configuration(dedent("""\
> +            pipeline:
> +                - [build]
> +            jobs:
> +                build:
> +                    series: {distro_series.name}
> +                    architectures:
> +                        - non-buildable-architecture
> +            """.format(distro_series=distro_series)))
> +        logger = BufferLogger()
> +
> +        dases_to_build = list(
> +            determine_DASes_to_build(configuration, logger=logger))
> +
> +        self.assertEqual(0, len(dases_to_build))
> +        # XXX jugmac00 2022-03-08
> +        # for unknown reasons, the logger output starts with a backslash:
> +        # actual    = '''\
> +        # ERROR non-buildable-architecture is not a buildable architecture name in Ubuntu distroseries-100005  # noqa: E501
> +        # '''
> +        self.assertIn(
> +            "ERROR non-buildable-architecture is not a buildable architecture "
> +            "name in Ubuntu %s" % distro_series.name,
> +            logger.getLogBuffer()
> +        )
> +
> +
> +
> +class TestGetAllCommitsForPaths(TestCaseWithFactory):
> +
> +    layer = LaunchpadZopelessLayer
> +
> +    def test_no_refs(self):
> +        repository = self.factory.makeGitRepository()
> +        ref_paths = ['refs/heads/master']
> +
> +        rv = get_all_commits_for_paths(repository, ref_paths)
> +
> +        self.assertEqual([], rv)
> +
> +    def test_one_ref_one_path(self):
> +        repository = self.factory.makeGitRepository()
> +        ref_paths = ['refs/heads/master']
> +        [ref] = self.factory.makeGitRefs(repository, ref_paths)
> +
> +        rv = get_all_commits_for_paths(repository, ref_paths)
> +
> +        self.assertEqual(1, len(rv))
> +        self.assertEqual(ref.commit_sha1, rv[0])
> +
> +    def test_multiple_refs_and_paths(self):
> +        # XXX jugmac00 2022-03-04
> +        # this test possibly should have multiple commits per path

... but I did not know how to set this up, see https://chat.canonical.com/canonical/pl/3do5azn6wbfdfx7w1uj1ihn7cw

> +        repository = self.factory.makeGitRepository()
> +        ref_paths = ['refs/heads/master', "refs/heads/dev"]
> +        refs = self.factory.makeGitRefs(repository, ref_paths)
> +
> +        rv = get_all_commits_for_paths(repository, ref_paths)
> +
> +        self.assertEqual(2, len(rv))
> +        self.assertEqual({ref.commit_sha1 for ref in refs}, set(rv))
> diff --git a/lib/lp/code/model/tests/test_gitrepository.py b/lib/lp/code/model/tests/test_gitrepository.py
> index 3272b3b..bc17444 100644
> --- a/lib/lp/code/model/tests/test_gitrepository.py
> +++ b/lib/lp/code/model/tests/test_gitrepository.py
> @@ -1461,6 +1467,7 @@ class TestGitRepositoryModifications(TestCaseWithFactory):
>              repository, "date_last_modified", UTC_NOW)
>  
>      def test_create_ref_sets_date_last_modified(self):
> +        self.useFixture(GitHostingFixture())

Those old tests needed to be updated to work with the new event handler.

>          repository = self.factory.makeGitRepository(
>              date_created=datetime(2015, 6, 1, tzinfo=pytz.UTC))
>          [ref] = self.factory.makeGitRefs(repository=repository)


-- 
https://code.launchpad.net/~jugmac00/launchpad/+git/launchpad/+merge/416223
Your team Launchpad code reviewers is requested to review the proposed merge of ~jugmac00/launchpad:create-lpcraft-jobs-on-push into launchpad:master.



References