mirror of
https://github.com/JasonN3/build-container-installer.git
synced 2025-12-25 10:57:55 +01:00
Merge branch 'main' into fix_container_dir
This commit is contained in:
commit
88c39b035f
5 changed files with 148 additions and 2 deletions
110
.github/workflows/build-and-test.yml
vendored
110
.github/workflows/build-and-test.yml
vendored
|
|
@ -82,7 +82,7 @@ jobs:
|
||||||
type=ref,event=branch
|
type=ref,event=branch
|
||||||
type=ref,event=pr
|
type=ref,event=pr
|
||||||
|
|
||||||
- name: Build ISO
|
- name: Build ISO with new container
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
arch: ${{ env.ARCH}}
|
arch: ${{ env.ARCH}}
|
||||||
|
|
@ -98,6 +98,7 @@ jobs:
|
||||||
mv build/deploy.iso build/${{ env.IMAGE_NAME }}-${{ env.VERSION }}.iso
|
mv build/deploy.iso build/${{ env.IMAGE_NAME }}-${{ env.VERSION }}.iso
|
||||||
|
|
||||||
- name: Upload ISO as artifact
|
- name: Upload ISO as artifact
|
||||||
|
id: upload
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: ${{ env.IMAGE_NAME }}-${{ env.VERSION }}.iso
|
name: ${{ env.IMAGE_NAME }}-${{ env.VERSION }}.iso
|
||||||
|
|
@ -106,3 +107,110 @@ jobs:
|
||||||
retention-days: 0
|
retention-days: 0
|
||||||
compression-level: 0
|
compression-level: 0
|
||||||
overwrite: true
|
overwrite: true
|
||||||
|
|
||||||
|
test-qemu:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- build-and-push-iso
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
steps:
|
||||||
|
- name: Checkout repo
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Ensure qemu is installed
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y qemu qemu-utils xorriso unzip qemu-system-x86 netcat socat jq isomd5sum ansible make
|
||||||
|
|
||||||
|
- name: Create disk
|
||||||
|
run: |
|
||||||
|
qemu-img create -f qcow2 disk.qcow2 50G
|
||||||
|
|
||||||
|
- name: Download generated ISO
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: ${{ env.IMAGE_NAME }}-${{ env.VERSION }}.iso
|
||||||
|
|
||||||
|
- name: Verify ISO
|
||||||
|
run: checkisomd5 ${{ env.IMAGE_NAME }}-${{ env.VERSION }}.iso
|
||||||
|
|
||||||
|
- name: Run ISO checks
|
||||||
|
run: |
|
||||||
|
mv ${{ env.IMAGE_NAME }}-${{ env.VERSION }}.iso deploy.iso
|
||||||
|
make test-iso
|
||||||
|
|
||||||
|
- name: Add Kickstart and Grub options to ISO
|
||||||
|
run: |
|
||||||
|
sudo mkdir /mnt/iso || true
|
||||||
|
sudo mount -o loop deploy.iso /mnt/iso
|
||||||
|
cp /mnt/iso/boot/grub2/grub.cfg grub.cfg
|
||||||
|
sudo umount /mnt/iso
|
||||||
|
sed -i 's/quiet/console=ttyS0,115200n8 inst.ks=cdrom:\/ks.cfg/' grub.cfg
|
||||||
|
sed -i 's/set default="1"/set default="0"/' grub.cfg
|
||||||
|
sed -i 's/set timeout=60/set timeout=1/' grub.cfg
|
||||||
|
cat << EOF > ks.cfg
|
||||||
|
lang en_US.UTF-8
|
||||||
|
keyboard us
|
||||||
|
timezone Americas/New_York
|
||||||
|
zerombr
|
||||||
|
clearpart --all --initlabel
|
||||||
|
autopart
|
||||||
|
poweroff
|
||||||
|
user --name=core --groups=wheel --password=foobar
|
||||||
|
%include /usr/share/anaconda/interactive-defaults.ks
|
||||||
|
EOF
|
||||||
|
xorriso -dialog on << EOF
|
||||||
|
-indev deploy.iso
|
||||||
|
-outdev test.iso
|
||||||
|
-boot_image any replay
|
||||||
|
-map ks.cfg ks.cfg
|
||||||
|
-chmod 0444 ks.cfg
|
||||||
|
-map grub.cfg boot/grub2/grub.cfg
|
||||||
|
-end
|
||||||
|
EOF
|
||||||
|
|
||||||
|
- name: Install the test VM
|
||||||
|
run: |
|
||||||
|
timeout 1h qemu-system-x86_64 -name "Anaconda" -boot d -m 4096 -cpu qemu64 -display none -cdrom test.iso -smp 2 -hda disk.qcow2 -serial telnet:localhost:4321,server,nowait & QEMU_PID=$!
|
||||||
|
echo "PID: $QEMU_PID"
|
||||||
|
timeout 1m bash -c "while ! (echo > /dev/tcp/127.0.0.1/4321); do sleep 0.1; done"
|
||||||
|
(nc localhost 4321 | tee vm.stdout) &
|
||||||
|
wait $QEMU_PID
|
||||||
|
|
||||||
|
- name: Start the test VM
|
||||||
|
env:
|
||||||
|
VM_USER: core
|
||||||
|
VM_PASS: foobar
|
||||||
|
run: |
|
||||||
|
mkfifo vm.stdin
|
||||||
|
qemu-system-x86_64 -name "Anaconda" \
|
||||||
|
-m 4096 -cpu qemu64 -display none -smp 2 \
|
||||||
|
-chardev socket,path=/tmp/qga.sock,server,nowait,id=qga0 \
|
||||||
|
-device virtio-serial \
|
||||||
|
-device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0 \
|
||||||
|
-boot c -hda disk.qcow2 -serial telnet:localhost:4321,server,nowait & export QEMU_PID=$!
|
||||||
|
echo "PID: $QEMU_PID"
|
||||||
|
|
||||||
|
timeout 1m bash -c "while ! (echo > /dev/tcp/127.0.0.1/4321); do sleep 0.1; done"
|
||||||
|
(tail -f vm.stdin | nc localhost 4321 | tee vm.stdout) &
|
||||||
|
|
||||||
|
timeout 30m bash -c "while ! (grep 'login:' vm.stdout); do sleep 1; done"
|
||||||
|
|
||||||
|
export VM_IP=$({ echo '{"execute": "guest-network-get-interfaces"}'; sleep 2; } | socat unix-connect:/tmp/qga.sock - | jq -r '.return[1]["ip-addresses"][] | select(."ip-address-type"=="ipv4") | .["ip-address"]')
|
||||||
|
if ! (echo > /dev/tcp/${VM_IP}/22)
|
||||||
|
then
|
||||||
|
echo "SSH must be installed and enabled inside the container"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "VM ready for tests at IP ${VM_IP}"
|
||||||
|
for check in $(ls tests/vm)
|
||||||
|
do
|
||||||
|
if [[ -f $check && $check != "README.md" ]]
|
||||||
|
then
|
||||||
|
chmod +x $check
|
||||||
|
./${check}
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
|
|
||||||
7
Makefile
7
Makefile
|
|
@ -10,7 +10,7 @@ WEB_UI = false
|
||||||
REPOS = /etc/yum.repos.d/fedora.repo /etc/yum.repos.d/fedora-updates.repo
|
REPOS = /etc/yum.repos.d/fedora.repo /etc/yum.repos.d/fedora-updates.repo
|
||||||
ENROLLMENT_PASSWORD =
|
ENROLLMENT_PASSWORD =
|
||||||
SECURE_BOOT_KEY_URL =
|
SECURE_BOOT_KEY_URL =
|
||||||
ADDITIONAL_TEMPLATES = ""
|
ADDITIONAL_TEMPLATES =
|
||||||
ROOTFS_SIZE = 4
|
ROOTFS_SIZE = 4
|
||||||
|
|
||||||
# Generated vars
|
# Generated vars
|
||||||
|
|
@ -175,6 +175,11 @@ clean:
|
||||||
|
|
||||||
install-deps:
|
install-deps:
|
||||||
dnf install -y lorax xorriso skopeo
|
dnf install -y lorax xorriso skopeo
|
||||||
|
|
||||||
|
test-iso:
|
||||||
|
$(eval _TESTS = $(filter-out README.md,$(shell ls tests/iso)))
|
||||||
|
$(foreach test,$(_TESTS),chmod +x tests/iso/$(test))
|
||||||
|
$(foreach test,$(_TESTS),./tests/iso/$(test) deploy.iso)
|
||||||
|
|
||||||
.PHONY: clean install-deps
|
.PHONY: clean install-deps
|
||||||
|
|
||||||
|
|
|
||||||
1
tests/iso/README.md
Normal file
1
tests/iso/README.md
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Place scripts that will test the ISO. The ISO file will be passed as the first argument
|
||||||
31
tests/iso/os-release.sh
Normal file
31
tests/iso/os-release.sh
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
iso=$1
|
||||||
|
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y squashfs-tools
|
||||||
|
|
||||||
|
sudo mkdir /mnt/{iso,install}
|
||||||
|
|
||||||
|
# Mount ISO
|
||||||
|
sudo mount -o loop $iso /mnt/iso
|
||||||
|
|
||||||
|
# Mount squashfs
|
||||||
|
sudo mount -t squashfs -o loop /mnt/iso/images/install.img /mnt/install
|
||||||
|
|
||||||
|
FOUND_VERSION=$(cat /mnt/install/etc/os-release | grep VERSION_ID | cut -d= -f2)
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
sudo umount /mnt/install
|
||||||
|
sudo umount /mnt/iso
|
||||||
|
|
||||||
|
if [[ ${FOUND_VERSION} != ${VERSION} ]]
|
||||||
|
then
|
||||||
|
echo "Version mismatch"
|
||||||
|
echo "Expected: ${VERSION}"
|
||||||
|
echo "Found: ${FOUND_VERSION}"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Correct version found"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
1
tests/vm/README.md
Normal file
1
tests/vm/README.md
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Place scripts that will test the VM. The VM will be available at ${VM_IP} using username ${VM_USER} and password ${VM_PASS}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue