Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions .github/workflows/docker-build-test-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,13 @@ jobs:
shell: bash

- name: Write tags file 🏷
run: |
python3 -m tagging.write_tags_file --short-image-name ${{ inputs.image }} --tags-dir /tmp/jupyter/tags/ --registry ${{ env.REGISTRY }} --owner ${{ env.OWNER }} --variant ${{ inputs.variant }}
run: >
python3 -m tagging.write_tags_file
--registry ${{ env.REGISTRY }}
--owner ${{ env.OWNER }}
--short-image-name ${{ inputs.image }}
--variant ${{ inputs.variant }}
--tags-dir /tmp/jupyter/tags/
shell: bash
- name: Upload tags file 💾
uses: actions/upload-artifact@v4
Expand All @@ -77,7 +82,14 @@ jobs:
retention-days: 3

- name: Write manifest and build history file 🏷
run: python3 -m tagging.write_manifest --short-image-name ${{ inputs.image }} --hist-lines-dir /tmp/jupyter/hist_lines/ --manifests-dir /tmp/jupyter/manifests/ --registry ${{ env.REGISTRY }} --owner ${{ env.OWNER }} --variant ${{ inputs.variant }}
run: >
python3 -m tagging.write_manifest
--registry ${{ env.REGISTRY }}
--owner ${{ env.OWNER }}
--short-image-name ${{ inputs.image }}
--variant ${{ inputs.variant }}
--hist-lines-dir /tmp/jupyter/hist_lines/
--manifests-dir /tmp/jupyter/manifests/
shell: bash
- name: Upload manifest file 💾
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -105,5 +117,9 @@ jobs:
retention-days: 3

- name: Run tests ✅
run: python3 -m tests.run_tests --short-image-name ${{ inputs.image }} --registry ${{ env.REGISTRY }} --owner ${{ env.OWNER }}
run: >
python3 -m tests.run_tests
--registry ${{ env.REGISTRY }}
--owner ${{ env.OWNER }}
--short-image-name ${{ inputs.image }}
shell: bash
6 changes: 5 additions & 1 deletion .github/workflows/docker-merge-tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,9 @@ jobs:

- name: Merge tags for the images 🔀
if: env.PUSH_TO_REGISTRY == 'true'
run: python3 -m tagging.merge_tags --short-image-name ${{ inputs.image }} --tags-dir /tmp/jupyter/tags/ --variant ${{ inputs.variant }}
run: >
python3 -m tagging.merge_tags
--short-image-name ${{ inputs.image }}
--variant ${{ inputs.variant }}
--tags-dir /tmp/jupyter/tags/
shell: bash
9 changes: 8 additions & 1 deletion .github/workflows/docker-tag-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,14 @@ jobs:
name: ${{ inputs.image }}-${{ inputs.platform }}-${{ inputs.variant }}-tags
path: /tmp/jupyter/tags/
- name: Apply tags to the loaded image 🏷
run: python3 -m tagging.apply_tags --short-image-name ${{ inputs.image }} --tags-dir /tmp/jupyter/tags/ --platform ${{ inputs.platform }} --registry ${{ env.REGISTRY }} --owner ${{ env.OWNER }} --variant ${{ inputs.variant }}
run: >
python3 -m tagging.apply_tags
--registry ${{ env.REGISTRY }}
--owner ${{ env.OWNER }}
--short-image-name ${{ inputs.image }}
--variant ${{ inputs.variant }}
--platform ${{ inputs.platform }}
--tags-dir /tmp/jupyter/tags/
# This step is needed to prevent pushing non-multi-arch "latest" tag
- name: Remove the "latest" tag from the image 🗑️
run: docker image rmi ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ inputs.image }}:latest
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/docker-wiki-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ jobs:
path: wiki/

- name: Update wiki 🏷
run: python3 -m tagging.update_wiki --wiki-dir wiki/ --hist-lines-dir /tmp/jupyter/hist_lines/ --manifests-dir /tmp/jupyter/manifests/
run: >
python3 -m tagging.update_wiki
--wiki-dir wiki/
--hist-lines-dir /tmp/jupyter/hist_lines/
--manifests-dir /tmp/jupyter/manifests/
shell: bash

- name: Push Wiki to GitHub 📤
Expand Down
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,25 @@ linkcheck-docs: ## check broken links
hook/%: VARIANT?=default
hook/%: ## run post-build hooks for an image
python3 -m tagging.write_tags_file \
--short-image-name "$(notdir $@)" \
--tags-dir /tmp/jupyter/tags/ \
--registry "$(REGISTRY)" \
--owner "$(OWNER)" \
--variant "$(VARIANT)"
--short-image-name "$(notdir $@)" \
--variant "$(VARIANT)" \
--tags-dir /tmp/jupyter/tags/
python3 -m tagging.write_manifest \
--registry "$(REGISTRY)" \
--owner "$(OWNER)" \
--short-image-name "$(notdir $@)" \
--variant "$(VARIANT)" \
--hist-lines-dir /tmp/jupyter/hist_lines/ \
--manifests-dir /tmp/jupyter/manifests/ \
--manifests-dir /tmp/jupyter/manifests/
python3 -m tagging.apply_tags \
--registry "$(REGISTRY)" \
--owner "$(OWNER)" \
--variant "$(VARIANT)"
python3 -m tagging.apply_tags \
--short-image-name "$(notdir $@)" \
--tags-dir /tmp/jupyter/tags/ \
--variant "$(VARIANT)" \
--platform "$(shell uname -m)" \
--registry "$(REGISTRY)" \
--owner "$(OWNER)" \
--variant "$(VARIANT)"
--tags-dir /tmp/jupyter/tags/
hook-all: $(foreach I, $(ALL_IMAGES), hook/$(I)) ## run post-build hooks for all images


