|
90 | 90 |
|
91 | 91 | - name: test |
92 | 92 | run: make TESTFLAGS="${{ matrix.race }}" test |
| 93 | + |
| 94 | + vm: |
| 95 | + name: "VM" |
| 96 | + strategy: |
| 97 | + fail-fast: false |
| 98 | + matrix: |
| 99 | + template: |
| 100 | + - template://almalinux-8 |
| 101 | + - template://centos-stream-9 |
| 102 | + - template://fedora |
| 103 | + runs-on: ubuntu-24.04 |
| 104 | + steps: |
| 105 | + - uses: actions/checkout@v4 |
| 106 | + |
| 107 | + - name: "Install QEMU" |
| 108 | + run: | |
| 109 | + set -eux |
| 110 | + sudo apt-get update |
| 111 | + sudo apt-get install -y --no-install-recommends ovmf qemu-system-x86 qemu-utils |
| 112 | + sudo modprobe kvm |
| 113 | + # `sudo usermod -aG kvm $(whoami)` does not take an effect on GHA |
| 114 | + sudo chown $(whoami) /dev/kvm |
| 115 | +
|
| 116 | + - name: "Install Lima" |
| 117 | + env: |
| 118 | + GITHUB_TOKEN: ${{ github.token }} # required by `gh attestation verify` |
| 119 | + run: | |
| 120 | + set -eux |
| 121 | + LIMA_VERSION=$(curl -fsSL https://api.github.com/repos/lima-vm/lima/releases/latest | jq -r .tag_name) |
| 122 | + FILE="lima-${LIMA_VERSION:1}-Linux-x86_64.tar.gz" |
| 123 | + curl -fOSL https://github.com/lima-vm/lima/releases/download/${LIMA_VERSION}/${FILE} |
| 124 | + gh attestation verify --owner=lima-vm "${FILE}" |
| 125 | + sudo tar Cxzvf /usr/local "${FILE}" |
| 126 | + rm -f "${FILE}" |
| 127 | + # Export LIMA_VERSION For the GHA cache key |
| 128 | + echo "LIMA_VERSION=${LIMA_VERSION}" >>$GITHUB_ENV |
| 129 | +
|
| 130 | + - name: "Cache ~/.cache/lima" |
| 131 | + uses: actions/cache@v4 |
| 132 | + with: |
| 133 | + path: ~/.cache/lima |
| 134 | + key: lima-${{ env.LIMA_VERSION }}-${{ matrix.template }} |
| 135 | + |
| 136 | + - name: "Start VM" |
| 137 | + # --plain is set to disable file sharing, port forwarding, built-in containerd, etc. |
| 138 | + run: limactl start --plain --name=default --cpus=1 --memory=1 ${{ matrix.template }} |
| 139 | + |
| 140 | + - name: "Initialize VM" |
| 141 | + # plain old rsync and ssh are used for the initialization of the guest, |
| 142 | + # so that people who are not familiar with Lima can understand the initialization steps. |
| 143 | + run: | |
| 144 | + set -eux -o pipefail |
| 145 | + # Initialize SSH |
| 146 | + mkdir -p -m 0700 ~/.ssh |
| 147 | + cat ~/.lima/default/ssh.config >> ~/.ssh/config |
| 148 | + # Sync the current directory to /tmp/selinux in the guest |
| 149 | + rsync -a -e ssh . lima-default:/tmp/selinux |
| 150 | + # Install packages |
| 151 | + ssh lima-default sudo dnf install -y git make golang |
| 152 | +
|
| 153 | + - name: "make test" |
| 154 | + run: ssh lima-default make -C /tmp/selinux test |
0 commit comments