Skip to content
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

ci: move to self-hosted action runner (backport #618) #619

Merged
merged 4 commits into from
Jan 4, 2024
Merged
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
96 changes: 96 additions & 0 deletions .github/workflows/vagrant-install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Vagrant install

on:
pull_request:
types: [opened, reopened, synchronize]

env:
LIBVIRT_DEFAULT_URI: "qemu:///system"

jobs:
main:
name: Build and deploy
runs-on:
- self-hosted
- Linux
- kvm
- vagrant
- equinix
steps:
- uses: actions/checkout@v3
- name: Build Harvester artifacts
run: |
make
- name: Clone and checkout ipxe-examples
id: ipxe
run: |
cd $HOME
if [ ! -d ipxe-examples ]; then
git clone https://github.com/harvester/ipxe-examples.git
fi

cd ipxe-examples
git reset && git checkout .
git clean -fd
git pull
echo "VAGRANT_HOME=$HOME/ipxe-examples/vagrant-pxe-harvester" >> $GITHUB_OUTPUT
- name: Clean up previous vagrant deployment
working-directory: ${{ steps.ipxe.outputs.VAGRANT_HOME }}
run: |
vagrant destroy -f
- name: Remove OVMF.fd line if needed
working-directory: ${{ steps.ipxe.outputs.VAGRANT_HOME }}
run: |
if [ ! -f /usr/share/qemu/OVMF.fd ]; then
echo "Remove libvirt loader: can't find UEFI firmware"
sed 's/libvirt.loader.*/#libvirt.loader = /' Vagrantfile
fi
- name: Generate SSH keys
run: |
ssh-keygen -t rsa -q -N "" -f ./ci/terraform/tmp-ssh-key
- name: Set SSH key in ipxe-examples settings
run: |
export PUB_KEY=$(cat ./ci/terraform/tmp-ssh-key.pub)
yq e -i ".harvester_config.ssh_authorized_keys += [ strenv(PUB_KEY) ]" ${{ steps.ipxe.outputs.VAGRANT_HOME }}/settings.yml
- name: Set artifacts in ipxe-examples settings
run: |
yq e -i ".harvester_iso_url = \"file://${{ github.workspace }}/dist/artifacts/harvester-master-amd64.iso\"" ${{ steps.ipxe.outputs.VAGRANT_HOME }}/settings.yml
yq e -i ".harvester_kernel_url = \"file://${{ github.workspace }}/dist/artifacts/harvester-master-vmlinuz-amd64\"" ${{ steps.ipxe.outputs.VAGRANT_HOME }}/settings.yml
yq e -i ".harvester_ramdisk_url = \"file://${{ github.workspace }}/dist/artifacts/harvester-master-initrd-amd64\"" ${{ steps.ipxe.outputs.VAGRANT_HOME }}/settings.yml
yq e -i ".harvester_rootfs_url = \"file://${{ github.workspace }}/dist/artifacts/harvester-master-rootfs-amd64.squashfs\"" ${{ steps.ipxe.outputs.VAGRANT_HOME }}/settings.yml
- name: Setup cluster
working-directory: ${{ steps.ipxe.outputs.VAGRANT_HOME }}
run: |
./setup_harvester.sh
- name: Enable soft emulation
working-directory: ./ci/terraform
run: |
./enable_soft_emulation.sh ${{ steps.ipxe.outputs.VAGRANT_HOME }}/settings.yml
- name: Clean the previous temp files
working-directory: ./ci/terraform
run: |
./cleanup_test_files.sh
- name: Testing existing files
working-directory: ./ci/terraform
run: |
./check_files.sh ${{ steps.ipxe.outputs.VAGRANT_HOME }}/settings.yml
- name: Testing services status
working-directory: ./ci/terraform
run: |
./check_services_status.sh ${{ steps.ipxe.outputs.VAGRANT_HOME }}/settings.yml
- name: Testing basic operations with terraform
working-directory: ./ci/terraform
run: |
curl https://releases.hashicorp.com/terraform/1.3.7/terraform_1.3.7_linux_amd64.zip -o terraform_bin.zip
unzip -o terraform_bin.zip
./get_kubeconfig.sh ${{ steps.ipxe.outputs.VAGRANT_HOME }}/settings.yml
./terraform init -no-color
./terraform apply -auto-approve -no-color
- name: Test network on the VMs
working-directory: ./ci/terraform
run: |
./test_terraform_vm.sh ${{ steps.ipxe.outputs.VAGRANT_HOME }}/settings.yml
- name: Clean up vagrant cluster
working-directory: ${{ steps.ipxe.outputs.VAGRANT_HOME }}
run: |
vagrant destroy -f
56 changes: 0 additions & 56 deletions ci/README.md

This file was deleted.

189 changes: 0 additions & 189 deletions ci/run_vagrant_install_test.yml

This file was deleted.

23 changes: 23 additions & 0 deletions ci/terraform/check_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash -ex

if [[ $# != 1 ]]
then
echo "We need the settings.yaml from ipxe repo"
exit 1
fi

SETTINGS=$1

EXISTING_FILES="/oem/grubenv /oem/grubcustom"
NODE0_IP=$(yq e ".harvester_network_config.cluster[0].ip" ${SETTINGS})

echo "Check files that should exist."

SSHKEY=./tmp-ssh-key
for filepath in ${EXISTING_FILES}; do
echo "Prepare to check file: ${filepath} ..."
if ! ssh -o "StrictHostKeyChecking no" -i tmp-ssh-key rancher@$NODE0_IP "sudo stat ${filepath}" | grep -q ${filepath}; then
echo "${filepath} should exist, exit!"
exit 1
fi
done
21 changes: 12 additions & 9 deletions package/harvester-os/files/usr/sbin/harv-install
Original file line number Diff line number Diff line change
Expand Up @@ -370,17 +370,20 @@ update_grub_settings()
# stuck on the grub file search for about 30 minutes, this can be
# mitigated by adding the `grubenv` file.
#
# PATCH: add /oem/grubenv if it does not exist
# We need to patch grubenv, grubcustom
oem_dir=${TARGET}/oem
GRUBENV_FILE="${oem_dir}/grubenv"
if ! [ -f ${GRUBENV_FILE} ]; then
grub2-editenv ${GRUBENV_FILE} create
fi

# PATCH: add /oem/grubcustom too to prevent stuck when using BOSS-S1
GRUBCUSTOM_FILE="${oem_dir}/grubcustom"
if ! [ -f ${GRUBCUSTOM_FILE} ]; then
grub2-editenv ${GRUBCUSTOM_FILE} create
# PATCH1: add /oem/grubenv if it does not exist
# grubenv use load_env to load, so we use grub2-editenv
TARGET_FILE="${oem_dir}/grubenv"
if ! [ -f ${TARGET_FILE} ]; then
grub2-editenv ${TARGET_FILE} create
fi
# PATCH2: add /oem/grubcustom if it does not exist
# grubcustom use source to load, so we can use touch directly
TARGET_FILE="${oem_dir}/grubcustom"
if ! [ -f ${TARGET_FILE} ]; then
touch ${TARGET_FILE}
fi

add_debug_grub_entry
Expand Down