Write correct manifests in forks

This commit is contained in:
Ayaz Salikhov
2025-02-21 20:33:00 +00:00
parent 73628de2cd
commit d9b6333f13
4 changed files with 29 additions and 6 deletions

View File

@@ -101,6 +101,7 @@ jobs:
--variant ${{ inputs.variant }} --variant ${{ inputs.variant }}
--hist-lines-dir /tmp/jupyter/hist_lines/ --hist-lines-dir /tmp/jupyter/hist_lines/
--manifests-dir /tmp/jupyter/manifests/ --manifests-dir /tmp/jupyter/manifests/
--repository ${{ github.repository }}
shell: bash shell: bash
- name: Upload manifest file 💾 - name: Upload manifest file 💾
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4

View File

@@ -77,6 +77,7 @@ linkcheck-docs: ## check broken links
hook/%: VARIANT?=default hook/%: VARIANT?=default
hook/%: REPOSITORY?=$(OWNER)/docker-stacks
hook/%: ## run post-build hooks for an image hook/%: ## run post-build hooks for an image
python3 -m tagging.apps.write_tags_file \ python3 -m tagging.apps.write_tags_file \
--registry "$(REGISTRY)" \ --registry "$(REGISTRY)" \
@@ -90,7 +91,8 @@ hook/%: ## run post-build hooks for an image
--short-image-name "$(notdir $@)" \ --short-image-name "$(notdir $@)" \
--variant "$(VARIANT)" \ --variant "$(VARIANT)" \
--hist-lines-dir /tmp/jupyter/hist_lines/ \ --hist-lines-dir /tmp/jupyter/hist_lines/ \
--manifests-dir /tmp/jupyter/manifests/ --manifests-dir /tmp/jupyter/manifests/ \
--repository "$(REPOSITORY)"
python3 -m tagging.apps.apply_tags \ python3 -m tagging.apps.apply_tags \
--registry "$(REGISTRY)" \ --registry "$(REGISTRY)" \
--owner "$(OWNER)" \ --owner "$(OWNER)" \

View File

@@ -32,6 +32,7 @@ def write_build_history_line(
hist_lines_dir: Path, hist_lines_dir: Path,
filename: str, filename: str,
all_tags: list[str], all_tags: list[str],
repository: str,
) -> None: ) -> None:
LOGGER.info("Appending build history line") LOGGER.info("Appending build history line")
@@ -42,8 +43,8 @@ def write_build_history_line(
commit_hash = GitHelper.commit_hash() commit_hash = GitHelper.commit_hash()
links_column = MARKDOWN_LINE_BREAK.join( links_column = MARKDOWN_LINE_BREAK.join(
[ [
f"[Git diff](https://github.com/jupyter/docker-stacks/commit/{commit_hash})", f"[Git diff](https://github.com/{repository}/commit/{commit_hash})",
f"[Dockerfile](https://github.com/jupyter/docker-stacks/blob/{commit_hash}/images/{short_image_name}/Dockerfile)", f"[Dockerfile](https://github.com/{repository}/blob/{commit_hash}/images/{short_image_name}/Dockerfile)",
f"[Build manifest](./{filename})", f"[Build manifest](./{filename})",
] ]
) )
@@ -61,12 +62,19 @@ def write_manifest_file(
filename: str, filename: str,
manifests: list[ManifestInterface], manifests: list[ManifestInterface],
container: Container, container: Container,
repository: str,
) -> None: ) -> None:
manifest_names = [manifest.__class__.__name__ for manifest in manifests] manifest_names = [manifest.__class__.__name__ for manifest in manifests]
LOGGER.info(f"Using manifests: {manifest_names}") LOGGER.info(f"Using manifests: {manifest_names}")
markdown_pieces = [ markdown_pieces = [
ManifestHeader.create_header(short_image_name, registry, owner, BUILD_TIMESTAMP) ManifestHeader.create_header(
registry=registry,
owner=owner,
short_image_name=short_image_name,
build_timestamp=BUILD_TIMESTAMP,
repository=repository,
)
] + [manifest.markdown_piece(container) for manifest in manifests] ] + [manifest.markdown_piece(container) for manifest in manifests]
markdown_content = "\n\n".join(markdown_pieces) + "\n" markdown_content = "\n\n".join(markdown_pieces) + "\n"
@@ -82,6 +90,7 @@ def write_manifest(
variant: str, variant: str,
hist_lines_dir: Path, hist_lines_dir: Path,
manifests_dir: Path, manifests_dir: Path,
repository: str,
) -> None: ) -> None:
LOGGER.info(f"Creating manifests for image: {short_image_name}") LOGGER.info(f"Creating manifests for image: {short_image_name}")
taggers, manifests = get_taggers_and_manifests(short_image_name) taggers, manifests = get_taggers_and_manifests(short_image_name)
@@ -104,6 +113,7 @@ def write_manifest(
hist_lines_dir=hist_lines_dir, hist_lines_dir=hist_lines_dir,
filename=filename, filename=filename,
all_tags=all_tags, all_tags=all_tags,
repository=repository,
) )
write_manifest_file( write_manifest_file(
registry=registry, registry=registry,
@@ -113,6 +123,7 @@ def write_manifest(
filename=filename, filename=filename,
manifests=manifests, manifests=manifests,
container=container, container=container,
repository=repository,
) )
@@ -127,6 +138,11 @@ if __name__ == "__main__":
hist_lines_dir=True, hist_lines_dir=True,
manifests_dir=True, manifests_dir=True,
) )
arg_parser.add_argument(
"--repository",
required=True,
help="Repository name on GitHub",
)
args = arg_parser.parse_args() args = arg_parser.parse_args()
LOGGER.info(f"Current build timestamp: {BUILD_TIMESTAMP}") LOGGER.info(f"Current build timestamp: {BUILD_TIMESTAMP}")

View File

@@ -12,7 +12,11 @@ class ManifestHeader:
@staticmethod @staticmethod
def create_header( def create_header(
short_image_name: str, registry: str, owner: str, build_timestamp: str registry: str,
owner: str,
short_image_name: str,
build_timestamp: str,
repository: str,
) -> str: ) -> str:
commit_hash = GitHelper.commit_hash() commit_hash = GitHelper.commit_hash()
commit_hash_tag = GitHelper.commit_hash_tag() commit_hash_tag = GitHelper.commit_hash_tag()
@@ -36,7 +40,7 @@ class ManifestHeader:
- Build timestamp: {build_timestamp} - Build timestamp: {build_timestamp}
- Docker image: `{registry}/{owner}/{short_image_name}:{commit_hash_tag}` - Docker image: `{registry}/{owner}/{short_image_name}:{commit_hash_tag}`
- Docker image size: {image_size} - Docker image size: {image_size}
- Git commit SHA: [{commit_hash}](https://github.com/jupyter/docker-stacks/commit/{commit_hash}) - Git commit SHA: [{commit_hash}](https://github.com/{repository}/commit/{commit_hash})
- Git commit message: - Git commit message:
```text ```text