diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..eae2fec0 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +.cosa +target diff --git a/.gitignore b/.gitignore index b59902fd..72355c7c 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ example /target Cargo.lock +bootc.tar.zst diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..84eff857 --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +prefix ?= /usr + +all: + cargo build --release + +install: + install -D -t $(DESTDIR)$(prefix)/bin target/release/bootc + +bin-archive: all + $(MAKE) install DESTDIR=tmp-install && tar --zstd -C tmp-install -cf bootc.tar.zst . && rm tmp-install -rf + +install-kola-tests: + install -D -t $(DESTDIR)$(prefix)/lib/coreos-assembler/tests/kola/bootc tests/kolainst/basic diff --git a/ci/Dockerfile.ci b/ci/Dockerfile.ci new file mode 100644 index 00000000..fc9f2643 --- /dev/null +++ b/ci/Dockerfile.ci @@ -0,0 +1,10 @@ +# This really just depends on `cosa run`, which we could +# in theory split out separately at some point later. +FROM quay.io/coreos-assembler/coreos-assembler:latest +WORKDIR /srv +USER root +# Grab all of our ci scripts +COPY /src/ci/ /ci/ +RUN ln -sr /ci/run-kola.sh /usr/bin/bootc-run-kola +USER builder +CMD ["/usr/bin/bootc-run-kola"] diff --git a/ci/Dockerfile.fcos b/ci/Dockerfile.fcos new file mode 100644 index 00000000..2d79eb36 --- /dev/null +++ b/ci/Dockerfile.fcos @@ -0,0 +1,10 @@ +# This Dockerfile generates a container image that installs bootc into +# a Fedora CoreOS image. +FROM quay.io/coreos-assembler/fcos-buildroot:testing-devel as builder +WORKDIR /src +COPY . . +RUN make bin-archive + +FROM quay.io/fedora/fedora-coreos:testing-devel +COPY --from=builder /src/bootc.tar.zst /tmp +RUN tar -xvf /tmp/bootc.tar.zst && ostree container commit diff --git a/ci/run-kola.sh b/ci/run-kola.sh new file mode 100755 index 00000000..22a90f57 --- /dev/null +++ b/ci/run-kola.sh @@ -0,0 +1,20 @@ +#!/bin/bash +set -xeuo pipefail + +# We require the an image containing bootc-under-test to have been injected +# by an external system, e.g. Prow +# https://docs.ci.openshift.org/docs/architecture/ci-operator/#referring-to-images-in-tests +if test -z "${TARGET_IMAGE:-}"; then + echo "fatal: Must set TARGET_IMAGE" 1>&2; exit 1 +fi +echo "Test base image: ${TARGET_IMAGE}" + +tmpdir="$(mktemp -d -p /var/tmp)" +cd "${tmpdir}" +if test -z "${BASE_QEMU_IMAGE:-}"; then + coreos-installer download -p qemu -f qcow2.xz --decompress + BASE_QEMU_IMAGE="$(echo *.qcow2)" +fi +kola run --oscontainer ostree-unverified-registry:${TARGET_IMAGE} --qemu-image "./${BASE_QEMU_IMAGE}" ext.bootc.'*' + +echo "ok kola bootc" diff --git a/tests/kolainst/basic b/tests/kolainst/basic new file mode 100644 index 00000000..7f45519c --- /dev/null +++ b/tests/kolainst/basic @@ -0,0 +1,24 @@ +#!/bin/bash +# Verify basic bootc functionality. +## kola: +## timeoutMin: 30 +## tags: "needs-internet" +# +# Copyright (C) 2022 Red Hat, Inc. + +set -xeuo pipefail + +cd $(mktemp -d) + +case "${AUTOPKGTEST_REBOOT_MARK:-}" in + "") + bootc status --json > status.json + image=$(jq -r '.[0].image.image' < status.json) + echo "booted into $image" + + # TODO more tests here + + echo "ok status test" + ;; + *) echo "unexpected mark: ${AUTOPKGTEST_REBOOT_MARK}"; exit 1;; +esac