diff --git a/Makefile b/Makefile index 82c0e3df..44ef8358 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ pre-commit-check: echo "Note: Install pre-commit hooks by 'pre-commit install' and you'll never have to run this check manually again." check-failures: check-test-lib - cd tests/failures/check && make tag && ! make check && make clean + cd tests/failures/check && make build && ! make check && make clean cd tests/failures/check && ./check_skip_squash.sh check-latest-imagestream: diff --git a/README.md b/README.md index e6c2a313..e34d9d9d 100644 --- a/README.md +++ b/README.md @@ -23,12 +23,8 @@ during the build. `make build` will also expect a `README.md` so that it can transform it into a man page that gets added to the image so make sure it is available and that you have the `go-md2man` tool installed on your host. - - -`make tag` -Use this rule if you want to tag an image after it is built. It will be tagged with +The image will be tagged after it is built. It will be tagged with two tags - name:latest and name:version. -Depends on `build` `make test` or `make check` This rule will run the testsuite scripts contained in the container source repositories. @@ -63,6 +59,21 @@ E.g. command for the source generation into Fedora dist-repo The sources are not generated directly into dist-git repository, but into created `results` directory. +`make version-table` +Generates a version table in the main `README.md` file that shows which versions of the software +are provided for each OS as images. In order to generate a table, install `python-natsort` +(or the `natsort` package from PyPI), then insert the following two +comments into the `README`: +```md + + +``` +in **this exact** format, and finally run `make version-table` to generate it. + `make clean` Runs scripts that clean-up the working dir. Depends on the `clean-images` rule by default and additional clean rules can be provided through the `clean-hook` variable. diff --git a/build.sh b/build.sh index d43e30ed..926a27c5 100755 --- a/build.sh +++ b/build.sh @@ -233,6 +233,26 @@ function docker_build_with_version { # IMAGE_ID # analyze_logs_by_logdetective "$?" "${tmp_file}" echo "$IMAGE_ID" > .image-id + tag_image +} + +function tag_image { + name=$(docker inspect -f "{{.Config.Labels.name}}" "$IMAGE_ID") || (echo "-> No image with this tag found, try re-building." && return) + # We need to check '.git' dir in root directory + if [ -d "../.git" ] ; then + commit_date=$(git show -s HEAD --format=%cd --date=short | sed 's/-//g') + date_and_hash="${commit_date}-$(git rev-parse --short HEAD)" + else + date_and_hash="$(date +%Y%m%d%H%M%S)" + fi + + full_reg_name="$REGISTRY$name" + echo "-> Tagging image '$IMAGE_ID' as '$full_reg_name:$dir' and '$full_reg_name:latest' and '$full_reg_name:$OS' and '$full_reg_name:$date_and_hash'" + + docker tag "$IMAGE_ID" "$full_reg_name:$OS" + docker tag "$IMAGE_ID" "$full_reg_name:$dir" + docker tag "$IMAGE_ID" "$full_reg_name:latest" + docker tag "$IMAGE_ID" "$full_reg_name:$date_and_hash" } # Versions are stored in subdirectories. You can specify VERSION variable diff --git a/common.mk b/common.mk index b4d7d632..fe7fe923 100644 --- a/common.mk +++ b/common.mk @@ -12,7 +12,6 @@ endif build = $(SHELL) $(common_dir)/build.sh test = $(SHELL) $(common_dir)/test.sh shellcheck = $(SHELL) $(common_dir)/run-shellcheck.sh -tag = $(SHELL) $(common_dir)/tag.sh clean = $(SHELL) $(common_dir)/clean.sh betka = $(SHELL) $(common_dir)/betka.sh @@ -92,28 +91,27 @@ check: test test: script_env += TEST_MODE=true # The tests should ideally depend on $IMAGE_ID only, but see PR#19 for more info -# while we need to depend on 'tag' instead of 'build'. -test: tag +test: build VERSIONS="$(VERSIONS)" $(script_env) $(test) .PHONY: test-openshift-4 test-openshift-4: script_env += TEST_OPENSHIFT_4=true -test-openshift-4: tag +test-openshift-4: build VERSIONS="$(VERSIONS)" BASE_IMAGE_NAME="$(BASE_IMAGE_NAME)" $(script_env) $(test) .PHONY: test-openshift test-openshift: script_env += TEST_OPENSHIFT_MODE=true -test-openshift: tag +test-openshift: build VERSIONS="$(VERSIONS)" BASE_IMAGE_NAME="$(BASE_IMAGE_NAME)" $(script_env) $(test) .PHONY: test-openshift-pytest test-openshift-pytest: script_env += TEST_OPENSHIFT_PYTEST=true -test-openshift-pytest: tag +test-openshift-pytest: build VERSIONS="$(VERSIONS)" BASE_IMAGE_NAME="$(BASE_IMAGE_NAME)" $(script_env) $(test) .PHONY: test-pytest test-pytest: script_env += TEST_PYTEST=true -test-pytest: tag +test-pytest: build VERSIONS="$(VERSIONS)" BASE_IMAGE_NAME="$(BASE_IMAGE_NAME)" $(script_env) $(test) @@ -121,10 +119,6 @@ test-pytest: tag shellcheck: $(shellcheck) $(SHELLCHECK_FILES) -.PHONY: tag -tag: build - VERSIONS="$(VERSIONS)" $(script_env) $(tag) - .PHOHY: betka betka: VERSIONS="$(VERSIONS)" \ diff --git a/tag.sh b/tag.sh deleted file mode 100755 index d92450a9..00000000 --- a/tag.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash - -# This script is used to tag the OpenShift Docker images. -# -# Resulting image will be tagged: 'name:version' and 'name:latest'. Name and version -# are values of labels from resulted image -# -# VERSIONS - Must be set to a list with possible versions (subdirectories) - -set -eE - -trap 'echo "errexit on line $LINENO, $0" >&2' ERR - -[ -n "${DEBUG:-}" ] && set -x -# This adds backwards compatibility if only single version needs to be tagged -# In CI we would like to test single version but VERSIONS= means, that nothing is tested -# make tag TARGET= VERSIONS= ... checks single version for CLI -# make tag TARGET= SINGLE_VERSION= ... checks single version from Testing Farm -VERSIONS=${SINGLE_VERSION:-$VERSIONS} -if [[ "${SINGLE_VERSION}" == *"minimal"* ]]; then - echo "Adding ${SINGLE_VERSION//-minimal/} because it might be needed for testing $SINGLE_VERSION." - VERSIONS="$VERSIONS ${SINGLE_VERSION//-minimal/}" -fi -if [[ "${SINGLE_VERSION}" == *"micro"* ]]; then - echo "Adding ${SINGLE_VERSION//-micro/} because it might be needed for testing $SINGLE_VERSION." - VERSIONS="$VERSIONS ${SINGLE_VERSION//-micro/}" -fi -echo "Tagged versions are: $VERSIONS" - -for dir in ${VERSIONS}; do - [ ! -e "${dir}/.image-id" ] && echo "-> Image for version $dir not built, skipping tag." && continue - pushd "${dir}" > /dev/null - IMAGE_ID=$(cat .image-id) - name=$(docker inspect -f "{{.Config.Labels.name}}" "$IMAGE_ID") - # We need to check '.git' dir in root directory - if [ -d "../.git" ] ; then - commit_date=$(git show -s HEAD --format=%cd --date=short | sed 's/-//g') - date_and_hash="${commit_date}-$(git rev-parse --short HEAD)" - else - date_and_hash="$(date +%Y%m%d%H%M%S)" - fi - - full_reg_name="$REGISTRY$name" - echo "-> Tagging image '$IMAGE_ID' as '$full_reg_name:$dir' and '$full_reg_name:latest' and '$full_reg_name:$OS' and '$full_reg_name:$date_and_hash'" - - docker tag "$IMAGE_ID" "$full_reg_name:$OS" - docker tag "$IMAGE_ID" "$full_reg_name:$dir" - docker tag "$IMAGE_ID" "$full_reg_name:latest" - docker tag "$IMAGE_ID" "$full_reg_name:$date_and_hash" - - popd > /dev/null -done diff --git a/tests/failures/check/check_skip_squash.sh b/tests/failures/check/check_skip_squash.sh index 3224a9c6..81e91439 100755 --- a/tests/failures/check/check_skip_squash.sh +++ b/tests/failures/check/check_skip_squash.sh @@ -1,3 +1,3 @@ #!/bin/bash -make tag SKIP_SQUASH=0 +make build SKIP_SQUASH=0 diff --git a/tests/failures/check/v0/Dockerfile.rhel10 b/tests/failures/check/v0/Dockerfile.rhel10 index d35734d9..ee0327c8 100644 --- a/tests/failures/check/v0/Dockerfile.rhel10 +++ b/tests/failures/check/v0/Dockerfile.rhel10 @@ -1,3 +1,2 @@ -FROM ubi9/s2i-core -## ubi10/s2i-core does not exist let's use ubi9/s2i-core +FROM ubi10/s2i-core LABEL name=test-image