Skip to content

Commit a20957a

Browse files
committed
ci: add bootc RPM build and bootc container image build
Will run for each PR to build RPM and re-build bootc container to replace bootc with new build one Signed-off-by: Xiaofeng Wang <[email protected]>
1 parent d72bb14 commit a20957a

File tree

3 files changed

+135
-3
lines changed

3 files changed

+135
-3
lines changed

.github/workflows/e2e.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: build bootc and bootc image
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
7+
jobs:
8+
build:
9+
strategy:
10+
matrix:
11+
os: [ubuntu-latest, ubuntu-24.04-arm]
12+
# os: [ubuntu-latest]
13+
# distro: [fedora-41, fedora-42, fedora-r43, centos-stream-9, centos-stream-10]
14+
distro: [centos-stream-9]
15+
runs-on: ${{ matrix.os }}
16+
17+
# Required to push container image to ghcr.io
18+
# https://github.com/orgs/community/discussions/57724
19+
permissions:
20+
contents: read
21+
packages: write
22+
attestations: write
23+
id-token: write
24+
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- name: Build bootc RPM
29+
env:
30+
DISTRO: ${{ matrix.distro }}
31+
BUILD_IMAGE: quay.io/fedora/fedora:42
32+
run: |
33+
podman run \
34+
--rm \
35+
--privileged \
36+
-v $(pwd):/workdir:z \
37+
-e DISTRO=$DISTRO \
38+
--workdir /workdir \
39+
$BUILD_IMAGE \
40+
contrib/scripts/mock_build.sh
41+
42+
- name: Re-build bootc image with new bootc PRM
43+
env:
44+
DISTRO: ${{ matrix.distro }}
45+
run: |
46+
set -xeu
47+
if [[ $DISTRO =~ fedora ]]; then
48+
VERSION_ID=$(cut -d'-' -f2 <<<"$DISTRO")
49+
BASE_IMAGE="quay.io/fedora/fedora-bootc:${VERSION_ID}"
50+
fi
51+
if [[ $DISTRO =~ centos ]]; then
52+
VERSION_ID=$(cut -d'-' -f3 <<<"$DISTRO")
53+
BASE_IMAGE="quay.io/centos-bootc/centos-bootc:stream${VERSION_ID}"
54+
fi
55+
56+
tee target/build/Containerfile >/dev/null <<CONTAINERFILEEOF
57+
FROM $BASE_IMAGE
58+
RUN dnf -y upgrade /rpms/*.rpm && dnf -y clean all && rm -rf /var/cache /var/lib/dnf
59+
CONTAINERFILEEOF
60+
cat target/build/Containerfile
61+
62+
IMAGE_NAME="bootc-image:${{ github.sha }}-$(uname -m)"
63+
buildah build -v "$(pwd)/target/build/":/rpms:z -t $IMAGE_NAME target/build
64+
buildah login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io
65+
buildah push $IMAGE_NAME "docker://ghcr.io/${{ github.event.pull_request.head.repo.full_name }}/$IMAGE_NAME"
66+
67+
push:
68+
needs: build
69+
runs-on: ubuntu-latest
70+
71+
# Required to push container image to ghcr.io
72+
# https://github.com/orgs/community/discussions/57724
73+
permissions:
74+
contents: read
75+
packages: write
76+
attestations: write
77+
id-token: write
78+
79+
steps:
80+
- uses: actions/checkout@v4
81+
82+
- name: Push manifest
83+
env:
84+
ARCHES: "x86_64 aarch64"
85+
run: |
86+
set -xeuo pipefail
87+
REGISTRY_NAME="ghcr.io/${{ github.event.pull_request.head.repo.full_name }}/bootc-image"
88+
buildah login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io
89+
90+
for arch in $ARCHES; do
91+
buildah pull "${REGISTRY_NAME}:${{ github.sha }}-${arch}"
92+
done
93+
94+
buildah manifest create "${REGISTRY_NAME}:${{ github.sha }}" `for arch in ${ARCHES}; do echo "${REGISTRY_NAME}:${{ github.sha }}-${arch};" done`
95+
96+
for arch in ${ARCHES}; do
97+
buildah manifest annotate "${REGISTRY_NAME}:${{ github.sha }}" "${REGISTRY_NAME}:${{ github.sha }}-${arch}" --os linux --arch ${arch}
98+
done
99+
buildah tag "${REGISTRY_NAME}:${{ github.sha }}"
100+
buildah manifest push --all "${REGISTRY_NAME}:${{ github.sha }}" docker://"${REGISTRY_NAME}:${{ github.sha }}"

.packit.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ jobs:
4444
- centos-stream-10-s390x
4545
- fedora-41-x86_64
4646
- fedora-41-aarch64
47-
- fedora-41-ppc64le
48-
- fedora-41-s390x
47+
- fedora-42-x86_64
48+
- fedora-42-aarch64
49+
- fedora-42-ppc64le
50+
- fedora-42-s390x
4951
# Sanity check on secondary targets, fewer architectures just
5052
# because the chance that we break e.g. ppc64le *just* on
5153
# rawhide is basically nil.
@@ -81,7 +83,7 @@ jobs:
8183
- fedora-rawhide-aarch64
8284
tmt_plan: /integration
8385
skip_build: true
84-
identifier: integration-test
86+
identifier: integration
8587

8688
- job: propose_downstream
8789
trigger: release

contrib/scripts/mock_build.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
set -exuo pipefail
3+
4+
ARCH=$(uname -m)
5+
MOCK_CONFIG="${DISTRO}-${ARCH}"
6+
7+
sudo dnf install -y cargo zstd git openssl-devel ostree-devel rpm-build mock
8+
9+
sudo dnf -y builddep contrib/packaging/bootc.spec
10+
cargo install cargo-vendor-filterer
11+
12+
cargo xtask spec
13+
14+
# Adding user to mock group
15+
sudo usermod -a -G mock "$(whoami)"
16+
17+
# Building SRPM
18+
mock -r "$MOCK_CONFIG" --buildsrpm \
19+
--spec "target/bootc.spec" \
20+
--config-opts=cleanup_on_failure=False \
21+
--config-opts=cleanup_on_success=True \
22+
--sources target \
23+
--resultdir target/build
24+
25+
# Building RPMs
26+
mock -r "$MOCK_CONFIG" \
27+
--config-opts=cleanup_on_failure=False \
28+
--config-opts=cleanup_on_success=True \
29+
--resultdir "target/build" \
30+
target/build/*.src.rpm

0 commit comments

Comments
 (0)