xref: /libuv/.github/workflows/CI-unix.yml (revision a94f2ad2)
1name: CI-unix
2
3on:
4  pull_request:
5    paths:
6      - '**'
7      - '!docs/**'
8      - '!src/win/**'
9      - '!.**'
10      - '.github/workflows/CI-unix.yml'
11  push:
12    branches:
13      - v[0-9].*
14      - master
15
16jobs:
17  build-linux:
18    runs-on: ubuntu-latest
19    steps:
20      - uses: actions/checkout@v4
21      - name: configure
22        run: |
23          ./autogen.sh
24          mkdir build
25          (cd build && ../configure)
26      - name: distcheck
27        run: |
28          make -C build distcheck
29
30  build-android:
31    runs-on: ubuntu-latest
32    env:
33      ANDROID_AVD_HOME: /root/.android/avd
34    steps:
35      - uses: actions/checkout@v4
36      - name: Envinfo
37        run: npx envinfo
38      - name: Enable KVM
39        run: |
40          echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
41          sudo udevadm control --reload-rules
42          sudo udevadm trigger --name-match=kvm
43      - name: Build and Test
44        uses: reactivecircus/android-emulator-runner@v2
45        with:
46          api-level: 30
47          arch: x86_64
48          target: google_apis
49          ram-size: 2048M
50          emulator-options: -no-audio -no-window -gpu off -no-boot-anim -netdelay none -netspeed full -writable-system -no-snapshot-save -no-snapshot-load -no-snapshot
51          disable-animations: true
52          script: |
53            echo "::group::Configure"
54            cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DANDROID_ABI="x86_64" -DANDROID_PLATFORM=android-30
55            echo "::endgroup::"
56
57            echo "::group::Build"
58            cmake --build build
59
60            ## Correct some ld bugs that cause problems with libuv tests
61            wget "https://github.com/termux/termux-elf-cleaner/releases/download/v2.2.1/termux-elf-cleaner" -P build
62            chmod a+x build/termux-elf-cleaner
63            build/termux-elf-cleaner --api-level 30 ./build/uv_run_tests
64            build/termux-elf-cleaner --api-level 30 ./build/uv_run_tests_a
65
66            adb shell "su 0 setenforce 0" # to allow some syscalls like link, chmod, etc.
67
68            ## Push the build and test fixtures to the device
69            adb push build /data/local/tmp
70            adb shell mkdir /data/local/tmp/build/test
71            adb push test/fixtures /data/local/tmp/build/test
72            echo "::endgroup::"
73
74            ## Run the tests
75            file build/uv_run_tests_a
76            adb shell "cd /data/local/tmp/build && env UV_TEST_TIMEOUT_MULTIPLIER=5 ./uv_run_tests_a"
77
78  build-macos:
79    runs-on: ${{ matrix.os }}
80    strategy:
81      fail-fast: false
82      matrix:
83        os: [macos-13, macos-14]
84    steps:
85      - uses: actions/checkout@v4
86      - name: Envinfo
87        run: npx envinfo
88      - name: Disable Firewall
89        run: |
90          /usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate
91          sudo defaults write /Library/Preferences/com.apple.alf globalstate -int 0
92          /usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate
93      - name: Setup
94        run: |
95          brew install ninja automake libtool
96      - name: Configure
97        run: |
98          mkdir build
99          cd build
100          cmake .. -DBUILD_TESTING=ON -G Ninja
101      - name: Build
102        run: |
103          cmake --build build
104          ls -lh
105      - name: platform_output
106        run: |
107          ./build/uv_run_tests platform_output
108      - name: platform_output_a
109        run: |
110          ./build/uv_run_tests_a platform_output
111      - name: Test
112        run: |
113          cd build && ctest -V
114      - name: Autotools configure
115        if: always()
116        run: |
117          ./autogen.sh
118          mkdir build-auto
119          (cd build-auto && ../configure)
120          make -C build-auto -j4
121
122  build-ios:
123    runs-on: ${{ matrix.os }}
124    strategy:
125      fail-fast: false
126      matrix:
127        os: [macos-13, macos-14]
128    steps:
129      - uses: actions/checkout@v4
130      - name: Configure
131        run: |
132          mkdir build-ios
133          cd build-ios
134          cmake .. -GXcode -DCMAKE_SYSTEM_NAME:STRING=iOS -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED:BOOL=NO -DCMAKE_CONFIGURATION_TYPES:STRING=Release
135      - name: Build
136        run: |
137          cmake --build build-ios
138          ls -lh build-ios
139
140  build-cross-qemu:
141    runs-on: ubuntu-24.04
142    name: build-cross-qemu-${{ matrix.config.target }}
143
144    strategy:
145      fail-fast: false
146      matrix:
147        config:
148          - {target: arm,                 toolchain: gcc-arm-linux-gnueabi,       cc: arm-linux-gnueabi-gcc,      qemu: qemu-arm      }
149          - {target: armhf,               toolchain: gcc-arm-linux-gnueabihf,     cc: arm-linux-gnueabihf-gcc,    qemu: qemu-arm      }
150          - {target: aarch64,             toolchain: gcc-aarch64-linux-gnu,       cc: aarch64-linux-gnu-gcc,      qemu: qemu-aarch64  }
151          - {target: riscv64,             toolchain: gcc-riscv64-linux-gnu,       cc: riscv64-linux-gnu-gcc,      qemu: qemu-riscv64  }
152          - {target: ppc,                 toolchain: gcc-powerpc-linux-gnu,       cc: powerpc-linux-gnu-gcc,      qemu: qemu-ppc      }
153          - {target: ppc64,               toolchain: gcc-powerpc64-linux-gnu,     cc: powerpc64-linux-gnu-gcc,    qemu: qemu-ppc64    }
154          - {target: ppc64le,             toolchain: gcc-powerpc64le-linux-gnu,   cc: powerpc64le-linux-gnu-gcc,  qemu: qemu-ppc64le  }
155          - {target: s390x,               toolchain: gcc-s390x-linux-gnu,         cc: s390x-linux-gnu-gcc,        qemu: qemu-s390x    }
156          - {target: mips,                toolchain: gcc-mips-linux-gnu,          cc: mips-linux-gnu-gcc,         qemu: qemu-mips     }
157          - {target: mips64,              toolchain: gcc-mips64-linux-gnuabi64,   cc: mips64-linux-gnuabi64-gcc,  qemu: qemu-mips64   }
158          - {target: mipsel,              toolchain: gcc-mipsel-linux-gnu,        cc: mipsel-linux-gnu-gcc,       qemu: qemu-mipsel   }
159          - {target: mips64el,            toolchain: gcc-mips64el-linux-gnuabi64, cc: mips64el-linux-gnuabi64-gcc,qemu: qemu-mips64el }
160          - {target: arm (u64 slots),     toolchain: gcc-arm-linux-gnueabi,       cc: arm-linux-gnueabi-gcc,      qemu: qemu-arm      }
161          - {target: aarch64 (u64 slots), toolchain: gcc-aarch64-linux-gnu,       cc: aarch64-linux-gnu-gcc,      qemu: qemu-aarch64  }
162          - {target: ppc (u64 slots),     toolchain: gcc-powerpc-linux-gnu,       cc: powerpc-linux-gnu-gcc,      qemu: qemu-ppc      }
163          - {target: ppc64 (u64 slots),   toolchain: gcc-powerpc64-linux-gnu,     cc: powerpc64-linux-gnu-gcc,    qemu: qemu-ppc64    }
164
165    steps:
166      - uses: actions/checkout@v4
167      - name: Install qemu and ${{ matrix.config.toolchain }}
168        run: |
169          sudo apt update
170          sudo apt install qemu-user qemu-user-binfmt ${{ matrix.config.toolchain }} -y
171      - name: Configure with ${{ matrix.config.cc }}
172        run: |
173          mkdir build
174          cd build
175          cmake .. -DBUILD_TESTING=ON -DQEMU=ON -DCMAKE_C_COMPILER=${{ matrix.config.cc }}
176      - name: Build
177        run: |
178          cmake --build build
179          ls -lh build
180      - name: Test
181        run: |
182          ${{ matrix.config.qemu }} build/uv_run_tests_a
183