Skip to content

Commit

Permalink
ci: prepare for using fedora image based ci
Browse files Browse the repository at this point in the history
Signed-off-by: Ming Lei <[email protected]>
  • Loading branch information
Ming Lei committed Aug 15, 2023
1 parent e6a02dc commit 8261bcf
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 116 deletions.
58 changes: 18 additions & 40 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,61 +25,39 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:

- name: "install: mkosi + dependencies"
shell: bash
run: |
sudo apt update -o Acquire::Retries=3
sudo apt install -y dnf rpm systemd-container qemu-system-x86 ovmf e2fsprogs btrfs-progs
rustup update stable && rustup default stable
wget https://github.com/systemd/mkosi/archive/refs/tags/v14.tar.gz
tar zxf v14.tar.gz
cd mkosi-14
sed -i '/gpgurl\ = \urllib.parse.urljoin/c \ gpgurl\ =\ \"https://fedoraproject.org/fedora.gpg\"' ./mkosi/__init__.py
python3 -m pip install --user ./
# Required for ssh'ing into VM
- name: "setup: environment"
run: |
sudo systemctl enable --now systemd-networkd
- name: "cache: os packages"
uses: actions/cache@v3
with:
path: mkosi.cache
key: fedora-cache-v1
sudo apt install -y dnf rpm qemu-system-x86 ovmf e2fsprogs btrfs-progs wget git \
qemu-utils genisoimage make sshpass unzip lynx bc openssl \
flex bison time util-linux
- name: "acquire: libublk"
uses: actions/checkout@v3

- name: "build: fedora image"
working-directory: ci
run: |
sudo $(which mkosi) build
- name: "start: boot fedora in qemu"
working-directory: ci
run: |
RUNNER_TRACKING_ID="" && sudo $(which mkosi) qemu -serial none -monitor none -display none | tee ${{ github.workspace }}/qemu.log &
- name: "Cache Fedora image"
id: cache-fedora
uses: actions/cache@v3
with:
path: ~/images
key: fedora-image-key

- name: "connect: check ssh connection"
shell: bash
timeout-minutes: 10
- name: "Generate Fedora Image"
working-directory: ci
if: steps.cache-fedora.outputs.cache-hit != 'true'
run: |
until mkosi ssh uname -a; do
echo "Retrying..."
sleep 0.25
done
pwd
ls -la
./setup-image 10 ~/images
- name: "test: run libublk test"
working-directory: ci
run: |
mkosi ssh ls -l /usr/share/
mkosi ssh cargo test --manifest-path /usr/share/libublk-rs/Cargo.toml
- name: "Show Images"
run: ls -l ~/images

- name: "cleanup"
if: always()
continue-on-error: true
run: |
cat ${{ github.workspace }}/qemu.log
#cat ${{ github.workspace }}/qemu.log
sudo pkill -f qemu
24 changes: 24 additions & 0 deletions ci/fedora-user-data
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#cloud-config
chpasswd:
list: |
root:linux
expire: False
ssh_pwauth: True
resize_rootfs: noblock
resize_rootfs: true

bootcmd:
- [ sh, -c, echo "=========bootcmd=========" ]

runcmd:
- [ sh, -c, echo "=========runcmd=========" ]
- [ sh, -c, echo "deltarpm=false" >> /etc/dnf/dnf.conf ]
- [ sh, -c, echo "keepcache=true" >> /etc/dnf/dnf.conf ]
- [ sh, -c, echo "ip_resolve=4" >> /etc/dnf/dnf.conf ]
- [ sh, -c, echo "fastestmirror=true" >> /etc/dnf/dnf.conf ]
- [ sh, -c, echo "PermitRootLogin yes" >> /etc/ssh/sshd_config ]
- [ sh, -c, sed -i '/^SELINUX=/ s/=.*/=disabled/' /etc/selinux/config ]
- [ sh, -c, cat /etc/ssh/sshd_config ]
- [ sh, -c, systemctl restart sshd ]

final_message: "SYSTEM READY TO LOG IN"
24 changes: 0 additions & 24 deletions ci/mkosi.build

This file was deleted.

2 changes: 0 additions & 2 deletions ci/mkosi.conf

This file was deleted.

28 changes: 0 additions & 28 deletions ci/mkosi.default.d/10-ubdsrv.conf

This file was deleted.

21 changes: 0 additions & 21 deletions ci/mkosi.default.d/fedora/10-fedora.conf

This file was deleted.

1 change: 0 additions & 1 deletion ci/mkosi.extra/etc/modules-load.d/ublk-drv.conf

This file was deleted.

28 changes: 28 additions & 0 deletions ci/setup-image
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

VM_ID=$1
VM_DIR=$2
ROOT_SIZE=4G

MY_DIR=$(cd "$(dirname "$0")";pwd)
USER_DATA=${MY_DIR}/fedora-user-data
LINK=https://ftp-nyc.osuosl.org/pub/fedora/linux/releases/38/Cloud/x86_64/images/Fedora-Cloud-Base-38-1.6.x86_64.qcow2
BASE_NAME=`basename $LINK`

cd $VM_DIR

rm -f $BASE_NAME
wget $LINK
#create root.qcow2, need qemu-system-x86 package
qemu-img create -f qcow2 -F qcow2 -b `basename $LINK` root.qcow2
qemu-img resize root.qcow2 $ROOT_SIZE
qemu-img info root.qcow2

echo "instance-id: ktest${VM_ID}" > ./meta-data
echo "local-hostname: ktest-${VM_ID}" >> ./meta-data
cp -f $USER_DATA ./user-data
genisoimage -output seed.iso -volid cidata -joliet -rock user-data meta-data

rm -f meta-data
rm -f user-data
cd -

0 comments on commit 8261bcf

Please sign in to comment.