Skip to content

Commit

Permalink
Merge pull request #80 from sclorg/do_not_update_dockerfile
Browse files Browse the repository at this point in the history
Do not update Dockerfile in case of dist-git
  • Loading branch information
phracek committed Sep 16, 2024
2 parents 42f7e4b + 87439af commit 2cb33ab
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
with:
dockerfiles: ./Dockerfile.generator
image: cwt-generator
tags: latest 1 ${{ github.sha }}
tags: latest 1 ${{ github.sha }} 1.5.7

- name: Push cwt-generator image to Quay.io
id: push-to-quay
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.generator
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM quay.io/fedora/fedora:36
FROM quay.io/fedora/fedora:39
ENV CWT_DIR=/tmp/container-workflow-tool
RUN dnf install -y go-md2man \
make git python3-PyYAML \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.tests
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM quay.io/fedora/fedora:36
FROM quay.io/fedora/fedora:39

RUN dnf install -y ansible

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ TEST_IMAGE=cwt-tests
GENERATOR_IMAGE=quay.io/rhscl/cwt-generator
UNAME=$(shell uname)
ifeq ($(UNAME),Darwin)
PODMAN := /usr/local/bin/docker
PODMAN := /opt/podman/bin/podman
else
PODMAN := /usr/bin/podman
endif
Expand Down
9 changes: 0 additions & 9 deletions container_workflow_tool/distgit.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,7 @@ def dist_git_merge_changes(self, images, rebase=False):
pull_upstr = image.get("pull_upstream", True)
repo = self._clone_downstream(component, branch)
df_path = os.path.join(component, "Dockerfile")
downstream_from = self.df_handler.get_from_df(df_path)
self.logger.debug(f"Downstream_from: {downstream_from}\n")
from_tag = self.conf.get("from_tag", "latest")
if rebase or not pull_upstr:
self.df_handler.update_dockerfile(
df_path, from_tag, downstream_from=downstream_from
)
# It is possible for the git repository to have no changes
if repo.is_dirty():
commit = self.get_commit_msg(rebase, image)
Expand All @@ -97,9 +91,6 @@ def dist_git_merge_changes(self, images, rebase=False):
# Save the upstream commit hash
ups_hash = Repo(ups_path).commit().hexsha
self.pull_upstream(component, path, url, repo, ups_name, commands)
self.df_handler.update_dockerfile(
df_path, from_tag, downstream_from=downstream_from
)
repo.git.add("Dockerfile")
# It is possible for the git repository to have no changes
if repo.is_dirty():
Expand Down
3 changes: 2 additions & 1 deletion container_workflow_tool/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,8 @@ def clear_cache(self):
self.logger.info("Removing cached data and git storage.")
# Clear ondisk storage for git and the brew cache
tmp = self._get_tmp_workdir(setup_dir=False)
shutil.rmtree(tmp, ignore_errors=True)
if tmp is not None and os.path.isdir(tmp):
shutil.rmtree(tmp, ignore_errors=True)
# If the working directory has been set by the user, recreate it
if self.tmp_workdir:
os.makedirs(tmp)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def get_dir(system_path=None, virtual_path=None):

setup(
name='container-workflow-tool',
version="1.5.6",
version="1.5.7",
description='A python3 tool to make rebuilding images easier by automating several steps of the process.',
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down
28 changes: 0 additions & 28 deletions tests/test_distgit.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,7 @@ def test_distgit_merge_changes(self):
self.ir.conf["from_tag"] = "test"
tmp = Path(self.ir._get_tmp_workdir())
self.ir.dist_git_merge_changes()
dpath = tmp / self.component / 'Dockerfile'
assert os.path.isfile(dpath)
assert not (tmp / self.component / "test" / "test-openshift.yaml").exists()
tag_found = False
with open(dpath) as f:
if ":test" in f.read():
tag_found = True
assert tag_found
shutil.rmtree(tmp / self.component)

@pytest.mark.distgit
Expand All @@ -86,25 +79,4 @@ def test_distgit_merge_changes_openshift_yaml(self):
tmp = Path(self.ir._get_tmp_workdir())
self.ir.distgit._clone_downstream(self.component, "main")
self.ir.dist_git_merge_changes()
dpath = tmp / self.component / 'Dockerfile'
assert os.path.isfile(dpath)
tag_found = False
with open(dpath) as f:
if ":test" in f.read():
tag_found = True
assert tag_found
shutil.rmtree(tmp / self.component)

@pytest.mark.distgit
def test_tag_dockerfile(self):
tmp = Path(self.ir._get_tmp_workdir())
self.ir.conf["from_tag"] = "test"
self.ir.dist_git_merge_changes()
cpath = tmp / self.component
dpath = cpath / 'Dockerfile'
found_tag = False
with open(dpath) as f:
if ":test" in f.read():
found_tag = True
assert found_tag
shutil.rmtree(tmp / self.component)

0 comments on commit 2cb33ab

Please sign in to comment.