Expand Down Expand Up @@ -135,7 +135,7 @@ run-sudo-shell/%: ## run bash in interactive mode as root in a stack

test/%: ## run tests against a stack
python3 -m tests.run_tests \
--short-image-name "$(notdir $@)" \
--registry "$(REGISTRY)" \
--owner "$(OWNER)"
--owner "$(OWNER)" \
--short-image-name "$(notdir $@)"
test-all: $(foreach I, $(ALL_IMAGES), test/$(I)) ## test all stacks
48 changes: 10 additions & 38 deletions tagging/apply_tags.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env python3
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import argparse
import logging
from pathlib import Path

import plumbum

from tagging.common_arguments import common_arguments_parser
from tagging.get_platform import unify_aarch64
from tagging.get_prefix import get_file_prefix_for_platform

Expand All @@ -16,12 +16,13 @@


def apply_tags(
short_image_name: str,
*,
registry: str,
owner: str,
tags_dir: Path,
platform: str,
short_image_name: str,
variant: str,
platform: str,
tags_dir: Path,
) -> None:
"""
Tags <registry>/<owner>/<short_image_name>:latest with the tags reported by all taggers for this image
Expand All @@ -41,18 +42,7 @@ def apply_tags(
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)

arg_parser = argparse.ArgumentParser()
arg_parser.add_argument(
"--short-image-name",
required=True,
help="Short image name",
)
arg_parser.add_argument(
"--tags-dir",
required=True,
type=Path,
help="Directory with saved tags file",
)
arg_parser = common_arguments_parser()
arg_parser.add_argument(
"--platform",
required=True,
Expand All @@ -61,30 +51,12 @@ def apply_tags(
help="Image platform",
)
arg_parser.add_argument(
"--registry",
required=True,
type=str,
choices=["docker.io", "quay.io"],
help="Image registry",
)
arg_parser.add_argument(
"--owner",
required=True,
help="Owner of the image",
)
arg_parser.add_argument(
"--variant",
"--tags-dir",
required=True,
help="Variant tag prefix",
type=Path,
help="Directory with saved tags file",
)
args = arg_parser.parse_args()
args.platform = unify_aarch64(args.platform)

apply_tags(
args.short_image_name,
args.registry,
args.owner,
args.tags_dir,
args.platform,
args.variant,
)
apply_tags(**vars(args))
39 changes: 39 additions & 0 deletions tagging/common_arguments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import argparse


def common_arguments_parser(
registry: bool = True,
owner: bool = True,
short_image_name: bool = True,
variant: bool = True,
) -> argparse.ArgumentParser:
"""Add common CLI arguments to parser"""

parser = argparse.ArgumentParser()
if registry:
parser.add_argument(
"--registry",
required=True,
choices=["docker.io", "quay.io"],
help="Image registry",
)
if owner:
parser.add_argument(
"--owner",
required=True,
help="Owner of the image",
)
if short_image_name:
parser.add_argument(
"--short-image-name",
required=True,
help="Short image name",
)
if variant:
parser.add_argument(
"--variant",
required=True,
help="Variant tag prefix",
)

return parser
17 changes: 4 additions & 13 deletions tagging/merge_tags.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env python3
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import argparse
import logging
from pathlib import Path

import plumbum

from tagging.common_arguments import common_arguments_parser
from tagging.get_platform import ALL_PLATFORMS
from tagging.get_prefix import get_file_prefix_for_platform

Expand All @@ -16,6 +16,7 @@


def merge_tags(
*,
short_image_name: str,
variant: str,
tags_dir: Path,
Expand Down Expand Up @@ -60,23 +61,13 @@ def merge_tags(
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)

arg_parser = argparse.ArgumentParser()
arg_parser.add_argument(
"--short-image-name",
required=True,
help="Short image name",
)
arg_parser = common_arguments_parser(registry=False, owner=False)
arg_parser.add_argument(
"--tags-dir",
required=True,
type=Path,
help="Directory with saved tags file",
)
arg_parser.add_argument(
"--variant",
required=True,
help="Variant tag prefix",
)
args = arg_parser.parse_args()

merge_tags(args.short_image_name, args.variant, args.tags_dir)
merge_tags(**vars(args))
10 changes: 6 additions & 4 deletions tagging/update_wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@ def remove_old_manifests(wiki_dir: Path) -> None:


def update_wiki(
wiki_dir: Path, hist_lines_dir: Path, manifests_dir: Path, allow_no_files: bool
*,
wiki_dir: Path,
hist_lines_dir: Path,
manifests_dir: Path,
allow_no_files: bool,
) -> None:
LOGGER.info("Updating wiki")

Expand Down Expand Up @@ -214,6 +218,4 @@ def update_wiki(
)
args = arg_parser.parse_args()

update_wiki(
args.wiki_dir, args.hist_lines_dir, args.manifests_dir, args.allow_no_files
)
update_wiki(**vars(args))
Loading