Skip to content

Commit

Permalink
Aliases also need to be uploaded
Browse files Browse the repository at this point in the history
Signed-off-by: Aloys Baillet <aloys.baillet+github@gmail.com>
  • Loading branch information
aloysbaillet committed Nov 14, 2021
1 parent ee5da50 commit 409a03d
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 62 deletions.
24 changes: 18 additions & 6 deletions python/aswfdocker/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,20 @@ def _build_conan_package(
build_cmd,
dry_run,
)
alias_version = (
f"{image}/latest"
f"@{self.build_info.docker_org}/{version_info.conan_profile}"
)
self._run_in_docker(
base_cmd,
[
"conan",
"alias",
alias_version,
conan_version,
],
dry_run,
)
if self.push:
self._run_in_docker(
base_cmd,
Expand All @@ -262,17 +276,15 @@ def _build_conan_package(
],
dry_run,
)
alias_version = (
f"{image}/latest"
f"@{self.build_info.docker_org}/{version_info.conan_profile}"
)
self._run_in_docker(
base_cmd,
[
"conan",
"alias",
"upload",
"--all",
"-r",
self.build_info.docker_org,
alias_version,
conan_version,
],
dry_run,
)
Expand Down
96 changes: 40 additions & 56 deletions python/aswfdocker/tests/test_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ def setUp(self):
self.maxDiff = None
self._log_handlers = logging.getLogger("").handlers
logging.getLogger("").handlers = []
self._i = 0

def tearDown(self):
logging.getLogger("").handlers = self._log_handlers
Expand Down Expand Up @@ -383,7 +384,7 @@ def test_builder_cli_conan(self):
tempfile.gettempdir(), "docker-bake-PACKAGE-vfx1-2019.json"
)
cmds = result.output.strip().splitlines()
self.assertEqual(len(cmds), 3)
self.assertEqual(len(cmds), 4)
self.assertEqual(
cmds[0],
f"INFO:aswfdocker.builder:Would run: 'docker buildx bake -f {bake_path} --progress auto'",
Expand Down Expand Up @@ -452,6 +453,10 @@ def test_builderlist_cli(self):
)
self.assertEqual(result.exit_code, 0)

def _assertEndsWith(self, cmds, expected):
self.assertTrue(cmds[self._i].endswith(expected), "got: " + cmds[self._i])
self._i += 1

def test_builderlist_cli_conan(self):
runner = CliRunner()
result = runner.invoke(
Expand Down Expand Up @@ -481,68 +486,47 @@ def test_builderlist_cli_conan(self):
tempfile.gettempdir(), "docker-bake-PACKAGE-vfx1-2019-2020.json"
)
cmds = result.output.strip().splitlines()
self.assertEqual(len(cmds), 11)
i = 0
self.assertEqual(len(cmds), 13)
self.assertEqual(
cmds[i],
cmds[self._i],
f"INFO:aswfdocker.builder:Would run: 'docker buildx bake -f {bake_path} --progress auto'",
)
i += 1
self._i += 1
self.assertTrue(
cmds[i].startswith(
cmds[self._i].startswith(
"INFO:aswfdocker.builder:Would run: 'docker run -e CONAN_USER_HOME="
+ constants.CONAN_USER_HOME
),
msg=cmds[i],
)
self.assertTrue(
cmds[i].endswith("conan user -p -r aswftesting'"),
msg=cmds[i],
)
i += 1
self.assertTrue(
cmds[i].endswith("conan config set general.default_profile=vfx2019'"),
msg=cmds[i],
)
i += 1
self.assertTrue(
cmds[i].endswith(
f"conan create {constants.CONAN_USER_HOME}/recipes/openexr openexr/2.3.0@aswftesting/vfx2019"
" --keep-source --keep-build --build=missing'"
),
msg=cmds[i],
)
i += 1
self.assertTrue(
cmds[i].endswith(
"conan upload --all -r aswftesting openexr/2.3.0@aswftesting/vfx2019'"
),
msg=cmds[i],
)
i += 1
self.assertTrue(
cmds[i].endswith(
"conan alias openexr/latest@aswftesting/vfx2019 openexr/2.3.0@aswftesting/vfx2019'"
),
msg=cmds[i],
)
i += 1
self.assertTrue(
cmds[i].endswith("conan user -p -r aswftesting'"),
msg=cmds[i],
)
i += 1
self.assertTrue(
cmds[i].endswith("conan config set general.default_profile=vfx2020'"),
msg=cmds[i],
)
i += 1
self.assertTrue(
cmds[i].endswith(
f"conan create {constants.CONAN_USER_HOME}/recipes/openexr openexr/2.4.0@aswftesting/vfx2020"
" --keep-source --keep-build --build=missing'"
),
msg=cmds[i],
msg=cmds[self._i],
)
self._assertEndsWith(cmds, "conan user -p -r aswftesting'")
self._assertEndsWith(cmds, "conan config set general.default_profile=vfx2019'")
self._assertEndsWith(
cmds,
f"conan create {constants.CONAN_USER_HOME}/recipes/openexr"
" openexr/2.3.0@aswftesting/vfx2019"
" --keep-source --keep-build --build=missing'",
)
self._assertEndsWith(
cmds,
"conan alias openexr/latest@aswftesting/vfx2019"
" openexr/2.3.0@aswftesting/vfx2019'",
)
self._assertEndsWith(
cmds,
"conan upload --all -r aswftesting" " openexr/2.3.0@aswftesting/vfx2019'",
)
self._assertEndsWith(
cmds,
"conan upload --all -r aswftesting" " openexr/latest@aswftesting/vfx2019'",
)
self._assertEndsWith(cmds, "conan user -p -r aswftesting'")
self._assertEndsWith(cmds, "conan config set general.default_profile=vfx2020'")
self._assertEndsWith(
cmds,
f"conan create {constants.CONAN_USER_HOME}/recipes/openexr"
" openexr/2.4.0@aswftesting/vfx2020"
" --keep-source --keep-build --build=missing'",
)
self.assertEqual(result.exit_code, 0)

Expand Down

0 comments on commit 409a03d

Please sign in to comment.