Skip to content

test: add e2e test #1359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
101 changes: 101 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: build bootc and bootc image

on:
pull_request:
branches: [ main ]

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm]
# os: [ubuntu-latest]
# distro: [fedora-41, fedora-42, fedora-r43, centos-stream-9, centos-stream-10]
distro: [centos-stream-9]
runs-on: ${{ matrix.os }}

# Required to push container image to ghcr.io
# https://github.com/orgs/community/discussions/57724
permissions:
contents: read
packages: write
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per discussion let's create a default flow in Github Actions that builds a bootc container image tagged with the sha digest and pushes to ghcr.io under the repo namespace.

Then we can run further tests on that container image.

I think we'll need a scheduled workflow to prune the images though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@henrywang you're saying the push permission here wasn't working, can you link to a failing run?

I am not aware of anything special at all here, a ton of projects use a similar flow so it should work - we definitely have this enabled at the repo level

image

attestations: write
id-token: write

steps:
- uses: actions/checkout@v4

- name: Build bootc RPM
env:
DISTRO: ${{ matrix.distro }}
BUILD_IMAGE: quay.io/fedora/fedora:42
run: |
podman run \
--rm \
--privileged \
-v $(pwd):/workdir:z \
-e DISTRO=$DISTRO \
--workdir /workdir \
$BUILD_IMAGE \
contrib/scripts/mock_build.sh

- name: Re-build bootc image with new bootc PRM
env:
DISTRO: ${{ matrix.distro }}
run: |
set -xeu
if [[ $DISTRO =~ fedora ]]; then
VERSION_ID=$(cut -d'-' -f2 <<<"$DISTRO")
BASE_IMAGE="quay.io/fedora/fedora-bootc:${VERSION_ID}"
fi
if [[ $DISTRO =~ centos ]]; then
VERSION_ID=$(cut -d'-' -f3 <<<"$DISTRO")
BASE_IMAGE="quay.io/centos-bootc/centos-bootc:stream${VERSION_ID}"
fi

tee target/build/Containerfile >/dev/null <<CONTAINERFILEEOF
FROM $BASE_IMAGE
RUN dnf -y upgrade /rpms/*.rpm && dnf -y clean all && rm -rf /var/cache /var/lib/dnf
CONTAINERFILEEOF
cat target/build/Containerfile

IMAGE_NAME="bootc-image:${{ github.sha }}-$(uname -m)"
IMAGE_TAG="${{ github.sha }}-$(uname -m)"
buildah build -v "$(pwd)/target/build/":/rpms:z -t $IMAGE_NAME target/build
buildah login -u bootc-dev -p ${{ secrets.GITHUB_TOKEN }} ghcr.io
buildah push $IMAGE_NAME "docker://ghcr.io/bootc-dev/${IMAGE_NAME}"

push:
needs: build
runs-on: ubuntu-latest

# Required to push container image to ghcr.io
# https://github.com/orgs/community/discussions/57724
permissions:
contents: read
packages: write
attestations: write
id-token: write

steps:
- uses: actions/checkout@v4

- name: Push manifest
env:
ARCHES: "x86_64 aarch64"
run: |
set -xeuo pipefail
REGISTRY_NAME="ghcr.io/${{ github.event.pull_request.head.repo.full_name }}/bootc-image"
buildah login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io

for arch in $ARCHES; do
buildah pull "${REGISTRY_NAME}:${{ github.sha }}-${arch}"
done

buildah manifest create "${REGISTRY_NAME}:${{ github.sha }}" `for arch in ${ARCHES}; do echo "${REGISTRY_NAME}:${{ github.sha }}-${arch};" done`

for arch in ${ARCHES}; do
buildah manifest annotate "${REGISTRY_NAME}:${{ github.sha }}" "${REGISTRY_NAME}:${{ github.sha }}-${arch}" --os linux --arch ${arch}
done
buildah tag "${REGISTRY_NAME}:${{ github.sha }}"
buildah manifest push --all "${REGISTRY_NAME}:${{ github.sha }}" docker://"${REGISTRY_NAME}:${{ github.sha }}"
8 changes: 5 additions & 3 deletions .packit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ jobs:
- centos-stream-10-s390x
- fedora-41-x86_64
- fedora-41-aarch64
- fedora-41-ppc64le
- fedora-41-s390x
- fedora-42-x86_64
- fedora-42-aarch64
- fedora-42-ppc64le
- fedora-42-s390x
# Sanity check on secondary targets, fewer architectures just
# because the chance that we break e.g. ppc64le *just* on
# rawhide is basically nil.
Expand Down Expand Up @@ -81,7 +83,7 @@ jobs:
- fedora-rawhide-aarch64
tmt_plan: /integration
skip_build: true
identifier: integration-test
identifier: integration

- job: propose_downstream
trigger: release
Expand Down
30 changes: 30 additions & 0 deletions contrib/scripts/mock_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
set -exuo pipefail

ARCH=$(uname -m)
MOCK_CONFIG="${DISTRO}-${ARCH}"

sudo dnf install -y cargo zstd git openssl-devel ostree-devel rpm-build mock

sudo dnf -y builddep contrib/packaging/bootc.spec
cargo install cargo-vendor-filterer

cargo xtask spec

# Adding user to mock group
sudo usermod -a -G mock "$(whoami)"

# Building SRPM
mock -r "$MOCK_CONFIG" --buildsrpm \
--spec "target/bootc.spec" \
--config-opts=cleanup_on_failure=False \
--config-opts=cleanup_on_success=True \
--sources target \
--resultdir target/build

# Building RPMs
mock -r "$MOCK_CONFIG" \
--config-opts=cleanup_on_failure=False \
--config-opts=cleanup_on_success=True \
--resultdir "target/build" \
target/build/*.src.rpm
Loading