diff --git a/.github/workflows/greenboot-ci.yaml b/.github/workflows/greenboot-ci.yaml index bfd2a4b..226ac6e 100644 --- a/.github/workflows/greenboot-ci.yaml +++ b/.github/workflows/greenboot-ci.yaml @@ -181,6 +181,29 @@ jobs: timeout: 90 secrets: "QUAY_USERNAME=${{ secrets.QUAY_USERNAME }};QUAY_PASSWORD=${{ secrets.QUAY_PASSWORD }};STAGE_REDHAT_IO_USERNAME=${{ secrets.STAGE_REDHAT_IO_USERNAME }};STAGE_REDHAT_IO_TOKEN=${{ secrets.STAGE_REDHAT_IO_TOKEN }};DOWNLOAD_NODE=${{ secrets.DOWNLOAD_NODE }}" + rhel-9-9-bootc: + needs: check-pull-request + if: ${{ needs.check-pull-request.outputs.allowed_user == 'true' }} + continue-on-error: true + runs-on: ubuntu-latest + + steps: + - name: Run the tests + uses: sclorg/testing-farm-as-github-action@v3.1.2 + with: + compose: RHEL-9.9.0-Nightly + api_key: ${{ secrets.TF_API_KEY }} + git_url: ${{ needs.check-pull-request.outputs.repo_url }} + git_ref: ${{ needs.check-pull-request.outputs.ref }} + update_pull_request_status: true + pull_request_status_name: rhel-9.9-bootc + tmt_context: "arch=x86_64;distro=rhel-9-9" + tmt_plan_regex: bootc + tf_scope: private + variables: "ARCH=x86_64" + timeout: 90 + secrets: "QUAY_USERNAME=${{ secrets.QUAY_USERNAME }};QUAY_PASSWORD=${{ secrets.QUAY_PASSWORD }};STAGE_REDHAT_IO_USERNAME=${{ secrets.STAGE_REDHAT_IO_USERNAME }};STAGE_REDHAT_IO_TOKEN=${{ secrets.STAGE_REDHAT_IO_TOKEN }};DOWNLOAD_NODE=${{ secrets.DOWNLOAD_NODE }}" + rhel-10-2-bootc: needs: check-pull-request if: ${{ needs.check-pull-request.outputs.allowed_user == 'true' }} @@ -204,3 +227,26 @@ jobs: variables: "ARCH=x86_64;PR_NUMBER=${{ needs.check-pull-request.outputs.pr_number }}" timeout: 90 secrets: "QUAY_USERNAME=${{ secrets.QUAY_USERNAME }};QUAY_PASSWORD=${{ secrets.QUAY_PASSWORD }};STAGE_REDHAT_IO_USERNAME=${{ secrets.STAGE_REDHAT_IO_USERNAME }};STAGE_REDHAT_IO_TOKEN=${{ secrets.STAGE_REDHAT_IO_TOKEN }};DOWNLOAD_NODE=${{ secrets.DOWNLOAD_NODE }}" + + rhel-10-3-bootc: + needs: check-pull-request + if: ${{ needs.check-pull-request.outputs.allowed_user == 'true' }} + continue-on-error: true + runs-on: ubuntu-latest + + steps: + - name: Run the tests + uses: sclorg/testing-farm-as-github-action@v3.1.2 + with: + compose: RHEL-10.3-Nightly + api_key: ${{ secrets.TF_API_KEY }} + git_url: ${{ needs.check-pull-request.outputs.repo_url }} + git_ref: ${{ needs.check-pull-request.outputs.ref }} + update_pull_request_status: true + pull_request_status_name: rhel-10.3-bootc + tmt_context: "arch=x86_64;distro=rhel-10-3" + tmt_plan_regex: bootc + tf_scope: private + variables: "ARCH=x86_64" + timeout: 90 + secrets: "QUAY_USERNAME=${{ secrets.QUAY_USERNAME }};QUAY_PASSWORD=${{ secrets.QUAY_PASSWORD }};STAGE_REDHAT_IO_USERNAME=${{ secrets.STAGE_REDHAT_IO_USERNAME }};STAGE_REDHAT_IO_TOKEN=${{ secrets.STAGE_REDHAT_IO_TOKEN }};DOWNLOAD_NODE=${{ secrets.DOWNLOAD_NODE }}" diff --git a/tests/common/download-compose-rpms.sh b/tests/common/download-compose-rpms.sh new file mode 100644 index 0000000..e7d32e5 --- /dev/null +++ b/tests/common/download-compose-rpms.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Source this file to get the download_compose_rpms helper function. + +# download_compose_rpms +# +# Downloads the latest greenboot and greenboot-default-health-checks RPMs +# from the compose packages index at into . +# +# The packages index page is fetched once and reused for both lookups. +# +# The -k (--insecure) flag is required because RHEL internal compose servers +# use certificates signed by the Red Hat internal CA, which is not present +# in the default system trust store on CI hosts. +download_compose_rpms() { + local packages_url="$1" + local dest_dir="$2" + + local packages_page + packages_page="$(curl -kfsSL --retry 5 --retry-delay 2 --retry-all-errors \ + "${packages_url}")" + + local greenboot_rpm + greenboot_rpm="$(echo "${packages_page}" \ + | grep -oE 'greenboot-[0-9][^"]*\.rpm' \ + | grep -vE 'debug(info|source)' \ + | sort -V | tail -n 1)" + echo "Selected greenboot RPM: ${greenboot_rpm}" + + local greenboot_default_rpm + greenboot_default_rpm="$(echo "${packages_page}" \ + | grep -oE 'greenboot-default-health-checks-[0-9][^"]*\.rpm' \ + | sort -V | tail -n 1)" + echo "Selected greenboot-default-health-checks RPM: ${greenboot_default_rpm}" + + curl -kfsSL --retry 5 --retry-delay 2 --retry-all-errors \ + "${packages_url}${greenboot_rpm}" -o "${dest_dir}/${greenboot_rpm}" + curl -kfsSL --retry 5 --retry-delay 2 --retry-all-errors \ + "${packages_url}${greenboot_default_rpm}" -o "${dest_dir}/${greenboot_default_rpm}" +} diff --git a/tests/files/rhel-10-2.repo b/tests/files/rhel-10-2.repo index c66bbdd..5a49dc6 100644 --- a/tests/files/rhel-10-2.repo +++ b/tests/files/rhel-10-2.repo @@ -1,10 +1,10 @@ [RHEL-10.2-NIGHTLY-BaseOS] name=baseos -baseurl=http://REPLACE_ME_HERE/rhel-10/nightly/RHEL-10/latest-RHEL-10.2/compose/BaseOS/x86_64/os +baseurl=http://REPLACE_ME_HERE/rhel-10/nightly/RHEL-10/latest-RHEL-10.2/compose/BaseOS/REPLACE_ARCH_HERE/os enabled=1 gpgcheck=0 [RHEL-10.2-NIGHTLY-AppStream] name=appstream -baseurl=http://REPLACE_ME_HERE/rhel-10/nightly/RHEL-10/latest-RHEL-10.2/compose/AppStream/x86_64/os/ +baseurl=http://REPLACE_ME_HERE/rhel-10/nightly/RHEL-10/latest-RHEL-10.2/compose/AppStream/REPLACE_ARCH_HERE/os/ enabled=1 gpgcheck=0 diff --git a/tests/files/rhel-10-3.repo b/tests/files/rhel-10-3.repo new file mode 100644 index 0000000..269fe04 --- /dev/null +++ b/tests/files/rhel-10-3.repo @@ -0,0 +1,10 @@ +[RHEL-10.3-NIGHTLY-BaseOS] +name=baseos +baseurl=http://REPLACE_ME_HERE/rhel-10/nightly/RHEL-10/latest-RHEL-10.3/compose/BaseOS/REPLACE_ARCH_HERE/os +enabled=1 +gpgcheck=0 +[RHEL-10.3-NIGHTLY-AppStream] +name=appstream +baseurl=http://REPLACE_ME_HERE/rhel-10/nightly/RHEL-10/latest-RHEL-10.3/compose/AppStream/REPLACE_ARCH_HERE/os/ +enabled=1 +gpgcheck=0 diff --git a/tests/files/rhel-9-8.repo b/tests/files/rhel-9-8.repo index df97736..c4bc8f6 100644 --- a/tests/files/rhel-9-8.repo +++ b/tests/files/rhel-9-8.repo @@ -1,10 +1,10 @@ [RHEL-9.8-NIGHTLY-BaseOS] name=baseos -baseurl=http://REPLACE_ME_HERE/rhel-9/nightly/RHEL-9/latest-RHEL-9.8.0/compose/BaseOS/x86_64/os/ +baseurl=http://REPLACE_ME_HERE/rhel-9/nightly/RHEL-9/latest-RHEL-9.8.0/compose/BaseOS/REPLACE_ARCH_HERE/os/ enabled=1 gpgcheck=0 [RHEL-9.8-NIGHTLY-AppStream] name=appstream -baseurl=http://REPLACE_ME_HERE/rhel-9/nightly/RHEL-9/latest-RHEL-9.8.0/compose/AppStream/x86_64/os/ +baseurl=http://REPLACE_ME_HERE/rhel-9/nightly/RHEL-9/latest-RHEL-9.8.0/compose/AppStream/REPLACE_ARCH_HERE/os/ enabled=1 gpgcheck=0 diff --git a/tests/files/rhel-9-9.repo b/tests/files/rhel-9-9.repo new file mode 100644 index 0000000..f9a8bf0 --- /dev/null +++ b/tests/files/rhel-9-9.repo @@ -0,0 +1,10 @@ +[RHEL-9.9-NIGHTLY-BaseOS] +name=baseos +baseurl=http://REPLACE_ME_HERE/rhel-9/nightly/RHEL-9/latest-RHEL-9.9.0/compose/BaseOS/REPLACE_ARCH_HERE/os/ +enabled=1 +gpgcheck=0 +[RHEL-9.9-NIGHTLY-AppStream] +name=appstream +baseurl=http://REPLACE_ME_HERE/rhel-9/nightly/RHEL-9/latest-RHEL-9.9.0/compose/AppStream/REPLACE_ARCH_HERE/os/ +enabled=1 +gpgcheck=0 diff --git a/tests/greenboot-bootc-anaconda-iso.sh b/tests/greenboot-bootc-anaconda-iso.sh index 6d80d63..f62078c 100755 --- a/tests/greenboot-bootc-anaconda-iso.sh +++ b/tests/greenboot-bootc-anaconda-iso.sh @@ -24,6 +24,7 @@ echo -e "\033[0m" source /etc/os-release # Setup variables +ARCH=$(uname -m) TEST_UUID=anaconda-$((1 + RANDOM % 1000000)) TEMPDIR=$(mktemp -d) GUEST_ADDRESS=192.168.100.50 @@ -34,6 +35,15 @@ EDGE_USER=core EDGE_USER_PASSWORD=foobar CONSOLE_LOG=/tmp/vm-console.log +# RPM acquisition mode: +# If DOWNLOAD_NODE and COMPOSE_ID are both set -> download from compose +# Otherwise -> build locally with make rpm (default) +USE_COMPOSE_RPMS=false +if [[ -n "${DOWNLOAD_NODE:-}" && -n "${COMPOSE_ID:-}" ]]; then + USE_COMPOSE_RPMS=true +fi +GREENBOOT_PACKAGES_URL="" + case "${ID}-${VERSION_ID}" in "fedora-43") OS_VARIANT="fedora-unknown" @@ -64,14 +74,52 @@ case "${ID}-${VERSION_ID}" in BASE_IMAGE_URL="registry.stage.redhat.io/rhel9/rhel-bootc:9.8" BIB_URL="registry.stage.redhat.io/rhel9/bootc-image-builder:9.8" BOOT_ARGS="uefi" + { set +x; } 2>/dev/null sed -i "s/REPLACE_ME_HERE/${DOWNLOAD_NODE}/g" files/rhel-9-8.repo + sed -i "s/REPLACE_ARCH_HERE/${ARCH}/g" files/rhel-9-8.repo + if [[ "${USE_COMPOSE_RPMS}" == true ]]; then + GREENBOOT_PACKAGES_URL="https://${DOWNLOAD_NODE}/rhel-9/composes/RHEL-9/${COMPOSE_ID}/compose/AppStream/${ARCH}/os/Packages/" + fi + set -x + ;; + "rhel-9.9") + OS_VARIANT="rhel9-unknown" + BASE_IMAGE_URL="registry.stage.redhat.io/rhel9/rhel-bootc:9.9" + BIB_URL="registry.stage.redhat.io/rhel9/bootc-image-builder:9.9" + BOOT_ARGS="uefi" + { set +x; } 2>/dev/null + sed -i "s/REPLACE_ME_HERE/${DOWNLOAD_NODE}/g" files/rhel-9-9.repo + sed -i "s/REPLACE_ARCH_HERE/${ARCH}/g" files/rhel-9-9.repo + if [[ "${USE_COMPOSE_RPMS}" == true ]]; then + GREENBOOT_PACKAGES_URL="https://${DOWNLOAD_NODE}/rhel-9/composes/RHEL-9/${COMPOSE_ID}/compose/AppStream/${ARCH}/os/Packages/" + fi + set -x ;; "rhel-10.2") OS_VARIANT="rhel10-unknown" BASE_IMAGE_URL="registry.stage.redhat.io/rhel10/rhel-bootc:10.2" BIB_URL="registry.stage.redhat.io/rhel10/bootc-image-builder:10.2" BOOT_ARGS="uefi" + { set +x; } 2>/dev/null sed -i "s/REPLACE_ME_HERE/${DOWNLOAD_NODE}/g" files/rhel-10-2.repo + sed -i "s/REPLACE_ARCH_HERE/${ARCH}/g" files/rhel-10-2.repo + if [[ "${USE_COMPOSE_RPMS}" == true ]]; then + GREENBOOT_PACKAGES_URL="https://${DOWNLOAD_NODE}/rhel-10/composes/RHEL-10/${COMPOSE_ID}/compose/AppStream/${ARCH}/os/Packages/" + fi + set -x + ;; + "rhel-10.3") + OS_VARIANT="rhel10-unknown" + BASE_IMAGE_URL="registry.stage.redhat.io/rhel10/rhel-bootc:10.3" + BIB_URL="registry.stage.redhat.io/rhel10/bootc-image-builder:10.3" + BOOT_ARGS="uefi" + { set +x; } 2>/dev/null + sed -i "s/REPLACE_ME_HERE/${DOWNLOAD_NODE}/g" files/rhel-10-3.repo + sed -i "s/REPLACE_ARCH_HERE/${ARCH}/g" files/rhel-10-3.repo + if [[ "${USE_COMPOSE_RPMS}" == true ]]; then + GREENBOOT_PACKAGES_URL="https://${DOWNLOAD_NODE}/rhel-10/composes/RHEL-10/${COMPOSE_ID}/compose/AppStream/${ARCH}/os/Packages/" + fi + set -x ;; *) echo "unsupported distro: ${ID}-${VERSION_ID}" @@ -183,6 +231,19 @@ greenprint "Copying test assets" cp testing_assets/failing_binary tests/ ) +########################################################### +## +## Optionally download greenboot rpm packages from compose +## +########################################################### +if [[ "${USE_COMPOSE_RPMS}" == true && -n "${GREENBOOT_PACKAGES_URL}" ]]; then + greenprint "Downloading greenboot RPMs from compose" + rm -f greenboot-*.rpm + # source: tests/common/download-compose-rpms.sh + source "$(dirname "${BASH_SOURCE[0]}")/common/download-compose-rpms.sh" + download_compose_rpms "${GREENBOOT_PACKAGES_URL}" "." +fi + ########################################################### ## ## Build bootc container with greenboot installed @@ -193,10 +254,25 @@ podman login quay.io -u ${QUAY_USERNAME} -p ${QUAY_PASSWORD} podman login registry.stage.redhat.io -u ${STAGE_REDHAT_IO_USERNAME} -p ${STAGE_REDHAT_IO_TOKEN} tee Containerfile > /dev/null << EOF FROM ${BASE_IMAGE_URL} +EOF + +if [[ "${USE_COMPOSE_RPMS}" == true && -n "${GREENBOOT_PACKAGES_URL}" ]]; then + tee -a Containerfile > /dev/null << EOF +COPY greenboot-*.rpm /tmp/ +RUN dnf install -y /tmp/greenboot-*.rpm && \ + rm -f /tmp/greenboot-*.rpm && \ + systemctl enable greenboot-healthcheck.service +EOF +else + tee -a Containerfile > /dev/null << EOF RUN dnf install -y 'dnf-command(copr)' && \ dnf copr enable -y packit/fedora-iot-greenboot-rs-${PR_NUMBER} && \ dnf install -y greenboot greenboot-default-health-checks && \ systemctl enable greenboot-healthcheck.service +EOF +fi + +tee -a Containerfile > /dev/null << EOF RUN sed -i "s/GREENBOOT_MAX_BOOT_ATTEMPTS=3/GREENBOOT_MAX_BOOT_ATTEMPTS=5/g" /etc/greenboot/greenboot.conf RUN sed -i 's#DISABLED_HEALTHCHECKS=()#DISABLED_HEALTHCHECKS=("01_repository_dns_check.sh" "not_exit.sh")#g' /etc/greenboot/greenboot.conf @@ -220,12 +296,24 @@ COPY files/rhel-9-8.repo /etc/yum.repos.d/rhel-9-8.repo EOF fi +if [[ "${ID}-${VERSION_ID}" == "rhel-9.9" ]]; then + tee -a Containerfile >> /dev/null << EOF +COPY files/rhel-9-9.repo /etc/yum.repos.d/rhel-9-9.repo +EOF +fi + if [[ "${ID}-${VERSION_ID}" == "rhel-10.2" ]]; then tee -a Containerfile >> /dev/null << EOF COPY files/rhel-10-2.repo /etc/yum.repos.d/rhel-10-2.repo EOF fi +if [[ "${ID}-${VERSION_ID}" == "rhel-10.3" ]]; then + tee -a Containerfile >> /dev/null << EOF +COPY files/rhel-10-3.repo /etc/yum.repos.d/rhel-10-3.repo +EOF +fi + greenprint "Building container (retrying until Copr build is available)" build_success=false for attempt in $(seq 1 10); do diff --git a/tests/greenboot-bootc-qcow2.sh b/tests/greenboot-bootc-qcow2.sh index 23130d8..653905e 100755 --- a/tests/greenboot-bootc-qcow2.sh +++ b/tests/greenboot-bootc-qcow2.sh @@ -24,6 +24,7 @@ echo -e "\033[0m" source /etc/os-release # Setup variables +ARCH=$(uname -m) TEST_UUID=qcow2-$((1 + RANDOM % 1000000)) TEMPDIR=$(mktemp -d) GUEST_ADDRESS=192.168.100.50 @@ -34,6 +35,15 @@ EDGE_USER=core EDGE_USER_PASSWORD=foobar CONSOLE_LOG=/tmp/vm-console.log +# RPM acquisition mode: +# If DOWNLOAD_NODE and COMPOSE_ID are both set -> download from compose +# Otherwise -> build locally with make rpm (default) +USE_COMPOSE_RPMS=false +if [[ -n "${DOWNLOAD_NODE:-}" && -n "${COMPOSE_ID:-}" ]]; then + USE_COMPOSE_RPMS=true +fi +GREENBOOT_PACKAGES_URL="" + case "${ID}-${VERSION_ID}" in "fedora-43") OS_VARIANT="fedora-unknown" @@ -64,14 +74,52 @@ case "${ID}-${VERSION_ID}" in BASE_IMAGE_URL="registry.stage.redhat.io/rhel9/rhel-bootc:9.8" BIB_URL="registry.stage.redhat.io/rhel9/bootc-image-builder:9.8" BOOT_ARGS="uefi" + { set +x; } 2>/dev/null sed -i "s/REPLACE_ME_HERE/${DOWNLOAD_NODE}/g" files/rhel-9-8.repo + sed -i "s/REPLACE_ARCH_HERE/${ARCH}/g" files/rhel-9-8.repo + if [[ "${USE_COMPOSE_RPMS}" == true ]]; then + GREENBOOT_PACKAGES_URL="https://${DOWNLOAD_NODE}/rhel-9/composes/RHEL-9/${COMPOSE_ID}/compose/AppStream/${ARCH}/os/Packages/" + fi + set -x + ;; + "rhel-9.9") + OS_VARIANT="rhel9-unknown" + BASE_IMAGE_URL="registry.stage.redhat.io/rhel9/rhel-bootc:9.9" + BIB_URL="registry.stage.redhat.io/rhel9/bootc-image-builder:9.9" + BOOT_ARGS="uefi" + { set +x; } 2>/dev/null + sed -i "s/REPLACE_ME_HERE/${DOWNLOAD_NODE}/g" files/rhel-9-9.repo + sed -i "s/REPLACE_ARCH_HERE/${ARCH}/g" files/rhel-9-9.repo + if [[ "${USE_COMPOSE_RPMS}" == true ]]; then + GREENBOOT_PACKAGES_URL="https://${DOWNLOAD_NODE}/rhel-9/composes/RHEL-9/${COMPOSE_ID}/compose/AppStream/${ARCH}/os/Packages/" + fi + set -x ;; "rhel-10.2") OS_VARIANT="rhel10-unknown" BASE_IMAGE_URL="registry.stage.redhat.io/rhel10/rhel-bootc:10.2" BIB_URL="registry.stage.redhat.io/rhel10/bootc-image-builder:10.2" BOOT_ARGS="uefi" + { set +x; } 2>/dev/null sed -i "s/REPLACE_ME_HERE/${DOWNLOAD_NODE}/g" files/rhel-10-2.repo + sed -i "s/REPLACE_ARCH_HERE/${ARCH}/g" files/rhel-10-2.repo + if [[ "${USE_COMPOSE_RPMS}" == true ]]; then + GREENBOOT_PACKAGES_URL="https://${DOWNLOAD_NODE}/rhel-10/composes/RHEL-10/${COMPOSE_ID}/compose/AppStream/${ARCH}/os/Packages/" + fi + set -x + ;; + "rhel-10.3") + OS_VARIANT="rhel10-unknown" + BASE_IMAGE_URL="registry.stage.redhat.io/rhel10/rhel-bootc:10.3" + BIB_URL="registry.stage.redhat.io/rhel10/bootc-image-builder:10.3" + BOOT_ARGS="uefi" + { set +x; } 2>/dev/null + sed -i "s/REPLACE_ME_HERE/${DOWNLOAD_NODE}/g" files/rhel-10-3.repo + sed -i "s/REPLACE_ARCH_HERE/${ARCH}/g" files/rhel-10-3.repo + if [[ "${USE_COMPOSE_RPMS}" == true ]]; then + GREENBOOT_PACKAGES_URL="https://${DOWNLOAD_NODE}/rhel-10/composes/RHEL-10/${COMPOSE_ID}/compose/AppStream/${ARCH}/os/Packages/" + fi + set -x ;; *) echo "unsupported distro: ${ID}-${VERSION_ID}" @@ -183,6 +231,19 @@ greenprint "Copying test assets" cp testing_assets/failing_binary tests/ ) +########################################################### +## +## Optionally download greenboot rpm packages from compose +## +########################################################### +if [[ "${USE_COMPOSE_RPMS}" == true && -n "${GREENBOOT_PACKAGES_URL}" ]]; then + greenprint "Downloading greenboot RPMs from compose" + rm -f greenboot-*.rpm + # source: tests/common/download-compose-rpms.sh + source "$(dirname "${BASH_SOURCE[0]}")/common/download-compose-rpms.sh" + download_compose_rpms "${GREENBOOT_PACKAGES_URL}" "." +fi + ########################################################### ## ## Build bootc container with greenboot installed @@ -193,10 +254,25 @@ podman login quay.io -u ${QUAY_USERNAME} -p ${QUAY_PASSWORD} podman login registry.stage.redhat.io -u ${STAGE_REDHAT_IO_USERNAME} -p ${STAGE_REDHAT_IO_TOKEN} tee Containerfile > /dev/null << EOF FROM ${BASE_IMAGE_URL} +EOF + +if [[ "${USE_COMPOSE_RPMS}" == true && -n "${GREENBOOT_PACKAGES_URL}" ]]; then + tee -a Containerfile > /dev/null << EOF +COPY greenboot-*.rpm /tmp/ +RUN dnf install -y /tmp/greenboot-*.rpm && \ + rm -f /tmp/greenboot-*.rpm && \ + systemctl enable greenboot-healthcheck.service +EOF +else + tee -a Containerfile > /dev/null << EOF RUN dnf install -y 'dnf-command(copr)' && \ dnf copr enable -y packit/fedora-iot-greenboot-rs-${PR_NUMBER} && \ dnf install -y greenboot greenboot-default-health-checks && \ systemctl enable greenboot-healthcheck.service +EOF +fi + +tee -a Containerfile > /dev/null << EOF RUN sed -i "s/GREENBOOT_MAX_BOOT_ATTEMPTS=3/GREENBOOT_MAX_BOOT_ATTEMPTS=5/g" /etc/greenboot/greenboot.conf RUN sed -i 's#DISABLED_HEALTHCHECKS=()#DISABLED_HEALTHCHECKS=("01_repository_dns_check.sh" "not_exit.sh")#g' /etc/greenboot/greenboot.conf @@ -220,12 +296,24 @@ COPY files/rhel-9-8.repo /etc/yum.repos.d/rhel-9-8.repo EOF fi +if [[ "${ID}-${VERSION_ID}" == "rhel-9.9" ]]; then + tee -a Containerfile >> /dev/null << EOF +COPY files/rhel-9-9.repo /etc/yum.repos.d/rhel-9-9.repo +EOF +fi + if [[ "${ID}-${VERSION_ID}" == "rhel-10.2" ]]; then tee -a Containerfile >> /dev/null << EOF COPY files/rhel-10-2.repo /etc/yum.repos.d/rhel-10-2.repo EOF fi +if [[ "${ID}-${VERSION_ID}" == "rhel-10.3" ]]; then + tee -a Containerfile >> /dev/null << EOF +COPY files/rhel-10-3.repo /etc/yum.repos.d/rhel-10-3.repo +EOF +fi + greenprint "Building container (retrying until Copr build is available)" build_success=false for attempt in $(seq 1 10); do diff --git a/tests/greenboot-ostree.sh b/tests/greenboot-ostree.sh index 537a78e..6d26e08 100755 --- a/tests/greenboot-ostree.sh +++ b/tests/greenboot-ostree.sh @@ -77,6 +77,15 @@ for _ in $(seq 0 30); do sleep 10 done +# RPM acquisition mode: +# If DOWNLOAD_NODE and COMPOSE_ID are both set -> download from compose +# Otherwise -> build locally with make rpm (default) +USE_COMPOSE_RPMS=false +if [[ -n "${DOWNLOAD_NODE:-}" && -n "${COMPOSE_ID:-}" ]]; then + USE_COMPOSE_RPMS=true +fi +GREENBOOT_PACKAGES_URL="" + # Customize repository sudo mkdir -p /etc/osbuild-composer/repositories @@ -103,15 +112,29 @@ case "${ID}-${VERSION_ID}" in OS_VARIANT="rhel9-unknown" BOOT_LOCATION="http://${DOWNLOAD_NODE}/rhel-9/nightly/RHEL-9/latest-RHEL-9.8.0/compose/BaseOS/${ARCH}/os/" COPR_REPO_URL="https://download.copr.fedorainfracloud.org/results/packit/fedora-iot-greenboot-rs-${PR_NUMBER}/centos-stream-9-${ARCH}/" + if [[ "${USE_COMPOSE_RPMS}" == true ]]; then + GREENBOOT_PACKAGES_URL="https://${DOWNLOAD_NODE}/rhel-9/composes/RHEL-9/${COMPOSE_ID}/compose/AppStream/x86_64/os/Packages/" + fi sed "s/REPLACE_ME_HERE/${DOWNLOAD_NODE}/g" files/rhel-9-8-0.json | sudo tee /etc/osbuild-composer/repositories/rhel-98.json > /dev/null;; *) echo "unsupported distro: ${ID}-${VERSION_ID}" exit 1;; esac -# Add Copr repo as osbuild-composer source for greenboot PR builds -greenprint "Adding Copr source for greenboot PR #${PR_NUMBER}" -sudo tee /tmp/greenboot-copr.toml > /dev/null << EOF +if [[ "${USE_COMPOSE_RPMS}" == true && -n "${GREENBOOT_PACKAGES_URL}" ]]; then + # Layer in a pre-built greenboot RPM from compose instead of Copr, e.g. + # for RHEL targets where Copr only provides a CentOS Stream approximation. + greenprint "Downloading greenboot RPMs from compose: ${GREENBOOT_PACKAGES_URL}" + mkdir -p /var/www/html/packages + # source: tests/common/download-compose-rpms.sh + source "$(dirname "${BASH_SOURCE[0]}")/common/download-compose-rpms.sh" + download_compose_rpms "${GREENBOOT_PACKAGES_URL}" "/var/www/html/packages" + sudo createrepo_c /var/www/html/packages + sudo restorecon -Rv /var/www/html/packages +else + # Add Copr repo as osbuild-composer source for greenboot PR builds + greenprint "Adding Copr source for greenboot PR #${PR_NUMBER}" + sudo tee /tmp/greenboot-copr.toml > /dev/null << EOF id = "greenboot-copr" name = "Packit Copr greenboot PR build" type = "yum-baseurl" @@ -119,19 +142,20 @@ url = "${COPR_REPO_URL}" check_gpg = false check_ssl = false EOF -copr_added=false -for _ in $(seq 0 30); do - if sudo composer-cli sources add /tmp/greenboot-copr.toml; then - copr_added=true - break - fi - greenprint "Copr source not ready yet, retrying in 30s..." - sleep 30 -done + copr_added=false + for _ in $(seq 0 30); do + if sudo composer-cli sources add /tmp/greenboot-copr.toml; then + copr_added=true + break + fi + greenprint "Copr source not ready yet, retrying in 30s..." + sleep 30 + done -if [ "$copr_added" = false ]; then - echo "Failed to add Copr source after 30 attempts." - exit 1 + if [ "$copr_added" = false ]; then + echo "Failed to add Copr source after 30 attempts." + exit 1 + fi fi # Check ostree_key permissions