mirror of
https://github.com/JasonN3/build-container-installer.git
synced 2025-12-25 10:57:55 +01:00
split tests
This commit is contained in:
parent
3d85c93010
commit
49b197e027
9 changed files with 723 additions and 525 deletions
183
.github/workflows/test_deployment.yml
vendored
Normal file
183
.github/workflows/test_deployment.yml
vendored
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
pr:
|
||||
required: true
|
||||
type: string
|
||||
parent_job_name:
|
||||
required: true
|
||||
type: string
|
||||
iso_name-38:
|
||||
required: true
|
||||
type: string
|
||||
iso_name-39:
|
||||
required: true
|
||||
type: string
|
||||
iso_name-40:
|
||||
required: true
|
||||
type: string
|
||||
|
||||
|
||||
|
||||
jobs:
|
||||
load_vars:
|
||||
uses: ./.github/workflows/build_vars.yml
|
||||
|
||||
test-deployment:
|
||||
name: Test deployment
|
||||
env:
|
||||
JOB_NAME: Test deployment
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- load_vars
|
||||
permissions:
|
||||
contents: read
|
||||
statuses: write
|
||||
continue-on-error: false
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
version:
|
||||
- 38
|
||||
- 39
|
||||
- 40
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Switch branch
|
||||
if: inputs.pr
|
||||
env:
|
||||
GITHUB_USER: ${{ github.actor }}
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y hub
|
||||
hub pr checkout ${{ inputs.pr }}
|
||||
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_ENV
|
||||
|
||||
- name: Get Current Job Log URL
|
||||
if: inputs.pr && always()
|
||||
uses: Tiryoh/gha-jobid-action@v1
|
||||
id: jobs
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
job_name: "${{ inputs.parent_job_name }} / ${{ env.JOB_NAME }}"
|
||||
|
||||
- name: Set status
|
||||
if: inputs.pr && always()
|
||||
uses: myrotvorets/set-commit-status-action@v2.0.1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: Pending
|
||||
context: ${{ env.JOB_NAME }}
|
||||
sha: ${{ env.sha }}
|
||||
targetUrl: ${{ steps.jobs.outputs.html_url }}
|
||||
|
||||
- name: Install test tools
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y make
|
||||
sudo make install-test-deps PACKAGE_MANAGER=apt-get
|
||||
|
||||
- name: Download generated ISO
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: ${{ inputs[format('iso_name-{0}', matrix.version)] }}
|
||||
|
||||
- name: Add Kickstart and Grub options to ISO
|
||||
run: |
|
||||
mv ${{ inputs[format('iso_name-{0}', matrix.version)] }} deploy.iso
|
||||
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: Create VM disk
|
||||
run: |
|
||||
qemu-img create -f qcow2 disk.qcow2 50G
|
||||
|
||||
- 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=on,wait=off & 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
|
||||
VM_IP: "127.0.0.1"
|
||||
VM_PORT: "5555"
|
||||
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=on,wait=off,id=qga0 \
|
||||
-device e1000,netdev=net0 \
|
||||
-netdev user,id=net0,hostfwd=tcp::${VM_PORT}-:22 \
|
||||
-device virtio-serial \
|
||||
-device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0 \
|
||||
-boot c -hda disk.qcow2 -serial telnet:localhost:4321,server=on,wait=off & 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 ! (echo > /dev/tcp/${VM_IP}/${VM_PORT}); do sleep 1; done"
|
||||
|
||||
if ! (echo > /dev/tcp/${VM_IP}/${VM_PORT})
|
||||
then
|
||||
echo "SSH must be installed and enabled inside the container"
|
||||
fi
|
||||
|
||||
echo "VM ready for tests at IP ${VM_IP}:${VM_PORT}"
|
||||
|
||||
make test-vm VM_IP=${VM_IP} VM_PORT=${VM_PORT} VM_USER=${VM_USER} VM_PASS=${VM_PASS} \
|
||||
ARCH=${{ needs.load_vars.outputs.ARCH}} \
|
||||
IMAGE_NAME=${{ needs.load_vars.outputs.IMAGE_NAME}} \
|
||||
IMAGE_REPO=${{ needs.load_vars.outputs.IMAGE_REPO}} \
|
||||
IMAGE_TAG=${{ matrix.version }} \
|
||||
VERSION=${{ matrix.version }} \
|
||||
VARIANT=${{ needs.load_vars.outputs.VARIANT }} \
|
||||
FLATPAK_REMOTE_REFS_DIR=${{ needs.load_vars.outputs.FLATPAK_REMOTE_REFS_DIR }} \
|
||||
SECURE_BOOT_KEY_URL=${{ needs.load_vars.outputs.SECURE_BOOT_KEY_URL }} \
|
||||
ENROLLMENT_PASSWORD=${{ needs.load_vars.outputs.ENROLLMENT_PASSWORD }}
|
||||
kill $QEMU_PID
|
||||
|
||||
- name: Set status
|
||||
if: inputs.pr && always()
|
||||
uses: myrotvorets/set-commit-status-action@v2.0.1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: ${{ job.status }}
|
||||
context: ${{ env.JOB_NAME }}
|
||||
sha: ${{ env.sha }}
|
||||
targetUrl: ${{ steps.jobs.outputs.html_url }}
|
||||
Loading…
Add table
Add a link
Reference in a new issue