WebUI: Use Map instead of Mootools Hash in Torrents table
[qBittorrent.git] / .github / workflows / ci_macos.yaml
blobe94c96d5d36c953f96c497ff656997ef14029a36
1 name: CI - macOS
3 on: [pull_request, push]
5 permissions:
6   actions: write
8 concurrency:
9   group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
10   cancel-in-progress: ${{ github.head_ref != '' }}
12 jobs:
13   ci:
14     name: Build
15     runs-on: macos-latest
17     strategy:
18       fail-fast: false
19       matrix:
20         libt_version: ["2.0.10", "1.2.19"]
21         qbt_gui: ["GUI=ON", "GUI=OFF"]
22         qt_version: ["6.7.0"]
24     env:
25       boost_path: "${{ github.workspace }}/../boost"
26       libtorrent_path: "${{ github.workspace }}/../libtorrent"
28     steps:
29       - name: Checkout repository
30         uses: actions/checkout@v4
32       - name: Install dependencies
33         uses: Wandalen/wretry.action@v3
34         env:
35            HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
36            HOMEBREW_NO_INSTALL_CLEANUP: 1
37         with:
38           attempt_delay: 20000
39           attempt_limit: 6
40           command: |
41             brew update > /dev/null
42             brew install \
43               cmake ninja \
44               openssl@3 zlib
46       - name: Setup ccache
47         uses: Chocobo1/setup-ccache-action@v1
48         with:
49           store_cache: ${{ github.ref == 'refs/heads/master' }}
50           update_packager_index: false
51           ccache_options: |
52             max_size=2G
54       - name: Install boost
55         env:
56           BOOST_MAJOR_VERSION: "1"
57           BOOST_MINOR_VERSION: "86"
58           BOOST_PATCH_VERSION: "0"
59         run: |
60           boost_url="https://boostorg.jfrog.io/artifactory/main/release/${{ env.BOOST_MAJOR_VERSION }}.${{ env.BOOST_MINOR_VERSION }}.${{ env.BOOST_PATCH_VERSION }}/source/boost_${{ env.BOOST_MAJOR_VERSION }}_${{ env.BOOST_MINOR_VERSION }}_${{ env.BOOST_PATCH_VERSION }}.tar.gz"
61           boost_url2="https://sourceforge.net/projects/boost/files/boost/${{ env.BOOST_MAJOR_VERSION }}.${{ env.BOOST_MINOR_VERSION }}.${{ env.BOOST_PATCH_VERSION }}/boost_${{ env.BOOST_MAJOR_VERSION }}_${{ env.BOOST_MINOR_VERSION }}_${{ env.BOOST_PATCH_VERSION }}.tar.gz"
62           set +e
63           curl -L -o "${{ runner.temp }}/boost.tar.gz" "$boost_url"
64           tar -xf "${{ runner.temp }}/boost.tar.gz" -C "${{ github.workspace }}/.."; _exitCode="$?"
65           if [ "$_exitCode" -ne "0" ]; then
66             curl -L -o "${{ runner.temp }}/boost.tar.gz" "$boost_url2"
67             tar -xf "${{ runner.temp }}/boost.tar.gz" -C "${{ github.workspace }}/.."; _exitCode="$?"
68           fi
69           mv "${{ github.workspace }}/.."/boost_* "${{ env.boost_path }}"
71       - name: Install Qt
72         uses: jurplel/install-qt-action@v4
73         with:
74           version: ${{ matrix.qt_version }}
75           archives: qtbase qtdeclarative qtsvg qttools
76           # Not sure why Qt made a hard dependency on qtdeclarative, try removing it when Qt > 6.4.0
77           cache: true
79       - name: Install libtorrent
80         run: |
81           git clone \
82             --branch v${{ matrix.libt_version }} \
83             --depth 1 \
84             --recurse-submodules \
85             https://github.com/arvidn/libtorrent.git \
86             ${{ env.libtorrent_path }}
87           cd ${{ env.libtorrent_path }}
88           cmake \
89             -B build \
90             -G "Ninja" \
91             -DBUILD_SHARED_LIBS=OFF \
92             -DCMAKE_BUILD_TYPE=RelWithDebInfo \
93             -DCMAKE_CXX_STANDARD=17 \
94             -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
95             -DBOOST_ROOT="${{ env.boost_path }}" \
96             -Ddeprecated-functions=OFF
97           cmake --build build
98           sudo cmake --install build
100       - name: Build qBittorrent
101         run: |
102           CXXFLAGS="$CXXFLAGS -Werror -Wno-error=deprecated-declarations" \
103           LDFLAGS="$LDFLAGS -gz" \
104           cmake \
105             -B build \
106             -G "Ninja" \
107             -DCMAKE_BUILD_TYPE=RelWithDebInfo \
108             -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
109             -DBOOST_ROOT="${{ env.boost_path }}" \
110             -DTESTING=ON \
111             -DVERBOSE_CONFIGURE=ON \
112             -D${{ matrix.qbt_gui }}
113           cmake --build build --target qbt_update_translations
114           cmake --build build
115           cmake --build build --target check
117       - name: Prepare build artifacts
118         run: |
119           # create .dmg
120           appName="qbittorrent"
121           if [ "${{ matrix.qbt_gui }}" = "GUI=OFF" ]; then
122             appName="qbittorrent-nox"
123           fi
124           # package
125           pushd build
126           PACKAGE_RETRY=0
127           while [ "$PACKAGE_RETRY" -lt "3" ]; do
128             macdeployqt "$appName.app" -dmg -no-strip
129             if [ -f "$appName.dmg" ]; then
130               break
131             fi
132             sleep 5
133             PACKAGE_RETRY=$((PACKAGE_RETRY + 1))
134             echo "Retry $PACKAGE_RETRY..."
135           done
136           popd
137           # prepare upload folder
138           mkdir upload
139           cp "build/$appName.dmg" upload
140           mkdir upload/cmake
141           cp build/compile_commands.json upload/cmake
142           mkdir upload/cmake/libtorrent
143           cp ${{ env.libtorrent_path }}/build/compile_commands.json upload/cmake/libtorrent
145       - name: Upload build artifacts
146         uses: actions/upload-artifact@v4
147         with:
148           name: qBittorrent-CI_macOS_${{ matrix.qbt_gui }}_libtorrent-${{ matrix.libt_version }}_Qt-${{ matrix.qt_version }}
149           path: upload