From b2dc7f02ef8e7547b995de8a49135310d548f07d Mon Sep 17 00:00:00 2001 From: Ondrej Nosek Date: Nov 11 2020 16:00:47 +0000 Subject: Allow skipping nvr checking for chain-build Add '--skip-nvr-check' parameter to 'chain-build command'. In fact, nvr checking is performed just for the last package in the chain. This is the package from an active repository. JIRA: RHELCMP-3013 Resolves: rhbz#1890701 Signed-off-by: Ondrej Nosek --- diff --git a/pyrpkg/cli.py b/pyrpkg/cli.py index ae44349..161b351 100644 --- a/pyrpkg/cli.py +++ b/pyrpkg/cli.py @@ -588,6 +588,12 @@ class cliClient(object): defined, packages will be built sequentially. """ % {'name': self.name})) chainbuild_parser.add_argument( + '--skip-nvr-check', action='store_false', default=True, + dest='nvr_check', + help='Submit build to buildsystem without check if NVR was ' + 'already built. NVR is constructed locally and may be ' + 'different from NVR constructed during build on builder.') + chainbuild_parser.add_argument( 'package', nargs='+', help='List the packages and order you want to build in') chainbuild_parser.set_defaults(command=self.chainbuild) diff --git a/tests/test_cli.py b/tests/test_cli.py index 5ad8665..cdbc241 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -3542,6 +3542,31 @@ class TestBuildPackage(FakeKojiCreds, CliTestCase): @patch('pyrpkg.Commands.nvr', new_callable=PropertyMock) @patch('pyrpkg.Commands.commithash', new_callable=PropertyMock) @patch('subprocess.Popen') + def test_chainbuild_do_not_check_nvr_existence(self, Popen, commithash, nvr): + """checks whether '--skip-nvr-check' parameter is allowed for + 'chain-build'""" + commithash.return_value = '45678' + nvr.return_value = 'docpkg-0.1-1.fc28' + + Popen.return_value.communicate.side_effect = [ + ('12345', ''), + ] + + self.assert_build( + 'chain-build', + cli_opts=['--skip-nvr-check', 'firstpkg'], + expected_chain_urls=[ + ['git://localhost/firstpkg#12345'], + ['git://localhost/docpkg#45678'], + ]) + + session = self.mock_ClientSession.return_value + # check if nvr check was inactive + session.getBuild.assert_not_called() + + @patch('pyrpkg.Commands.nvr', new_callable=PropertyMock) + @patch('pyrpkg.Commands.commithash', new_callable=PropertyMock) + @patch('subprocess.Popen') def test_chain_build_without_build_set(self, Popen, commithash, nvr): commithash.return_value = '45678' nvr.return_value = 'docpkg-0.1-1.fc28'