summaryrefslogtreecommitdiffstats
path: root/.github/workflows/ci.yml
blob: cc961bcb3b5d2461f5b0b47b21b8c3b609d47f61 (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
name: CI
on: [push]
env:
  DEF_CFLAGS: -O2 -g -Wall

jobs:
  gcc-build-and-test:
    name: Build and test with gcc
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - run: ./configure CC=gcc CFLAGS="$DEF_CFLAGS"
    - run: make -j8 check V=1 CFLAGS_WARN="-Werror"
    - run: make -j8 install V=1 DESTDIR=$PWD/installdir
    - run: make -j8 uninstall V=1 DESTDIR=$PWD/installdir
    - if: failure()
      uses: actions/upload-artifact@v4
      with:
        name: gcc-test-fail-logs
        path: tests/*.failed

  clang-build-and-test:
    name: Build and test with clang
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - name: Install dependencies
      run: |
        sudo apt-get update
        sudo apt-get install -y clang
    - run: ./configure CC=clang CFLAGS="$DEF_CFLAGS"
    - run: make -j8 check V=1 CFLAGS_WARN="-Werror"
    - run: make -j8 install V=1 DESTDIR=$PWD/installdir
    - run: make -j8 uninstall V=1 DESTDIR=$PWD/installdir
    - uses: actions/upload-artifact@v4
      with:
        name: ubuntu-config.h
        path: lib/config.h
    - if: failure()
      uses: actions/upload-artifact@v4
      with:
        name: clang-test-fail-logs
        path: tests/*.failed

  i386-build-and-test:
    name: Build and test with gcc -m32
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - name: Install dependencies
      run: |
        sudo apt-get update
        sudo apt-get install -y gcc-multilib
    - run: ./configure CC=gcc CFLAGS="$DEF_CFLAGS -m32" LDFLAGS="-m32"
    - run: make -j8 check V=1 CFLAGS_WARN="-Werror"
    - run: make -j8 install V=1 DESTDIR=$PWD/installdir
    - run: make -j8 uninstall V=1 DESTDIR=$PWD/installdir
    - if: failure()
      uses: actions/upload-artifact@v4
      with:
        name: i386-test-fail-logs
        path: tests/*.failed

  asan-build-and-test:
    name: Build and test with ASAN enabled
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - name: Install dependencies
      run: |
        sudo apt-get update
        sudo apt-get install -y clang
    - run: echo "ASAN_CFLAGS=$DEF_CFLAGS -fsanitize=address -fno-sanitize-recover=address" >> $GITHUB_ENV
    - run: ./configure CC=clang CFLAGS="$ASAN_CFLAGS" LDFLAGS="$ASAN_CFLAGS"
    - run: make -j8 check V=1 CFLAGS_WARN="-Werror"
    - if: failure()
      uses: actions/upload-artifact@v4
      with:
        name: asan-test-fail-logs
        path: tests/*.failed

  ubsan-build-and-test:
    name: Build and test with UBSAN enabled
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - name: Install dependencies
      run: |
        sudo apt-get update
        sudo apt-get install -y clang
    - run: echo "UBSAN_CFLAGS=$DEF_CFLAGS -fsanitize=undefined -fno-sanitize-recover=undefined" >> $GITHUB_ENV
    - run: ./configure CC=clang CFLAGS="$UBSAN_CFLAGS" LDFLAGS="$UBSAN_CFLAGS"
    - run: make -j8 check V=1 CFLAGS_WARN="-Werror"
    - if: failure()
      uses: actions/upload-artifact@v4
      with:
        name: ubsan-test-fail-logs
        path: tests/*.failed

  macos-build-and-test:
    name: Build and test on macOS
    runs-on: macos-latest
    steps:
    - uses: actions/checkout@v4
    - run: ./configure CFLAGS="$DEF_CFLAGS"
      # -Wno-error=deprecated-declarations is needed to suppress known warnings
      # due to e2fsprogs' use of sbrk(0) and daemon().
    - run: make -j8 check V=1 CFLAGS_WARN="-Werror -Wno-error=deprecated-declarations"
    - if: failure()
      uses: actions/upload-artifact@v4
      with:
        name: macos-test-fail-logs
        path: tests/*.failed
    - run: make -j8 install DESTDIR=$PWD/installdir
    - run: make -j8 uninstall DESTDIR=$PWD/installdir
    - uses: actions/upload-artifact@v4
      with:
        name: macOS-config.h
        path: lib/config.h

  windows-msys2-build:
    name: Build mke2fs on Windows with ${{matrix.sys}}
    runs-on: windows-latest
    strategy:
      matrix:
        include:
        - { sys: mingw32, env: i686 }
        - { sys: mingw64, env: x86_64 }
    defaults:
      run:
        shell: msys2 {0}
    steps:
    - uses: actions/checkout@v4
    - uses: msys2/setup-msys2@v2
      with:
        msystem: ${{matrix.sys}}
        update: true
        install: >
          make
          mingw-w64-${{matrix.env}}-cc
    # For now the only parts that actually build for Windows are mke2fs and its
    # dependencies: all libraries except libss.  The build system doesn't want
    # to build just those parts, though, so do it one step at a time...
    - run: ./configure CFLAGS="$DEF_CFLAGS"
    - run: make -j8 subs V=1 CFLAGS_WARN="-Werror"
    - run: make -j8 -C lib/et/ all V=1 CFLAGS_WARN="-Werror"
    - run: make -j8 -C lib/uuid/ all V=1 CFLAGS_WARN="-Werror"
    - run: make -j8 -C lib/blkid/ all V=1 CFLAGS_WARN="-Werror"
    - run: make -j8 -C lib/ext2fs/ all V=1 CFLAGS_WARN="-Werror"
    - run: make -j8 -C lib/support/ all V=1 CFLAGS_WARN="-Werror"
    - run: make -j8 -C lib/e2p/ all V=1 CFLAGS_WARN="-Werror"
    - run: make -j8 -C misc/ mke2fs V=1 CFLAGS_WARN="-Werror"
    - run: misc/mke2fs.exe -T ext4 image.ext4 128M
    - uses: actions/upload-artifact@v4
      with:
        name: windows-${{matrix.env}}-config.h
        path: lib/config.h

  # Jobs that cross-compile e2fsprogs for Android using the Android NDK.  Note
  # that these use the autotools-based build system, which makes them a bit
  # different from the actual Android builds from the Android source tree.
  cross-compile-for-android:
    name: Cross-compile for Android (${{matrix.arch}})
    strategy:
      matrix:
        include:
        - { arch: aarch64, target: aarch64-linux-android }
        - { arch: armv7a, target: armv7a-linux-androideabi }
        - { arch: i686, target: i686-linux-android }
        - { arch: x86_64, target: x86_64-linux-android }
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    # See https://developer.android.com/ndk/guides/other_build_systems#autoconf
    - name: configure
      run: |
        TOOLCHAIN=$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64
        API_LEVEL=29 # Android 10
        export AR=$TOOLCHAIN/bin/llvm-ar
        export CC=$TOOLCHAIN/bin/${{matrix.target}}${API_LEVEL}-clang
        export AS=$CC
        export LD=$TOOLCHAIN/bin/ld
        export RANLIB=$TOOLCHAIN/bin/llvm-ranlib
        export STRIP=$TOOLCHAIN/bin/llvm-strip
        ./configure --host=${{matrix.target}} CFLAGS="$DEF_CFLAGS"
    - run: make -j8 V=1 CFLAGS_WARN="-Werror"
    - uses: actions/upload-artifact@v4
      with:
        name: android-${{matrix.arch}}-config.h
        path: lib/config.h