安利我司在 github action 里跑虚拟机的技术,不需自建 runner,只用免费 runner 比如 ubuntu-22.04 就行。典型用途是 CI 测试软件在不同内核版本下的行为,大鹅都说好。
总之照抄我这里的极简版就可以: https://github.com/jschwinger233/skbdump/blob/main/.github/workflows/test.yaml
1. 创建 vm
- name: Provision LVH VMs
uses: cilium/little-vm-helper@908ab1ff8a596a03cd5221a1f8602dc44c3f906d # v0.0.12
with:
test-name: test
image-version: 6.3-main
host-mount: ./
dns-resolver: '1.1.1.1'
install-dependencies: 'true'
cmd: |
uname -a
2. 跑命令
- name: Test
uses: cilium/little-vm-helper@908ab1ff8a596a03cd5221a1f8602dc44c3f906d # v0.0.12
with:
provision: 'false'
cmd: |
set -ex
iptables -t nat -I POSTROUTING 1 -d 1.1.1.1/32 -p tcp --dport 80 -o enp0s2 -j SNAT --to 10.0.0.6:23333
全程使用 cilium/little-vm-helper 这个 action,有手就行。
总之照抄我这里的极简版就可以: https://github.com/jschwinger233/skbdump/blob/main/.github/workflows/test.yaml
1. 创建 vm
- name: Provision LVH VMs
uses: cilium/little-vm-helper@908ab1ff8a596a03cd5221a1f8602dc44c3f906d # v0.0.12
with:
test-name: test
image-version: 6.3-main
host-mount: ./
dns-resolver: '1.1.1.1'
install-dependencies: 'true'
cmd: |
uname -a
2. 跑命令
- name: Test
uses: cilium/little-vm-helper@908ab1ff8a596a03cd5221a1f8602dc44c3f906d # v0.0.12
with:
provision: 'false'
cmd: |
set -ex
iptables -t nat -I POSTROUTING 1 -d 1.1.1.1/32 -p tcp --dport 80 -o enp0s2 -j SNAT --to 10.0.0.6:23333
全程使用 cilium/little-vm-helper 这个 action,有手就行。