xref: /freebsd/sys/contrib/openzfs/.github/workflows/zfs-qemu.yml (revision b64c5a0ace59af62eff52bfe110a521dc73c937b)
1name: zfs-qemu
2
3on:
4  push:
5  pull_request:
6
7concurrency:
8  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
9  cancel-in-progress: true
10
11jobs:
12  test-config:
13    name: Setup
14    runs-on: ubuntu-24.04
15    outputs:
16      test_os: ${{ steps.os.outputs.os }}
17      ci_type: ${{ steps.os.outputs.ci_type }}
18    steps:
19      - uses: actions/checkout@v4
20        with:
21          fetch-depth: 0
22      - name: Generate OS config and CI type
23        id: os
24        run: |
25          FULL_OS='["almalinux8", "almalinux9", "centos-stream9", "debian11", "debian12", "fedora40", "fedora41", "freebsd13-4r", "freebsd14-0r", "freebsd14-1s", "ubuntu20", "ubuntu22", "ubuntu24"]'
26          QUICK_OS='["almalinux8", "almalinux9", "debian12", "fedora41", "freebsd13-3r", "freebsd14-1r", "ubuntu24"]'
27          # determine CI type when running on PR
28          ci_type="full"
29          if ${{ github.event_name == 'pull_request' }}; then
30            head=${{ github.event.pull_request.head.sha }}
31            base=${{ github.event.pull_request.base.sha }}
32            ci_type=$(python3 .github/workflows/scripts/generate-ci-type.py $head $base)
33          fi
34          if [ "$ci_type" == "quick" ]; then
35            os_selection="$QUICK_OS"
36          else
37            os_selection="$FULL_OS"
38          fi
39          os_json=$(echo ${os_selection} | jq -c)
40          echo "os=$os_json" >> $GITHUB_OUTPUT
41          echo "ci_type=$ci_type" >> $GITHUB_OUTPUT
42
43  qemu-vm:
44    name: qemu-x86
45    needs: [ test-config ]
46    strategy:
47      fail-fast: false
48      matrix:
49        # rhl:     almalinux8, almalinux9, centos-stream9, fedora40, fedora41
50        # debian:  debian11, debian12, ubuntu20, ubuntu22, ubuntu24
51        # misc:    archlinux, tumbleweed
52        # FreeBSD Release: freebsd13-3r, freebsd13-4r, freebsd14-0r, freebsd14-1r
53        # FreeBSD Stable:  freebsd13-4s, freebsd14-1s
54        # FreeBSD Current: freebsd15-0c
55        os: ${{ fromJson(needs.test-config.outputs.test_os) }}
56    runs-on: ubuntu-24.04
57    steps:
58    - uses: actions/checkout@v4
59      with:
60        ref: ${{ github.event.pull_request.head.sha }}
61
62    - name: Setup QEMU
63      timeout-minutes: 10
64      run: .github/workflows/scripts/qemu-1-setup.sh
65
66    - name: Start build machine
67      timeout-minutes: 10
68      run: .github/workflows/scripts/qemu-2-start.sh ${{ matrix.os }}
69
70    - name: Install dependencies
71      timeout-minutes: 20
72      run: |
73        echo "Install dependencies in QEMU machine"
74        IP=192.168.122.10
75        while pidof /usr/bin/qemu-system-x86_64 >/dev/null; do
76          ssh 2>/dev/null zfs@$IP "uname -a" && break
77        done
78        scp .github/workflows/scripts/qemu-3-deps.sh zfs@$IP:qemu-3-deps.sh
79        PID=`pidof /usr/bin/qemu-system-x86_64`
80        ssh zfs@$IP '$HOME/qemu-3-deps.sh' ${{ matrix.os }}
81        # wait for poweroff to succeed
82        tail --pid=$PID -f /dev/null
83        sleep 5 # avoid this: "error: Domain is already active"
84        rm -f $HOME/.ssh/known_hosts
85
86    - name: Build modules
87      timeout-minutes: 30
88      run: |
89        echo "Build modules in QEMU machine"
90        sudo virsh start openzfs
91        IP=192.168.122.10
92        while pidof /usr/bin/qemu-system-x86_64 >/dev/null; do
93          ssh 2>/dev/null zfs@$IP "uname -a" && break
94        done
95        rsync -ar $HOME/work/zfs/zfs zfs@$IP:./
96        ssh zfs@$IP '$HOME/zfs/.github/workflows/scripts/qemu-4-build.sh' ${{ matrix.os }}
97
98    - name: Setup testing machines
99      timeout-minutes: 5
100      run: .github/workflows/scripts/qemu-5-setup.sh
101
102    - name: Run tests
103      timeout-minutes: 270
104      run: .github/workflows/scripts/qemu-6-tests.sh
105      env:
106        CI_TYPE: ${{ needs.test-config.outputs.ci_type }}
107
108    - name: Prepare artifacts
109      if: always()
110      timeout-minutes: 10
111      run: .github/workflows/scripts/qemu-7-prepare.sh
112
113    - uses: actions/upload-artifact@v4
114      id: artifact-upload
115      if: always()
116      with:
117        name: Logs-functional-${{ matrix.os }}
118        path: /tmp/qemu-${{ matrix.os }}.tar
119        if-no-files-found: ignore
120
121    - name: Test Summary
122      if: always()
123      run: .github/workflows/scripts/qemu-8-summary.sh '${{ steps.artifact-upload.outputs.artifact-url }}'
124
125  cleanup:
126    if: always()
127    name: Cleanup
128    runs-on: ubuntu-latest
129    needs: [ qemu-vm ]
130
131    steps:
132    - uses: actions/checkout@v4
133      with:
134        ref: ${{ github.event.pull_request.head.sha }}
135    - uses: actions/download-artifact@v4
136    - name: Generating summary
137      run: .github/workflows/scripts/qemu-9-summary-page.sh
138    - name: Generating summary...
139      run: .github/workflows/scripts/qemu-9-summary-page.sh 2
140    - name: Generating summary...
141      run: .github/workflows/scripts/qemu-9-summary-page.sh 3
142    - name: Generating summary...
143      run: .github/workflows/scripts/qemu-9-summary-page.sh 4
144    - name: Generating summary...
145      run: .github/workflows/scripts/qemu-9-summary-page.sh 5
146    - name: Generating summary...
147      run: .github/workflows/scripts/qemu-9-summary-page.sh 6
148    - name: Generating summary...
149      run: .github/workflows/scripts/qemu-9-summary-page.sh 7
150    - name: Generating summary...
151      run: .github/workflows/scripts/qemu-9-summary-page.sh 8
152    - name: Generating summary...
153      run: .github/workflows/scripts/qemu-9-summary-page.sh 9
154    - name: Generating summary...
155      run: .github/workflows/scripts/qemu-9-summary-page.sh 10
156    - name: Generating summary...
157      run: .github/workflows/scripts/qemu-9-summary-page.sh 11
158    - name: Generating summary...
159      run: .github/workflows/scripts/qemu-9-summary-page.sh 12
160    - name: Generating summary...
161      run: .github/workflows/scripts/qemu-9-summary-page.sh 13
162    - name: Generating summary...
163      run: .github/workflows/scripts/qemu-9-summary-page.sh 14
164    - name: Generating summary...
165      run: .github/workflows/scripts/qemu-9-summary-page.sh 15
166    - name: Generating summary...
167      run: .github/workflows/scripts/qemu-9-summary-page.sh 16
168    - name: Generating summary...
169      run: .github/workflows/scripts/qemu-9-summary-page.sh 17
170    - name: Generating summary...
171      run: .github/workflows/scripts/qemu-9-summary-page.sh 18
172    - name: Generating summary...
173      run: .github/workflows/scripts/qemu-9-summary-page.sh 19
174    - uses: actions/upload-artifact@v4
175      with:
176        name: Summary Files
177        path: out-*
178