-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (112 loc) · 4.36 KB
/
rust.yml
File metadata and controls
131 lines (112 loc) · 4.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Rust build and test
on:
push:
branches: [ '**' ]
pull_request:
branches: [ "main" ]
workflow_dispatch: # Allows manual runs
env:
CARGO_TERM_COLOR: always
sector_size: 4096
zone_size: 128
zone_capacity: 0
disk_size: 32
max_open: 14
max_active: 14
zasl: 5
znsimg: /var/lib/qemu/images/zns.raw
ssdimg: /var/lib/qemu/images/ssd.raw
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup ssh
run: |
mkdir ~/.ssh
ssh-keyscan -H 127.0.0.1 >> ~/.ssh/known_hosts
- name: Install packages
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: qemu-system-x86 qemu-utils cloud-utils wget sshpass
version: 1.0
execute_install_scripts: true
- name: Cache Ubuntu Cloud Image
id: cache-ubuntu-restore
uses: actions/cache/restore@v4
with:
path: |
/tmp/ubuntu.qcow2
key: ubuntu-cloudimg-noble-${{ hashFiles('.github/workflows/rust.yml') }}
- name: Download Ubuntu Cloud Image
if: steps.cache-ubuntu.outputs.cache-hit != 'true'
run: |
wget -O /tmp/ubuntu.qcow2 https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img -o /dev/null
qemu-img resize /tmp/ubuntu.qcow2 12G
- name: Cache Ubuntu save Cloud Image
id: cache-ubuntu
uses: actions/cache/save@v4
with:
path: |
/tmp/ubuntu.qcow2
key: ${{ steps.cache-ubuntu-restore.outputs.cache-primary-key }}
- name: Create Cloud-Init Disk
run: |
cat > user-data <<EOF
#cloud-config
password: ubuntu
chpasswd: { expire: False }
ssh_pwauth: True
EOF
cloud-localds /tmp/cloud-init.iso user-data
- name: Make raw disk images
run: |
sudo mkdir -p "$(dirname ${znsimg})"
sudo touch ${znsimg}
sudo truncate -s "${disk_size}"G ${znsimg}
sudo mkdir -p "$(dirname ${ssdimg})"
sudo touch ${ssdimg}
sudo truncate -s "${disk_size}"G ${ssdimg}
- name: Run QEMU VM with Ubuntu
run: |
sudo qemu-system-x86_64 \
-enable-kvm \
-m 12G \
-smp $(nproc) \
-cpu host \
-drive file=/tmp/ubuntu.qcow2,format=qcow2,if=virtio \
-drive file=/tmp/cloud-init.iso,format=raw,if=virtio \
-net user,hostfwd=tcp::2222-:22 \
-net nic \
-device nvme,id=nvme0,serial=deadbeef,zoned.zasl="${zasl}" \
-drive file="${znsimg}",id=nvmezns0,format=raw,if=none \
-device nvme-ns,drive=nvmezns0,bus=nvme0,nsid=1,logical_block_size="${sector_size}",physical_block_size="${sector_size}",zoned=true,zoned.zone_size="${zone_size}"M,zoned.zone_capacity="${zone_capacity}"M,zoned.max_open="${max_open}",zoned.max_active="${max_active}",uuid=5e40ec5f-eeb6-4317-bc5e-c919796a5f79 \
-device nvme,id=nvme1,serial=deadbaaf \
-drive file="${ssdimg}",id=nvmessd1,format=raw,if=none \
-device nvme-ns,drive=nvmessd1,bus=nvme1,nsid=1,logical_block_size="${sector_size}",physical_block_size="${sector_size}",zoned=false,uuid=5e40ec5f-eeb6-4317-bc5e-c919796a5f7a \
-nographic &
# Wait for SSH
for i in {1..60}; do
if sshpass -p "ubuntu" ssh -o StrictHostKeyChecking=no -o ConnectTimeout=2 -p 2222 ubuntu@127.0.0.1 true; then
echo "SSH is up"; break
fi
sleep 5
done
- name: Copy files and install dependencies
run: |
sshpass -p "ubuntu" scp -o StrictHostKeyChecking=no -P 2222 -r $GITHUB_WORKSPACE ubuntu@127.0.0.1:/home/ubuntu/OxCache
sshpass -p "ubuntu" ssh -o StrictHostKeyChecking=no -p 2222 ubuntu@127.0.0.1 << 'EOF'
sudo apt update && sudo apt install -y build-essential libclang-dev meson ninja-build
curl https://sh.rustup.rs -sSf | sh -s -- -y
. "$HOME/.cargo/env"
cd OxCache && RUNNING_IN_GITHUB_ACTIONS=yes cargo build
EOF
- name: Test
run: sshpass -p "ubuntu" ssh -o StrictHostKeyChecking=no -p 2222 ubuntu@127.0.0.1 \
'cd OxCache && sudo env "HOME=/home/ubuntu" bash -c ". /home/ubuntu/.cargo/env && RUNNING_IN_GITHUB_ACTIONS=yes cargo test --lib"'
# To SSH into actions
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3