xref: /curl/.github/workflows/macos.yml (revision 66bf995d)
1# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
2#
3# SPDX-License-Identifier: curl
4
5name: macOS
6
7on:
8  push:
9    branches:
10      - master
11      - '*/ci'
12    paths-ignore:
13      - '**/*.md'
14      - '.azure-pipelines.yml'
15      - '.circleci/**'
16      - '.cirrus.yml'
17      - 'appveyor.*'
18      - 'packages/**'
19      - 'plan9/**'
20      - 'projects/**'
21      - 'winbuild/**'
22  pull_request:
23    branches:
24      - master
25    paths-ignore:
26      - '**/*.md'
27      - '.azure-pipelines.yml'
28      - '.circleci/**'
29      - '.cirrus.yml'
30      - 'appveyor.*'
31      - 'packages/**'
32      - 'plan9/**'
33      - 'projects/**'
34      - 'winbuild/**'
35
36concurrency:
37  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
38  cancel-in-progress: true
39
40permissions: {}
41
42env:
43  DEVELOPER_DIR: /Applications/Xcode.app/Contents/Developer
44  MAKEFLAGS: -j 4
45
46jobs:
47  autotools:
48    name: ${{ matrix.build.name }}
49    runs-on: 'macos-latest'
50    timeout-minutes: 90
51    strategy:
52      fail-fast: false
53      matrix:
54        build:
55          - name: normal
56            install: nghttp2
57            configure: --without-ssl --enable-websockets
58            macosx-version-min: 10.9
59          - name: debug
60            install: nghttp2
61            configure: --enable-debug --without-ssl --enable-websockets
62            macosx-version-min: 10.9
63          - name: libssh2
64            install: nghttp2 libssh2
65            configure: --enable-debug --with-libssh2=$(brew --prefix)/opt/libssh2 --without-ssl --enable-websockets
66            macosx-version-min: 10.9
67          - name: libssh-c-ares
68            install: openssl nghttp2 libssh
69            configure: --enable-debug --with-libssh --with-openssl=$(brew --prefix)/opt/openssl --enable-ares --enable-websockets
70            macosx-version-min: 10.9
71          - name: libssh
72            install: openssl nghttp2 libssh
73            configure: --enable-debug --with-libssh --with-openssl=$(brew --prefix)/opt/openssl --enable-websockets
74            macosx-version-min: 10.9
75          - name: c-ares
76            install: nghttp2
77            configure: --enable-debug --enable-ares --without-ssl --enable-websockets
78            macosx-version-min: 10.9
79          - name: HTTP only
80            install: nghttp2
81            configure: |
82              --enable-debug \
83              --enable-maintainer-mode \
84              --disable-alt-svc \
85              --disable-dict \
86              --disable-file \
87              --disable-ftp \
88              --disable-gopher \
89              --disable-imap \
90              --disable-ldap \
91              --disable-pop3 \
92              --disable-rtmp \
93              --disable-rtsp \
94              --disable-scp \
95              --disable-sftp \
96              --disable-shared \
97              --disable-smb \
98              --disable-smtp \
99              --disable-telnet \
100              --disable-tftp \
101              --disable-unix-sockets \
102              --without-brotli \
103              --without-gssapi \
104              --without-libidn2 \
105              --without-libpsl \
106              --without-librtmp \
107              --without-libssh2 \
108              --without-nghttp2 \
109              --without-ntlm-auth \
110              --without-ssl \
111              --without-zlib \
112              --without-zstd
113
114            macosx-version-min: 10.15
115          - name: SecureTransport http2
116            install: nghttp2
117            configure: --enable-debug --with-secure-transport --enable-websockets
118            macosx-version-min: 10.8
119          # fails now with linker error on missing symbols, macos no longer old enough?
120          # - name: gcc SecureTransport
121          #   configure: CC=gcc-12 --enable-debug --with-secure-transport --enable-websockets --without-libpsl
122          #   macosx-version-min: 10.8
123          - name: OpenSSL http2
124            install: nghttp2 openssl
125            configure: --enable-debug --with-openssl=$(brew --prefix)/opt/openssl --enable-websockets
126            macosx-version-min: 10.9
127          - name: LibreSSL http2
128            install: nghttp2 libressl
129            configure: --enable-debug --with-openssl=$(brew --prefix)/opt/libressl --enable-websockets
130            macosx-version-min: 10.9
131          - name: torture
132            install: nghttp2 openssl
133            configure: --enable-debug --disable-shared --disable-threaded-resolver --with-openssl=$(brew --prefix)/opt/openssl --enable-websockets
134            tflags: -n -t --shallow=25 !FTP
135            macosx-version-min: 10.9
136          - name: torture-ftp
137            install: nghttp2 openssl
138            configure: --enable-debug --disable-shared --disable-threaded-resolver --with-openssl=$(brew --prefix)/opt/openssl --enable-websockets
139            tflags: -n -t --shallow=20 FTP
140            macosx-version-min: 10.9
141          - name: macOS 10.15
142            install: nghttp2 libssh2 openssl
143            configure: --enable-debug --disable-ldap --with-openssl=$(brew --prefix)/opt/openssl --enable-websockets
144            macosx-version-min: 10.15
145    steps:
146      - run: echo libtool autoconf automake pkg-config libpsl ${{ matrix.build.install }} | xargs -Ix -n1 echo brew '"x"' > /tmp/Brewfile
147        name: 'brew bundle'
148
149      # Run this command with retries because of spurious failures seen
150      # while running the tests, for example
151      # https://github.com/curl/curl/runs/4095721123?check_suite_focus=true
152      - run: "while [[ $? == 0 ]]; do for i in 1 2 3; do brew update && brew bundle install --no-lock --file /tmp/Brewfile && break 2 || { echo Error: wait to try again; sleep 10; } done; false Too many retries; done"
153        name: 'brew install'
154
155      - run: |
156          case "${{ matrix.build.install }}" in
157            *openssl*)
158              (
159                cd $(brew --prefix)/opt/openssl/lib/pkgconfig/
160                for i in libssl.pc libcrypto.pc; do
161                  sudo cp $i $i.orig
162                  sudo sed s,libdir=$(brew --prefix)'/Cellar/openssl@3/3.3.0$',libdir=$(brew --prefix)/Cellar/openssl@3/3.3.0/lib,g < $i.orig > /tmp/$i
163                  sudo cp /tmp/$i $i
164                  cat $i
165                done
166              )
167              ;;
168            *)
169              if test -d $(brew --prefix)/include/openssl; then
170                brew unlink openssl
171              fi;;
172          esac
173        name: 'brew unlink openssl'
174
175      - run: |
176          python3 -m venv $HOME/venv
177          source $HOME/venv/bin/activate
178          python3 -m pip install impacket
179        name: 'pip3 install'
180
181      - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
182
183      - run: rm -f $HOME/.curlrc
184        name: remove $HOME/.curlrc
185
186      - run: autoreconf -fi
187        name: 'autoreconf'
188
189      - run: ./configure --disable-dependency-tracking --enable-warnings --enable-werror ${{ matrix.build.configure }}
190        name: 'configure'
191        env:
192          CFLAGS: "-mmacosx-version-min=${{ matrix.build.macosx-version-min }}"
193
194      - run: make V=1
195        name: 'make'
196
197      - run: make V=1 examples
198        name: 'make examples'
199
200      - run: make V=1 -C tests
201        name: 'make tests'
202
203      - run: make V=1 test-ci
204        name: 'run tests'
205        env:
206          TFLAGS: "${{ matrix.build.tflags }} ~1452"
207
208  cmake:
209    name: cmake ${{ matrix.compiler.CC }} ${{ matrix.build.name }}
210    runs-on: 'macos-latest'
211    env:
212      CC: ${{ matrix.compiler.CC }}
213      # '-Wno-deprecated-declarations' required for LDAP and BUILD_EXAMPLES
214      CFLAGS: '-DCMAKE_C_FLAGS=-mmacosx-version-min=10.15 -Wno-deprecated-declarations'
215    strategy:
216      fail-fast: false
217      matrix:
218        compiler:
219          - CC: clang
220          - CC: gcc-12
221        build:
222          - name: OpenSSL
223            install: nghttp2 openssl gsasl
224            generate: -DOPENSSL_ROOT_DIR=$(brew --prefix)/opt/openssl -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 -DCURL_USE_GSASL=ON
225          - name: LibreSSL
226            install: nghttp2 libressl
227            generate: -DOPENSSL_ROOT_DIR=$(brew --prefix)/opt/libressl -DCURL_DISABLE_LDAP=ON -DCURL_DISABLE_LDAPS=ON -DBUILD_EXAMPLES=ON
228          - name: libssh2
229            install: nghttp2 openssl libssh2
230            generate: -DOPENSSL_ROOT_DIR=$(brew --prefix)/opt/openssl -DCURL_USE_LIBSSH2=ON -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON
231          - name: GnuTLS
232            install: gnutls
233            generate: -DCURL_USE_GNUTLS=ON -DCURL_USE_OPENSSL=OFF -DCURL_DISABLE_LDAP=ON -DCURL_DISABLE_LDAPS=ON -DCMAKE_SHARED_LINKER_FLAGS=-L$(brew --prefix)/lib -DCMAKE_EXE_LINKER_FLAGS=-L$(brew --prefix)/lib
234    steps:
235      - run: echo libtool autoconf automake pkg-config ${{ matrix.build.install }} | xargs -Ix -n1 echo brew '"x"' > /tmp/Brewfile
236        name: 'brew bundle'
237
238      - run: "while [[ $? == 0 ]]; do for i in 1 2 3; do brew update && brew bundle install --no-lock --file /tmp/Brewfile && break 2 || { echo Error: wait to try again; sleep 10; } done; false Too many retries; done"
239        name: 'brew install'
240
241      - run: |
242          case "${{ matrix.build.install }}" in
243            *openssl*)
244              ;;
245            *)
246              if test -d $(brew --prefix)/include/openssl; then
247                brew unlink openssl
248              fi;;
249          esac
250        name: 'brew unlink openssl'
251
252      - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
253
254      - run: cmake -B build -DCMAKE_UNITY_BUILD=ON -DCURL_WERROR=ON -DUSE_APPLE_IDN=ON ${{ matrix.build.generate }}
255        name: 'cmake generate'
256
257      - run: cmake --build build --parallel 3
258        name: 'cmake build'
259