summaryrefslogtreecommitdiffstats
path: root/.github/workflows/mkosi.yml
blob: 1e0b622f606f648c89ab3817e36115ceb759d2a6 (plain)
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
---
# vi: ts=2 sw=2 et:
# SPDX-License-Identifier: LGPL-2.1-or-later
# Simple boot tests that build and boot the mkosi images generated by the mkosi config files in mkosi.conf.d/.
name: mkosi

on:
  push:
    branches:
      - main
      - v[0-9]+-stable
    paths:
      - '**'
      - '!README*'
      - '!LICENSE*'
      - '!LICENSES/**'
      - '!TODO'
      - '!docs/**'
      - '!man/**'
      - '!catalog/**'
      - '!shell-completion/**'
      - '!po/**'
      - '!.**'
      - '.github/**'

  pull_request:
    branches:
      - main
      - v[0-9]+-stable
    paths:
      - '**'
      - '!README*'
      - '!LICENSE*'
      - '!LICENSES/**'
      - '!TODO'
      - '!docs/**'
      - '!man/**'
      - '!catalog/**'
      - '!shell-completion/**'
      - '!po/**'
      - '!.**'
      - '.github/**'

permissions:
  contents: read

jobs:
  ci:
    runs-on: ubuntu-22.04
    concurrency:
      group: ${{ github.workflow }}-${{ matrix.distro }}-${{ matrix.release }}-${{ github.ref }}
      cancel-in-progress: true
    strategy:
      fail-fast: false
      matrix:
        include:
          - distro: arch
            release: rolling
          - distro: debian
            release: testing
          - distro: ubuntu
            release: noble
          - distro: fedora
            release: "40"
          - distro: fedora
            release: rawhide
          - distro: opensuse
            release: tumbleweed
          - distro: centos
            release: "9"

    steps:
    - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
    - uses: systemd/mkosi@22d212dcb229b553572578ef16c809f9a9961ee8

    # Freeing up disk space with rm -rf can take multiple minutes. Since we don't need the extra free space
    # immediately, we remove the files in the background. However, we first move them to a different location
    # so that nothing tries to use anything in these directories anymore while we're busy deleting them.
    - name: Free disk space
      run: |
        sudo mv /usr/local /usr/local.trash
        sudo mv /opt/hostedtoolcache /opt/hostedtoolcache.trash
        sudo systemd-run rm -rf /usr/local.trash /opt/hostedtoolcache.trash

    - name: Btrfs
      run: |
        truncate --size=100G btrfs.raw
        mkfs.btrfs btrfs.raw
        sudo mkdir /mnt/mkosi
        LOOP="$(sudo losetup --find --show --direct-io=on btrfs.raw)"
        sudo mount "$LOOP" /mnt/mkosi --options compress=zstd:1,user_subvol_rm_allowed,noatime,discard=async,space_cache=v2
        sudo chown "$(id -u):$(id -g)" /mnt/mkosi
        mkdir /mnt/mkosi/tmp
        echo "TMPDIR=/mnt/mkosi/tmp" >>"$GITHUB_ENV"
        ln -s /mnt/mkosi/build build

    - name: Configure
      run: |
        tee mkosi.local.conf <<EOF
        [Distribution]
        Distribution=${{ matrix.distro }}
        Release=${{ matrix.release }}

        [Output]
        # Build a disk image in CI as this logic is much more prone to breakage.
        Format=disk
        UseSubvolumes=yes

        WorkspaceDirectory=$TMPDIR
        PackageCacheDirectory=$TMPDIR/cache

        [Content]
        Environment=
                # mkfs.erofs is extremely noisy when not connected to a tty.
                SYSTEMD_REPART_MKFS_OPTIONS_EROFS="--quiet"
                # Build debuginfo packages since we'll be publishing the packages as artifacts.
                WITH_DEBUG=1
                # Enabling optimizations significantly speeds up integration tests.
                OPTIMIZATION=g

        [Host]
        ToolsTree=default
        ToolsTreeDistribution=fedora
        # TODO: Drop once https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2038777 is fixed in Github Actions
        QemuFirmware=uefi
        # We build with debuginfo so there's no point in mounting the sources into the machine.
        RuntimeBuildSources=no
        EOF

        # These should override the options from mkosi.conf so we put them in a dropin that's ordered later
        # instead.
        tee mkosi.conf.d/99-ci.conf <<EOF
        [Host]
        KernelCommandLineExtra=
                # Root device can take a long time to appear, so let's bump the timeout.
                systemd.default_device_timeout_sec=180
        EOF

    - name: Generate secure boot key
      run: mkosi --debug genkey

    - name: Show image summary
      run: mkosi summary

    - name: Install build dependencies
      run: |
        sudo apt-get install \
            meson \
            gperf \
            libfdisk-dev \
            libtss2-dev \
            libblkid-dev \
            libmicrohttpd-dev \
            libcap-dev \
            libcurl4-openssl-dev \
            libcryptsetup-dev \
            erofs-utils \
            dosfstools \
            python3-pefile \
            sbsigntool \
            mtools

    - name: Configure meson
      run: |
        meson setup build \
            --buildtype=debugoptimized \
            -Dintegration-tests=true \
            -Dremote=enabled \
            -Dopenssl=enabled \
            -Dblkid=enabled \
            -Dtpm2=enabled \
            -Dlibcryptsetup=enabled \
            -Dlibcurl=enabled \
            -Drepart=disabled \
            -Dfirstboot=true \
            -Dsysusers=true \
            -Dtmpfiles=true \
            -Dhwdb=true \
            -Dvmspawn=enabled

    - name: Build image
      run: meson compile -C build mkosi

    - name: Run integration tests
      run: meson test -C build --no-rebuild --suite integration-tests --print-errorlogs --no-stdsplit --num-processes "$(($(nproc) - 1))"

    - name: Archive failed test journals
      uses: actions/upload-artifact@v4
      if: failure() && (github.repository == 'systemd/systemd' || github.repository == 'systemd/systemd-stable')
      with:
        name: ci-mkosi-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.distro }}-${{ matrix.release }}-failed-test-journals
        path: |
          build/test/journal/*.journal
          build/meson-logs/*
        retention-days: 7

    - name: Archive packages
      uses: actions/upload-artifact@v4
      if: (success() || failure()) && (github.repository == 'systemd/systemd' || github.repository == 'systemd/systemd-stable')
      with:
        name: ci-mkosi-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.distro }}-${{ matrix.release }}-packages
        path: |
          build/mkosi.output/*.rpm
          build/mkosi.output/*.deb
          build/mkosi.output/*.ddeb
          build/mkosi.output/*.pkg.tar
        retention-days: 4