|
| 1 | +# Copyright (c) Microsoft Corporation. |
| 2 | +# Licensed under the MIT License. |
| 3 | + |
| 4 | +name: Tests VMTests suite for OSModifier |
| 5 | + |
| 6 | +permissions: |
| 7 | + contents: read |
| 8 | + |
| 9 | +on: |
| 10 | + workflow_call: |
| 11 | + inputs: |
| 12 | + hostArch: |
| 13 | + required: true |
| 14 | + type: string |
| 15 | + hostDistro: |
| 16 | + required: true |
| 17 | + type: string |
| 18 | + inputImage: |
| 19 | + description: "Path to the base OS image accessible on the runner" |
| 20 | + required: true |
| 21 | + type: string |
| 22 | + |
| 23 | +env: |
| 24 | + EXPECTED_GO_VERSION: "1.24.1" |
| 25 | + IMAGE_CUSTOMIZER_CONTAINER_TAG: "imagecustomizer:dev" |
| 26 | + |
| 27 | +jobs: |
| 28 | + tests-osmodifier: |
| 29 | + name: Tests OSModifier suite |
| 30 | + runs-on: |
| 31 | + - self-hosted |
| 32 | + - 1ES.Pool=${{ inputs.hostDistro == 'azl3' && (inputs.hostArch == 'amd64' && 'maritimus-github-runner-azl3-amd64' || 'maritimus-github-runner-azl3-arm64') || (inputs.hostArch == 'amd64' && 'maritimus-github-runner-ubuntu2404-amd64' || 'maritimus-github-runner-ubuntu2404-arm64') }} |
| 33 | + permissions: |
| 34 | + contents: read |
| 35 | + |
| 36 | + steps: |
| 37 | + - name: Setup Go toolchain |
| 38 | + uses: actions/setup-go@v5 |
| 39 | + with: |
| 40 | + go-version: "${{ env.EXPECTED_GO_VERSION }}" |
| 41 | + |
| 42 | + - name: Install prerequisites (AZL3) |
| 43 | + if: inputs.hostDistro == 'azl3' |
| 44 | + env: |
| 45 | + HOST_ARCH: ${{ inputs.hostArch }} |
| 46 | + run: | |
| 47 | + set -eux |
| 48 | + sudo tdnf install -y \ |
| 49 | + libvirt libvirt-daemon libvirt-daemon-config-network \ |
| 50 | + libvirt-daemon-kvm libvirt-devel qemu-kvm qemu-img python3-libvirt \ |
| 51 | + python3-devel edk2-ovmf azure-cli \ |
| 52 | + rpm coreutils util-linux systemd openssl \ |
| 53 | + sed createrepo_c squashfs-tools cdrkit e2fsprogs dosfstools \ |
| 54 | + xfsprogs zstd veritysetup grub2 binutils lsof git docker |
| 55 | + if [[ "$HOST_ARCH" == "amd64" ]]; then |
| 56 | + sudo tdnf install -y grub2-pc |
| 57 | + fi |
| 58 | + sudo systemctl restart libvirtd |
| 59 | + sudo systemctl status libvirtd |
| 60 | +
|
| 61 | + - name: Install prerequisites (Ubuntu 24.04) |
| 62 | + if: inputs.hostDistro == 'ubuntu2404' |
| 63 | + env: |
| 64 | + HOST_ARCH: ${{ inputs.hostArch }} |
| 65 | + run: | |
| 66 | + set -eux |
| 67 | + sudo apt update -y |
| 68 | + sudo apt -y install \ |
| 69 | + qemu-utils rpm coreutils util-linux mount fdisk udev openssl \ |
| 70 | + sed createrepo-c squashfs-tools genisoimage e2fsprogs dosfstools \ |
| 71 | + xfsprogs zstd cryptsetup-bin grub2-common binutils lsof \ |
| 72 | + python3-venv python3-pip python3-dev \ |
| 73 | + libvirt-dev libvirt-daemon libvirt-daemon-system libvirt-clients \ |
| 74 | + qemu-kvm virt-manager docker.io |
| 75 | + if [[ "$HOST_ARCH" == "arm64" ]]; then |
| 76 | + sudo apt -y install qemu-system-arm qemu-efi-aarch64 ovmf vgabios |
| 77 | + fi |
| 78 | + curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash || true |
| 79 | + sudo systemctl restart libvirtd |
| 80 | +
|
| 81 | + - name: Checkout |
| 82 | + uses: actions/checkout@v4 |
| 83 | + with: |
| 84 | + path: repo |
| 85 | + |
| 86 | + - name: Build osmodifier and imagecustomizer |
| 87 | + run: | |
| 88 | + set -eux |
| 89 | + pushd ./repo/toolkit |
| 90 | + sudo env "PATH=$PATH" make go-osmodifier go-imagecustomizer |
| 91 | + popd |
| 92 | +
|
| 93 | + - name: Build imagecustomizer container (for VM prep) |
| 94 | + run: | |
| 95 | + set -eux |
| 96 | + pushd ./repo/toolkit |
| 97 | + ./tools/imagecustomizer/container/build-container.sh -t "${IMAGE_CUSTOMIZER_CONTAINER_TAG}" |
| 98 | + popd |
| 99 | +
|
| 100 | + - name: Test setup |
| 101 | + run: | |
| 102 | + set -eux |
| 103 | + pushd ./repo/test/vmtests |
| 104 | + # SSH key for VM access |
| 105 | + [[ -f ~/.ssh/id_ed25519 ]] || ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -N "" |
| 106 | + make create-venv |
| 107 | + popd |
| 108 | +
|
| 109 | + - name: Run OSModifier tests |
| 110 | + working-directory: repo/test/vmtests |
| 111 | + run: | |
| 112 | + set -eux |
| 113 | + sudo make test-osmodifier \ |
| 114 | + IMAGE_CUSTOMIZER_CONTAINER_TAG="${IMAGE_CUSTOMIZER_CONTAINER_TAG}" \ |
| 115 | + OSMODIFIER_BIN="../../toolkit/out/tools/osmodifier" \ |
| 116 | + INPUT_IMAGE="${{ inputs.inputImage }}" \ |
| 117 | + SSH_PRIVATE_KEY_FILE="$HOME/.ssh/id_ed25519" \ |
| 118 | + LOGS_DIR="./out" |
| 119 | +
|
| 120 | + - uses: actions/upload-artifact@v4 |
| 121 | + if: ${{ !cancelled() }} |
| 122 | + with: |
| 123 | + name: tests-results-osmodifier-${{ inputs.hostDistro }}-${{ inputs.hostArch }} |
| 124 | + path: repo/test/vmtests/out |
0 commit comments