xref: /freebsd/sys/contrib/openzfs/.github/workflows/zfs-qemu.yml (revision 87b759f0fa1f7554d50ce640c40138512bbded44)
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", "fedora39", "fedora40", "freebsd13", "freebsd13r", "freebsd14", "freebsd14r", "ubuntu20", "ubuntu22", "ubuntu24"]'
26          QUICK_OS='["almalinux8", "almalinux9", "debian12", "fedora40", "freebsd13", "freebsd14", "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        # all:
50        # os:  [almalinux8, almalinux9, archlinux, centos-stream9, fedora39, fedora40, debian11, debian12, freebsd13, freebsd13r, freebsd14, freebsd14r, freebsd15, ubuntu20, ubuntu22, ubuntu24]
51        # openzfs:
52        # os: [almalinux8, almalinux9, centos-stream9, debian11, debian12, fedora39, fedora40, freebsd13, freebsd13r, freebsd14, freebsd14r, ubuntu20, ubuntu22, ubuntu24]
53        os: ${{ fromJson(needs.test-config.outputs.test_os) }}
54    runs-on: ubuntu-24.04
55    steps:
56    - uses: actions/checkout@v4
57      with:
58        ref: ${{ github.event.pull_request.head.sha }}
59
60    - name: Setup QEMU
61      timeout-minutes: 10
62      run: .github/workflows/scripts/qemu-1-setup.sh
63
64    - name: Start build machine
65      timeout-minutes: 10
66      run: .github/workflows/scripts/qemu-2-start.sh ${{ matrix.os }}
67
68    - name: Install dependencies
69      timeout-minutes: 20
70      run: |
71        echo "Install dependencies in QEMU machine"
72        IP=192.168.122.10
73        while pidof /usr/bin/qemu-system-x86_64 >/dev/null; do
74          ssh 2>/dev/null zfs@$IP "uname -a" && break
75        done
76        scp .github/workflows/scripts/qemu-3-deps.sh zfs@$IP:qemu-3-deps.sh
77        PID=`pidof /usr/bin/qemu-system-x86_64`
78        ssh zfs@$IP '$HOME/qemu-3-deps.sh' ${{ matrix.os }}
79        # wait for poweroff to succeed
80        tail --pid=$PID -f /dev/null
81        sleep 5 # avoid this: "error: Domain is already active"
82        rm -f $HOME/.ssh/known_hosts
83
84    - name: Build modules
85      timeout-minutes: 30
86      run: |
87        echo "Build modules in QEMU machine"
88        sudo virsh start openzfs
89        IP=192.168.122.10
90        while pidof /usr/bin/qemu-system-x86_64 >/dev/null; do
91          ssh 2>/dev/null zfs@$IP "uname -a" && break
92        done
93        rsync -ar $HOME/work/zfs/zfs zfs@$IP:./
94        ssh zfs@$IP '$HOME/zfs/.github/workflows/scripts/qemu-4-build.sh' ${{ matrix.os }}
95
96    - name: Setup testing machines
97      timeout-minutes: 5
98      run: .github/workflows/scripts/qemu-5-setup.sh
99
100    - name: Run tests
101      timeout-minutes: 270
102      run: .github/workflows/scripts/qemu-6-tests.sh
103      env:
104        CI_TYPE: ${{ needs.test-config.outputs.ci_type }}
105
106    - name: Prepare artifacts
107      if: always()
108      timeout-minutes: 10
109      run: .github/workflows/scripts/qemu-7-prepare.sh
110
111    - uses: actions/upload-artifact@v4
112      id: artifact-upload
113      if: always()
114      with:
115        name: Logs-functional-${{ matrix.os }}
116        path: /tmp/qemu-${{ matrix.os }}.tar
117        if-no-files-found: ignore
118
119    - name: Test Summary
120      if: always()
121      run: .github/workflows/scripts/qemu-8-summary.sh '${{ steps.artifact-upload.outputs.artifact-url }}'
122
123  cleanup:
124    if: always()
125    name: Cleanup
126    runs-on: ubuntu-latest
127    needs: [ qemu-vm ]
128
129    steps:
130    - uses: actions/checkout@v4
131      with:
132        ref: ${{ github.event.pull_request.head.sha }}
133    - uses: actions/download-artifact@v4
134    - name: Generating summary
135      run: .github/workflows/scripts/qemu-9-summary-page.sh
136    - name: Generating summary...
137      run: .github/workflows/scripts/qemu-9-summary-page.sh 2
138    - name: Generating summary...
139      run: .github/workflows/scripts/qemu-9-summary-page.sh 3
140    - name: Generating summary...
141      run: .github/workflows/scripts/qemu-9-summary-page.sh 4
142    - name: Generating summary...
143      run: .github/workflows/scripts/qemu-9-summary-page.sh 5
144    - name: Generating summary...
145      run: .github/workflows/scripts/qemu-9-summary-page.sh 6
146    - name: Generating summary...
147      run: .github/workflows/scripts/qemu-9-summary-page.sh 7
148    - name: Generating summary...
149      run: .github/workflows/scripts/qemu-9-summary-page.sh 8
150    - name: Generating summary...
151      run: .github/workflows/scripts/qemu-9-summary-page.sh 9
152    - name: Generating summary...
153      run: .github/workflows/scripts/qemu-9-summary-page.sh 10
154    - name: Generating summary...
155      run: .github/workflows/scripts/qemu-9-summary-page.sh 11
156    - name: Generating summary...
157      run: .github/workflows/scripts/qemu-9-summary-page.sh 12
158    - name: Generating summary...
159      run: .github/workflows/scripts/qemu-9-summary-page.sh 13
160    - name: Generating summary...
161      run: .github/workflows/scripts/qemu-9-summary-page.sh 14
162    - name: Generating summary...
163      run: .github/workflows/scripts/qemu-9-summary-page.sh 15
164    - name: Generating summary...
165      run: .github/workflows/scripts/qemu-9-summary-page.sh 16
166    - name: Generating summary...
167      run: .github/workflows/scripts/qemu-9-summary-page.sh 17
168    - name: Generating summary...
169      run: .github/workflows/scripts/qemu-9-summary-page.sh 18
170    - name: Generating summary...
171      run: .github/workflows/scripts/qemu-9-summary-page.sh 19
172    - uses: actions/upload-artifact@v4
173      with:
174        name: Summary Files
175        path: out-*
176