diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 27333a5a..fca49ee6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,16 +1,16 @@ --- -name: release-tag +name: test-build-release on: pull_request: push: - tags: - - 'v*.*.*' + branches: [main] + tags: ['v*.*.*'] jobs: linters: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Shellcheck - hack uses: azohra/shell-linter@latest @@ -27,30 +27,177 @@ jobs: with: path: './openshift-tests-provider-cert/hack/*.sh' + + build-container-amd64: + runs-on: ubuntu-latest + needs: [linters] + env: + VERSION: "v0.0.0-devel-pr.${{ github.event.pull_request.number }}" + PLATFORMS: linux/amd64 + EXPIRATION: 1d + PUSH: false + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: quay.io + username: ${{ secrets.QUAY_USER }} + password: ${{ secrets.QUAY_PASS }} + + - name: Build and push - plugin + uses: docker/build-push-action@v6 + with: + platforms: ${{ env.PLATFORMS }} + push: ${{ env.PUSH }} + labels: | + quay.expires-after=${{ env.EXPIRATION }} + build-args: | + QUAY_EXPIRATION=${{ env.EXPIRATION }} + tags: quay.io/opct/plugin-openshift-tests:${{ env.VERSION }} + context: ./openshift-tests-provider-cert + file: ./openshift-tests-provider-cert/Containerfile + + - name: Build and push - must-gather-monitoring + uses: docker/build-push-action@v6 + with: + platforms: ${{ env.PLATFORMS }} + push: ${{ env.PUSH }} + labels: | + quay.expires-after=${{ env.EXPIRATION }} + build-args: | + QUAY_EXPIRATION=${{ env.EXPIRATION }} + tags: quay.io/opct/must-gather-monitoring:${{ env.VERSION }} + context: ./must-gather-monitoring + file: ./must-gather-monitoring/Containerfile + +# +# Releasing: triggered when push to main +# + release-latest: + if: github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + needs: [build-container-amd64] + env: + VERSION: "latest" + PLATFORMS: linux/amd64,linux/arm64 + EXPIRATION: never + PUSH: true + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: quay.io + username: ${{ secrets.QUAY_USER }} + password: ${{ secrets.QUAY_PASS }} + + - name: Build and push - plugin + uses: docker/build-push-action@v6 + with: + platforms: ${{ env.PLATFORMS }} + push: ${{ env.PUSH }} + labels: | + quay.expires-after=${{ env.EXPIRATION }} + build-args: | + QUAY_EXPIRATION=${{ env.EXPIRATION }} + tags: quay.io/opct/plugin-openshift-tests:${{ env.VERSION }} + context: ./openshift-tests-provider-cert + file: ./openshift-tests-provider-cert/Containerfile + + - name: Build and push - must-gather-monitoring + uses: docker/build-push-action@v6 + with: + platforms: ${{ env.PLATFORMS }} + push: ${{ env.PUSH }} + labels: | + quay.expires-after=${{ env.EXPIRATION }} + build-args: | + QUAY_EXPIRATION=${{ env.EXPIRATION }} + tags: quay.io/opct/must-gather-monitoring:${{ env.VERSION }} + context: ./must-gather-monitoring + file: ./must-gather-monitoring/Containerfile + + # # Releasing: triggered when a tag is created # - release: + release-tag: if: startsWith(github.ref, 'refs/tags/') runs-on: ubuntu-latest - needs: [linters] + needs: [build-container-amd64] + env: + PLATFORMS: linux/amd64,linux/arm64 + EXPIRATION: 1d + PUSH: false steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 + with: + submodules: recursive - name: Set vars id: vars run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} - - name: Push Container image + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: quay.io + username: ${{ secrets.QUAY_USER }} + password: ${{ secrets.QUAY_PASS }} + + - name: Build and push - plugin + uses: docker/build-push-action@v6 env: - RELEASE_VERSION: ${{ steps.vars.outputs.tag }} - QUAY_USER: ${{ secrets.QUAY_USER }} - QUAY_PASS: ${{ secrets.QUAY_PASS }} - run: | - podman login -u="${QUAY_USER}" -p="${QUAY_PASS}" quay.io - cd openshift-tests-provider-cert/; - make release VERSION=$RELEASE_VERSION + VERSION: ${{ steps.vars.outputs.tag }} + with: + platforms: ${{ env.PLATFORMS }} + push: ${{ env.PUSH }} + labels: | + quay.expires-after=${{ env.EXPIRATION }} + build-args: | + QUAY_EXPIRATION=${{ env.EXPIRATION }} + tags: quay.io/opct/plugin-openshift-tests:${{ env.VERSION }} + context: ./openshift-tests-provider-cert + file: ./openshift-tests-provider-cert/Containerfile + + - name: Build and push - must-gather-monitoring + uses: docker/build-push-action@v6 + env: + VERSION: ${{ steps.vars.outputs.tag }} + with: + platforms: ${{ env.PLATFORMS }} + push: ${{ env.PUSH }} + labels: | + quay.expires-after=${{ env.EXPIRATION }} + build-args: | + QUAY_EXPIRATION=${{ env.EXPIRATION }} + tags: quay.io/opct/must-gather-monitoring:${{ env.VERSION }} + context: ./must-gather-monitoring + file: ./must-gather-monitoring/Containerfile # https://github.com/mikepenz/release-changelog-builder-action#configuration - name: Build Changelog diff --git a/.github/workflows/release-devel.yaml b/.github/workflows/release-devel.yaml deleted file mode 100644 index 330620ef..00000000 --- a/.github/workflows/release-devel.yaml +++ /dev/null @@ -1,132 +0,0 @@ ---- -name: release-devel -on: - pull_request: - push: - branches: [main] - -jobs: - linters: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Shellcheck - hack - uses: azohra/shell-linter@latest - with: - path: "hack/*.sh" - - - name: Shellcheck - Plugin - openshift-tests - uses: azohra/shell-linter@latest - with: - path: './openshift-tests-provider-cert/plugin/*.sh' - - - name: Shellcheck - Plugin - openshift-tests - hack - uses: azohra/shell-linter@latest - with: - path: './openshift-tests-provider-cert/hack/*.sh' - -# -# Build container image -# - build-container: - name: release container(devel) - runs-on: ubuntu-22.04 - needs: [linters] - env: - VERSION: "v0.0.0-devel-pr.${{ github.event.pull_request.number }}" - TOOLS_REPO: localhost/tools - PLUGIN_TESTS_REPO: localhost/plugin-openshift-tests - MGM_REPO: localhost/must-gather-monitoring - - environment: production - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - submodules: recursive - - - name: Build images x86_64 - shell: bash - run: | - echo "> Build and publish container image:" - make build-arch-amd64 VERSION=${VERSION} - - # # TODO1: arm64 environment on Github Actions is not working. - # # manual steps is required: - # # $ make build-arch-arm64 VERSION=${VERSION} - # # $ make push-manifests VERSION=${VERSION} - # - # # TODO2: Quay login is not working for newer steps. Secrets are returning empty values. - # - # image is not working with podman - # - uses: uraimo/run-on-arch-action@v2 - # name: Build images arm64 - # id: build - # with: - # arch: aarch64 - # distro: ubuntu20.04 - # shell: /bin/bash - # env: | - # VERSION: "v0.0.0-devel-pr.${{ github.event.pull_request.number }}" - # TOOLS_REPO: localhost/tools - # PLUGIN_TESTS_REPO: localhost/plugin-openshift-tests - # MGM_REPO: localhost/must-gather-monitoring - # run: | - # apt-get update \ - # && apt -y install build-essential lsb-release curl gpg - # # https://podman.io/docs/installation - # mkdir -p /etc/apt/keyrings - # curl -fsSL "https://download.opensuse.org/repositories/devel:kubic:libcontainers:unstable/xUbuntu_$(lsb_release -rs)/Release.key" \ - # | gpg --dearmor \ - # | tee /etc/apt/keyrings/devel_kubic_libcontainers_unstable.gpg > /dev/null - # echo \ - # "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/devel_kubic_libcontainers_unstable.gpg]\ - # https://download.opensuse.org/repositories/devel:kubic:libcontainers:unstable/xUbuntu_$(lsb_release -rs)/ /" \ - # | tee /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list > /dev/null - # #apt-get update -qq - # apt-get -qq -y install podman - - # echo "> Build and publish container image:" - # make build-arch-arm64 VERSION=${VERSION} - - # - name: Build manifests - # shell: bash - # run: | - # echo "> Build and publish container image:" - # make build-manifests VERSION=${VERSION} - - # # https://github.com/marketplace/actions/podman-login - # - name: Log in to Quay.io - # uses: redhat-actions/podman-login@v1 - # with: - # username: ${{ env.PROD_QUAY_USER }} - # password: ${{ env.PROD_QUAY_PASS }} - # registry: quay.io - - # - name: Push images - # shell: bash - # run: | - # echo "> PuBuild and publish manifests" - # make push-manifests VERSION=${VERSION} - - # # Commenting in PR - # - name: Find comment - # uses: peter-evans/find-comment@v2 - # id: fbc - # with: - # issue-number: ${{ github.event.pull_request.number }} - # comment-author: 'github-actions[bot]' - # body-includes: '' - # - name: Create comment - # # if: steps.fbc.outputs.comment-id == '' - # uses: peter-evans/create-or-update-comment@v3 - # with: - # issue-number: ${{ github.event.pull_request.number }} - # body: | - # - # Images built: - # - Tools: [quay.io/opct/tools:${{ env.VERSION }}](https://quay.io/repository/opct/tools?tab=tags) - # - Plugin openshift-tests: [quay.io/opct/plugin-openshift-tests:${{ env.VERSION }}](https://quay.io/repository/opct/plugin-openshift-tests?tab=tags) - # - Must-Gather Monitoring: [quay.io/opct/must-gather-monitoring:${{ env.VERSION }}](https://quay.io/repository/opct/must-gather-monitoring?tab=tags) - # reactions: rocket diff --git a/.gitignore b/.gitignore index 0fa2f643..2704a4d3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ # Result files *.tar.gz -tools/VERSION openshift-tests-provider-cert/VERSION -must-gather-monitoring/VERSION \ No newline at end of file +must-gather-monitoring/VERSION diff --git a/Makefile b/Makefile index a7539a1c..ea67abd5 100644 --- a/Makefile +++ b/Makefile @@ -6,9 +6,10 @@ PREFIX ?= v0.0.0-devel VERSION ?= $(PREFIX)-$(shell git rev-parse --short HEAD) -ARCH ?= linux-amd64 -EXPIRE ?= 1w +PLATFORMS ?= linux/amd64,linux/arm64 +EXPIRE ?= 12h COMMAND ?= build +WHAT ?= tools # To create production images: make target VERSION_PREFIX='' EXPIRE=never .PHONY: format @@ -18,27 +19,24 @@ format: shellcheck shellcheck: hack/shellcheck.sh - #> Build app .PHONY: build build: EXPIRE=$(EXPIRE) VERSION=$(VERSION) \ - ./build.sh $(COMMAND) "$(WHAT)" $(ARCH) + ./build.sh "$(COMMAND)" "$(WHAT)" "$(PLATFORMS)" #>> tools - +# tools release is build manually. .PHONY: build-tools build-tools: WHAT = tools build-tools: build -.PHONY: build-tools-linux-amd64 -build-tools-linux-amd64: ARCH = linux-amd64 -build-tools-linux-amd64: build-tools - -.PHONY: build-tools-linux-arm64 -build-tools-linux-arm64: ARCH = linux-arm64 -build-tools-linux-arm64: build-tools +.PHONY: build-tools-release +build-tools-release: WHAT = tools +build-tools-release: EXPIRES = never +build-tools-release: VERSION = $(shell cat tools/VERSION) +build-tools-release: build #>> plugin-tests @@ -46,93 +44,14 @@ build-tools-linux-arm64: build-tools build-plugin-tests: WHAT = plugin-openshift-tests build-plugin-tests: build -.PHONY: build-plugin-tests-linux-amd64 -build-plugin-tests-linux-amd64: ARCH = linux-amd64 -build-plugin-tests-linux-amd64: build-plugin-tests - -.PHONY: build-plugin-tests-linux-arm64 -build-plugin-tests-linux-arm64: ARCH = linux-arm64 -build-plugin-tests-linux-arm64: build-plugin-tests - #>> must-gather-montioring .PHONY: build-must-gather-monitoring build-must-gather-monitoring: WHAT = must-gather-monitoring build-must-gather-monitoring: build -.PHONY: build-must-gather-monitoring-linux-amd64 -build-must-gather-monitoring-linux-amd64: ARCH = linux-amd64 -build-must-gather-monitoring-linux-amd64: build-must-gather-monitoring - -.PHONY: build-must-gather-monitoring-linux-arm64 -build-must-gather-monitoring-linux-arm64: ARCH = linux-arm64 -build-must-gather-monitoring-linux-arm64: build-must-gather-monitoring - -#> Build all by arch - -.PHONY: build-arch-amd64 -build-arch-amd64: ARCH = linux-amd64 -build-arch-amd64: - $(MAKE) build EXPIRE=$(EXPIRE) ARCH=$(ARCH) COMMAND=$(COMMAND) WHAT=tools - $(MAKE) build EXPIRE=$(EXPIRE) ARCH=$(ARCH) COMMAND=$(COMMAND) WHAT=plugin-openshift-tests - $(MAKE) build EXPIRE=$(EXPIRE) ARCH=$(ARCH) COMMAND=$(COMMAND) WHAT=must-gather-monitoring - -.PHONY: build-push-arch-amd64 -build-push-arch-amd64: COMMAND = push -build-push-arch-amd64: build-arch-amd64 - -.PHONY: build-arch-arm64 -build-arch-arm64: ARCH = linux-arm64 -build-arch-arm64: - $(MAKE) build EXPIRE=$(EXPIRE) ARCH=$(ARCH) COMMAND=$(COMMAND) WHAT=tools - $(MAKE) build EXPIRE=$(EXPIRE) ARCH=$(ARCH) COMMAND=$(COMMAND) WHAT=plugin-openshift-tests - $(MAKE) build EXPIRE=$(EXPIRE) ARCH=$(ARCH) COMMAND=$(COMMAND) WHAT=must-gather-monitoring - -.PHONY: build-push-arch-arm64 -build-push-arch-arm64: COMMAND = push -build-push-arch-arm64: build-arch-arm64 - -##> Production release only - -.PHONY: prod-build-push-arch-amd64 -prod-build-push-arch-amd64: COMMAND = push -prod-build-push-arch-amd64: EXPIRE = never -prod-build-push-arch-amd64: build-arch-amd64 - -.PHONY: prod-build-push-arch-arm64 -prod-build-push-arch-arm64: COMMAND = push -prod-build-push-arch-arm64: EXPIRE = never -prod-build-push-arch-arm64: build-arch-arm64 - -## Manifests - -.PHONY: build-manifest -build-manifest: - EXPIRE=$(EXPIRE) VERSION=$(VERSION) \ - hack/build-manifest.sh $(COMMAND) $(WHAT) - -.PHONY: build-manifests -build-manifests: - $(MAKE) build-manifest EXPIRE=$(EXPIRE) ARCH=$(ARCH) COMMAND=$(COMMAND) WHAT=tools - $(MAKE) build-manifest EXPIRE=$(EXPIRE) ARCH=$(ARCH) COMMAND=$(COMMAND) WHAT=plugin-openshift-tests - $(MAKE) build-manifest EXPIRE=$(EXPIRE) ARCH=$(ARCH) COMMAND=$(COMMAND) WHAT=must-gather-monitoring - -.PHONY: push-manifests -push-manifests: COMMAND = push -push-manifests: - $(MAKE) build-manifest EXPIRE=$(EXPIRE) ARCH=$(ARCH) COMMAND=$(COMMAND) WHAT=tools - $(MAKE) build-manifest EXPIRE=$(EXPIRE) ARCH=$(ARCH) COMMAND=$(COMMAND) WHAT=plugin-openshift-tests - $(MAKE) build-manifest EXPIRE=$(EXPIRE) ARCH=$(ARCH) COMMAND=$(COMMAND) WHAT=must-gather-monitoring - -##> Production release only - -.PHONY: prod-build-push-manifests -prod-build-push-manifests: EXPIRE = never -prod-build-push-manifests: push-manifests - -.PHONY: remove-manifests -remove-manifests: - podman manifest rm quay.io/opct/tools:$(TOOLS_VERSION) || true - podman manifest rm quay.io/opct/plugin-openshift-tests:$(PLUGIN_TESTS_VERSION) || true - podman manifest rm quay.io/opct/must-gather-monitoring:$(MGM_VERSION) || true - +.PHONY: images +images: + $(MAKE) build-tools + $(MAKE) build-plugin-tests + $(MAKE) build-must-gather-monitoring diff --git a/build.env b/build.env index 79052fd7..1cef4110 100755 --- a/build.env +++ b/build.env @@ -6,16 +6,11 @@ export CURRENT_VERSION_PLUGIN_TESTS="${VERSION}" export CURRENT_VERSION_MGM="${VERSION}" export JQ_VERSION=1.7 +export YQ_VERSION=4.2.0 export SONOBUOY_VERSION=v0.56.12 export IMAGE_EXPIRE_TIME="${EXPIRE:-1w}" -declare -A BUILD_PLATFORMS=() -BUILD_PLATFORMS+=( ["linux-amd64"]="linux/amd64" ) -BUILD_PLATFORMS+=( ["linux-arm64"]="linux/arm64" ) -#BUILD_PLATFORMS+=( ["linux-ppc64le"]="linux/ppc64le" ) -#BUILD_PLATFORMS+=( ["linux-s390x"]="linux/s390x" ) - export TOOLS_VERSION=${TOOLS_VERSION:-$CURRENT_VERSION_TOOLS} export TOOLS_REPO=${TOOLS_REPO:-quay.io/opct/tools} export TOOLS_IMG=${TOOLS_REPO}:${TOOLS_VERSION} @@ -26,4 +21,4 @@ export PLUGIN_TESTS_IMG=${PLUGIN_TESTS_REPO}:${PLUGIN_TESTS_VERSION} export MGM_VERSION=${MGM_VERSION:-$CURRENT_VERSION_MGM} export MGM_REPO=${MGM_REPO:-quay.io/opct/must-gather-monitoring} -export MGM_IMG=${MGM_REPO}:${MGM_VERSION} \ No newline at end of file +export MGM_IMG=${MGM_REPO}:${MGM_VERSION} diff --git a/build.sh b/build.sh index 8e518b9b..cf046331 100755 --- a/build.sh +++ b/build.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Mirror jq image to OPCT repo. +# Build OPCT plugin images. set -o pipefail set -o nounset @@ -8,33 +8,11 @@ set -o errexit COMMAND=${1}; shift BUILD_IMG=${1}; shift -BUILD_ARCH=${1}; +PLATFORMS=${1:-linux/amd64,linux/arm64}; # shellcheck disable=SC1091 source "$(dirname "$0")/build.env" -declare -g TARGET_OS -declare -g TARGET_ARCH -case $BUILD_ARCH in - "linux-amd64") - TARGET_OS=linux; - TARGET_ARCH=amd64; - ;; - "linux-arm64") - TARGET_OS=linux; - TARGET_ARCH=arm64; - ;; - "linux-ppc64le") - TARGET_OS=linux; - TARGET_ARCH=ppc64le; - ;; - "linux-s390x") - TARGET_OS=linux; - TARGET_ARCH=s390x; - ;; - *) echo "ERROR: invalid architecture [${BUILD_ARCH}]"; exit 1;; -esac - function push_image() { img_name=$1 if [[ $COMMAND == "push" ]]; then @@ -43,76 +21,111 @@ function push_image() { } function build_tools() { - + local build_root build_root=$(dirname "$0")/tools - - jq_bin="jq-${BUILD_ARCH}" - jq_url="https://github.com/jqlang/jq/releases/download/jq-${JQ_VERSION}/${jq_bin}" - - # TODO: build CAMGI in other supported arches. - # https://issues.redhat.com/browse/OPCT-275 - camgi_archive="camgi-0.9.0-linux-x86_64.tar" - camgi_url="https://github.com/elmiko/camgi.rs/releases/download/v0.9.0/${camgi_archive}" - - ocp_version=4.13.3 - oc_archive="openshift-client-linux.tar.gz" - oc_url="https://mirror.openshift.com/pub/openshift-v4/${TARGET_ARCH}/clients/ocp/${ocp_version}/${oc_archive}" - - img_name="${TOOLS_IMG}-${BUILD_ARCH}" echo "${TOOLS_VERSION}" > "${build_root}"/VERSION - podman build --platform "${BUILD_PLATFORMS[$BUILD_ARCH]}" \ - -f "${build_root}"/Containerfile \ - --build-arg=JQ_URL="${jq_url}" \ - --build-arg=JQ_BIN="${jq_bin}" \ - --build-arg=CAMGI_URL="${camgi_url}" \ - --build-arg=CAMGI_TAR="${camgi_archive}" \ - --build-arg=OC_TAR="${oc_archive}" \ - --build-arg=OC_URL="${oc_url}" \ - --build-arg=SONOBUOY_VERSION="${SONOBUOY_VERSION}" \ - --build-arg=QUAY_EXPIRATION="${IMAGE_EXPIRE_TIME}" \ - --build-arg=TARGETPLATFORM="${BUILD_PLATFORMS[$BUILD_ARCH]}" \ - --build-arg=TARGETARCH="${TARGET_ARCH}" \ - --build-arg=TARGETOS="${TARGET_OS}" \ - -t "${img_name}" "${build_root}" - - push_image "${img_name}" + img_name="${TOOLS_IMG}" + manifest="quay.io/opct/tools:${MGM_VERSION}" + + echo "Removing manifest ${manifest} if exists..." + podman manifest rm "${manifest}" || true + + echo "Creating manifests..." + podman manifest create "${manifest}" + + echo -e "\n\n\t>> Building ${manifest}\n" + for platform in $(echo "${PLATFORMS}" | tr ',' ' '); do + echo -e "\n\n\t>> Building ${manifest} for ${platform}\n" + TARGET_OS=$(echo "${platform}" | cut -d'/' -f1) + TARGET_ARCH=$(echo "${platform}" | cut -d'/' -f2) + BUILD_ARCH="$TARGET_OS-$TARGET_ARCH" + + jq_bin="jq-${BUILD_ARCH}" + jq_url="https://github.com/jqlang/jq/releases/download/jq-${JQ_VERSION}/${jq_bin}" + + # yq_bin="yq_${TARGET_OS}_${TARGET_ARCH}" + # yq_url="https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/${yq_bin}" + + # TODO: build CAMGI in other supported arches. + # https://issues.redhat.com/browse/OPCT-275 + camgi_archive="camgi-0.9.0-linux-x86_64.tar" + camgi_url="https://github.com/elmiko/camgi.rs/releases/download/v0.9.0/${camgi_archive}" + + ocp_version="stable-4.16" + oc_archive="openshift-client-linux.tar.gz" + oc_url="https://mirror.openshift.com/pub/openshift-v4/${TARGET_ARCH}/clients/ocp/${ocp_version}/${oc_archive}" + + podman build --platform "${platform}" \ + --manifest "${manifest}" \ + -f "${build_root}"/Containerfile \ + --build-arg=JQ_URL="${jq_url}" \ + --build-arg=JQ_BIN="${jq_bin}" \ + --build-arg=CAMGI_URL="${camgi_url}" \ + --build-arg=CAMGI_TAR="${camgi_archive}" \ + --build-arg=OC_TAR="${oc_archive}" \ + --build-arg=OC_URL="${oc_url}" \ + --build-arg=SONOBUOY_VERSION="${SONOBUOY_VERSION}" \ + --build-arg=QUAY_EXPIRATION="${IMAGE_EXPIRE_TIME}" \ + --build-arg=TARGETPLATFORM="${platform}" \ + --build-arg=TARGETARCH="${TARGET_ARCH}" \ + --build-arg=TARGETOS="${TARGET_OS}" \ + -t "${img_name}-${TARGET_OS}-${TARGET_ARCH}" "${build_root}" + done + + if [[ "$COMMAND" == "push" ]]; then + echo -e "\n\tPushing manifest ${manifest}...\n\n" + podman manifest push "${manifest}" "docker://${manifest}" + fi } function build_plugin_tests() { - build_root=$(dirname "$0")/openshift-tests-provider-cert - echo "${PLUGIN_TESTS_VERSION}" > "${build_root}"/VERSION - img_name="${PLUGIN_TESTS_IMG}-${BUILD_ARCH}" - podman build --platform "${BUILD_PLATFORMS[$BUILD_ARCH]}" \ - -f "${build_root}"/Containerfile \ - --build-arg=TOOLS_IMG="${TOOLS_IMG}-${BUILD_ARCH}" \ + img_name="${PLUGIN_TESTS_IMG}" + manifest="quay.io/opct/plugin-openshift-tests:${MGM_VERSION}" + + echo "Removing manifest ${manifest} if exists..." + podman manifest rm "${manifest}" || true + + echo "Creating manifests..." + podman manifest create "${manifest}" + + echo -e "\n\n\t>> Building ${manifest}\n" + podman build -f "${build_root}"/Containerfile \ + --platform "${PLATFORMS}" \ + --manifest "${manifest}" \ --build-arg=QUAY_EXPIRATION="${IMAGE_EXPIRE_TIME}" \ - --build-arg=TARGETPLATFORM="${BUILD_PLATFORMS[$BUILD_ARCH]}" \ - --build-arg=TARGETARCH="${TARGET_ARCH}" \ - --build-arg=TARGETOS="${TARGET_OS}" \ - -t "${img_name}" "${build_root}" + -t "${img_name}-buildx" "${build_root}" - push_image "${img_name}" + if [[ "$COMMAND" == "push" ]]; then + echo -e "\n\tPushing manifest ${manifest}...\n\n" + podman manifest push "${manifest}" "docker://${manifest}" + fi } function build_mgm() { - build_root=$(dirname "$0")/must-gather-monitoring echo "${MGM_VERSION}" > "${build_root}"/VERSION - img_name="${MGM_IMG}-${BUILD_ARCH}" - podman build --platform "${BUILD_PLATFORMS[$BUILD_ARCH]}" \ - -f "${build_root}"/Containerfile \ - --build-arg=TOOLS_IMG="${TOOLS_IMG}-${BUILD_ARCH}" \ + img_name="${MGM_IMG}" + manifest="quay.io/opct/must-gather-monitoring:${MGM_VERSION}" + + echo "Removing manifest ${manifest} if exists..." + podman manifest rm "${manifest}" || true + + echo "Creating manifests..." + podman manifest create "${manifest}" + + echo -e "\n\n\t>> Building ${manifest}\n" + podman build -f "${build_root}"/Containerfile \ + --platform "${PLATFORMS}" \ + --manifest "${manifest}" \ --build-arg=QUAY_EXPIRATION="${IMAGE_EXPIRE_TIME}" \ - --build-arg=TARGETPLATFORM="${BUILD_PLATFORMS[$BUILD_ARCH]}" \ - --build-arg=TARGETARCH="${TARGET_ARCH}" \ - --build-arg=TARGETOS="${TARGET_OS}" \ - -t "${img_name}" "${build_root}" + -t "${img_name}-buildx" "${build_root}" - if [[ $COMMAND == "push" ]]; then - podman push "${img_name}"; + if [[ "$COMMAND" == "push" ]]; then + echo -e "\n\tPushing manifest ${manifest}...\n\n" + podman manifest push "${manifest}" "docker://${manifest}" fi } @@ -130,4 +143,4 @@ case $BUILD_IMG in "plugin-openshift-tests") build_plugin_tests;; "must-gather-monitoring") build_mgm;; *) help;; -esac \ No newline at end of file +esac diff --git a/hack/build-manifest.sh b/hack/build-manifest.sh deleted file mode 100755 index bfa0fbcb..00000000 --- a/hack/build-manifest.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env bash - -# Create multi-arch manifests for a given image - -set -o pipefail -set -o nounset -set -o errexit - -# shellcheck disable=SC1091 -source "$(dirname "$0")"/../build.env - -COMMAND=$1; shift -APP=$1; - -case $APP in - "tools") base_image=${TOOLS_IMG};; - "plugin-openshift-tests") base_image=${PLUGIN_TESTS_IMG};; - "must-gather-monitoring") base_image=${MGM_IMG};; - *) echo "App not found: ${APP:-}"; exit 1;; -esac - -export PLATFORM_IMAGES="" - -# ensure image exists and is pulled to create manifests -for arch in ${!BUILD_PLATFORMS[*]} -do - img=${base_image}-${arch} - echo "Appending image to the list: ${img}" - if ! podman image exists "${img}" ; then - echo "Pulling image: ${img}" - podman pull "${img}"; - fi - PLATFORM_IMAGES+=" ${img}" -done - -set -x -if podman manifest exists "${base_image}" ; then - echo "Manifest already exists: ${base_image}" -else - echo "Creating manifest for [${base_image}] with iamges [${PLATFORM_IMAGES}]" - # shellcheck disable=SC2086 - podman manifest create "${base_image}" ${PLATFORM_IMAGES} -fi - -if [[ "${COMMAND}" == "push" ]] ; then - echo "Pushing manifest: ${base_image}" - podman manifest push "${base_image}" docker://"${base_image}" -fi \ No newline at end of file diff --git a/must-gather-monitoring/Containerfile b/must-gather-monitoring/Containerfile index f5db8969..586b37d0 100644 --- a/must-gather-monitoring/Containerfile +++ b/must-gather-monitoring/Containerfile @@ -1,6 +1,4 @@ - -ARG TOOLS_IMG=quay.io/opct/tools:v0.2.0 -FROM --platform=$TARGETPLATFORM ${TOOLS_IMG} AS build +FROM quay.io/opct/tools:v0.4.0 ARG QUAY_EXPIRATION=never ARG TARGETARCH @@ -15,12 +13,9 @@ LABEL io.k8s.display-name="OPCT Must-Gather Monitoring" \ os=$TARGETOS # For gathering data from nodes -RUN microdnf update -y && \ - microdnf install util-linux rsync -y && \ +RUN microdnf install util-linux rsync -y && \ microdnf clean all -COPY ./VERSION . - # Copy all collection scripts to /usr/bin COPY collection-scripts/* /usr/bin/ @@ -29,4 +24,4 @@ COPY runner_plugin /usr/bin/ RUN chmod u+x /usr/bin/gather* /usr/bin/runner_plugin -ENTRYPOINT /usr/bin/gather \ No newline at end of file +ENTRYPOINT /usr/bin/gather diff --git a/openshift-tests-provider-cert/Containerfile b/openshift-tests-provider-cert/Containerfile index e67f8b9b..47af47c1 100644 --- a/openshift-tests-provider-cert/Containerfile +++ b/openshift-tests-provider-cert/Containerfile @@ -1,12 +1,4 @@ -# Code generated for package assets by build-image.sh. DO NOT EDIT. -# sources: -# hack/Containerfile.alp -# hack/Containerfile.tools-alp - -# Plugin container image -ARG TOOLS_IMG=quay.io/opct/tools:v0.2.0 - -FROM ${TOOLS_IMG} +FROM quay.io/opct/tools:v0.4.0 ARG QUAY_EXPIRATION=never ARG TARGETARCH @@ -16,15 +8,12 @@ ARG TARGETOS LABEL io.k8s.display-name="OPCT Plugin openshift-tests" \ io.k8s.description="OPCT Plugin openshift-tests runs conformance tests using OpenShift e2e suites." \ io.openshift.tags="opct,plugin,openshift,okd,tests,e2e" \ - io.openshift.opct.versions="base=${TOOLS_IMG}" \ quay.expires-after=${QUAY_EXPIRATION} \ architecture=$TARGETARCH \ platform=$TARGETPLATFORM \ os=$TARGETOS WORKDIR /plugin - -COPY ./VERSION . COPY ./plugin/*.sh ./ CMD ["./runner.sh"] diff --git a/openshift-tests-provider-cert/Makefile b/openshift-tests-provider-cert/Makefile index 5e2692fd..1c8cbdeb 100644 --- a/openshift-tests-provider-cert/Makefile +++ b/openshift-tests-provider-cert/Makefile @@ -13,14 +13,16 @@ build-dev: VERSION_DEVEL=devel REGISTRY_PLUGIN=$(DEV_REGISTRY) hack/build-image.sh build-dev .PHONY: build-dev +.PHONY: release release: VERSION_PLUGIN=$(VERSION) hack/build-image.sh release -.PHONY: release + +.PHONY: test test: hack/test_runner.sh -.PHONY: test +.PHONY: test-shellcheck test-shellcheck: shellcheck plugin/*.sh hack/*.sh -.PHONY: test-shellcheck + diff --git a/tools/Containerfile b/tools/Containerfile index 221abd68..c0dcfc48 100644 --- a/tools/Containerfile +++ b/tools/Containerfile @@ -6,11 +6,12 @@ # ## Base image # -FROM quay.io/fedora/fedora-minimal:38 as base +FROM quay.io/fedora/fedora-minimal:40 as base # gcompat: allow to run glibc programs (oc and jq) # sononbuoy is already built with musl -RUN microdnf install -y bash curl grep tar xz gzip && \ +RUN echo "fastestmirror=true" >> /etc/dnf/dnf.conf && \ + microdnf install -y bash curl grep tar xz gzip && \ microdnf clean all FROM base as clients @@ -52,8 +53,8 @@ LABEL io.k8s.display-name="OPCT Tools" \ WORKDIR /tools ARG SONOBUOY_VERSION=TBD -COPY --from=quay.io/opct/sonobuoy:${SONOBUOY_VERSION} /sonobuoy /usr/bin/ -COPY --from=clients /clients/oc /usr/bin/ +COPY --from=quay.io/opct/sonobuoy:${SONOBUOY_VERSION} /sonobuoy /usr/bin/sonobuoy +COPY --from=clients /clients/oc /usr/bin/oc COPY --from=clients /clients/jq /usr/bin/jq COPY --from=clients /clients/camgi /usr/bin/camgi diff --git a/tools/VERSION b/tools/VERSION new file mode 100644 index 00000000..fb7a04cf --- /dev/null +++ b/tools/VERSION @@ -0,0 +1 @@ +v0.4.0