Don't stuck loading on mismatching info-hashes in resume data
[qBittorrent.git] / .github / workflows / ci_ubuntu.yaml
blob448ee7391d9809f1666467184300b586e68fb09e
1 name: CI - Ubuntu
3 on: [pull_request, push]
5 permissions:
6   actions: write
7   security-events: write
9 concurrency:
10   group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
11   cancel-in-progress: ${{ github.head_ref != '' }}
13 jobs:
14   ci:
15     name: Build
16     runs-on: ubuntu-latest
18     strategy:
19       fail-fast: false
20       matrix:
21         libt_version: ["2.0.9", "1.2.19"]
22         qbt_gui: ["GUI=ON", "GUI=OFF"]
23         qt_version: ["6.5.2"]
25     env:
26       boost_path: "${{ github.workspace }}/../boost"
27       harden_flags: "-D_FORTIFY_SOURCE=2 -D_GLIBCXX_ASSERTIONS"
28       libtorrent_path: "${{ github.workspace }}/../libtorrent"
30     steps:
31       - name: Checkout repository
32         uses: actions/checkout@v4
34       - name: Install dependencies
35         run: |
36           sudo apt update
37           sudo apt install \
38             build-essential cmake ninja-build \
39             libssl-dev libxkbcommon-x11-dev libxcb-cursor-dev zlib1g-dev
41       - name: Setup ccache
42         uses: Chocobo1/setup-ccache-action@v1
43         with:
44           store_cache: ${{ startsWith(github.ref, 'refs/heads/') }}
45           update_packager_index: false
46           ccache_options: |
47             max_size=2G
49       - name: Install boost
50         run: |
51           boost_url="https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.gz"
52           boost_url2="https://sourceforge.net/projects/boost/files/boost/1.76.0/boost_1_76_0.tar.gz"
53           set +e
54           curl -L -o "${{ runner.temp }}/boost.tar.gz" "$boost_url"
55           tar -xf "${{ runner.temp }}/boost.tar.gz" -C "${{ github.workspace }}/.."; _exitCode="$?"
56           if [ "$_exitCode" -ne "0" ]; then
57             curl -L -o "${{ runner.temp }}/boost.tar.gz" "$boost_url2"
58             tar -xf "${{ runner.temp }}/boost.tar.gz" -C "${{ github.workspace }}/.."; _exitCode="$?"
59           fi
60           mv "${{ github.workspace }}/.."/boost_* "${{ env.boost_path }}"
62       - name: Install Qt
63         uses: jurplel/install-qt-action@v3
64         with:
65           version: ${{ matrix.qt_version }}
66           archives: icu qtbase qtdeclarative qtsvg qttools
67           cache: true
69       - name: Install libtorrent
70         run: |
71           git clone \
72             --branch v${{ matrix.libt_version }} \
73             --depth 1 \
74             --recurse-submodules \
75             https://github.com/arvidn/libtorrent.git \
76             ${{ env.libtorrent_path }}
77           cd ${{ env.libtorrent_path }}
78           CXXFLAGS="$CXXFLAGS ${{ env.harden_flags }}" \
79           cmake \
80             -B build \
81             -G "Ninja" \
82             -DBUILD_SHARED_LIBS=OFF \
83             -DCMAKE_BUILD_TYPE=RelWithDebInfo \
84             -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
85             -DBOOST_ROOT="${{ env.boost_path }}" \
86             -Ddeprecated-functions=OFF
87           cmake --build build
88           sudo cmake --install build
90       # to avoid scanning 3rdparty codebases, initialize it just before building qbt
91       - name: Initialize CodeQL
92         uses: github/codeql-action/init@v3
93         if: startsWith(matrix.libt_version, 2) && (matrix.qbt_gui == 'GUI=ON')
94         with:
95           config-file: ./.github/workflows/helper/codeql/cpp.yaml
96           languages: cpp
98       - name: Build qBittorrent
99         run: |
100           CXXFLAGS="$CXXFLAGS ${{ env.harden_flags }} -Werror" \
101           LDFLAGS="$LDFLAGS -gz" \
102           cmake \
103             -B build \
104             -G "Ninja" \
105             -DCMAKE_BUILD_TYPE=RelWithDebInfo \
106             -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
107             -DBOOST_ROOT="${{ env.boost_path }}" \
108             -DCMAKE_INSTALL_PREFIX="/usr" \
109             -DTESTING=ON \
110             -DVERBOSE_CONFIGURE=ON \
111             -D${{ matrix.qbt_gui }}
112           cmake --build build --target qbt_update_translations
113           cmake --build build
114           cmake --build build --target check
115           DESTDIR="qbittorrent" cmake --install build
117       - name: Run CodeQL analysis
118         uses: github/codeql-action/analyze@v3
119         if: startsWith(matrix.libt_version, 2) && (matrix.qbt_gui == 'GUI=ON')
120         with:
121           category: ${{ github.base_ref || github.ref_name }}
123       - name: Prepare build artifacts
124         run: |
125           mkdir upload
126           mkdir upload/cmake
127           cp build/compile_commands.json upload/cmake
128           mkdir upload/cmake/libtorrent
129           cp ${{ env.libtorrent_path }}/build/compile_commands.json upload/cmake/libtorrent
131       - name: Install AppImage
132         run: |
133           sudo apt install libfuse2
134           curl \
135             -L \
136             -Z \
137             -O https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage \
138             -O https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage \
139             -O https://github.com/linuxdeploy/linuxdeploy-plugin-appimage/releases/download/continuous/linuxdeploy-plugin-appimage-x86_64.AppImage
140           chmod +x \
141             linuxdeploy-x86_64.AppImage \
142             linuxdeploy-plugin-qt-x86_64.AppImage \
143             linuxdeploy-plugin-appimage-x86_64.AppImage
145       - name: Prepare files for AppImage
146         if: matrix.qbt_gui == 'GUI=OFF'
147         run: |
148           mkdir -p qbittorrent/usr/share/applications
149           cp .github/workflows/helper/appimage/org.qbittorrent.qBittorrent.desktop qbittorrent/usr/share/applications/org.qbittorrent.qBittorrent.desktop
150           mkdir -p qbittorrent/usr/share/icons/hicolor/scalable/apps
151           cp dist/unix/menuicons/scalable/apps/qbittorrent.svg qbittorrent/usr/share/icons/hicolor/scalable/apps/qbittorrent.svg
153       - name: Package AppImage
154         run: |
155           ./linuxdeploy-x86_64.AppImage --appdir qbittorrent --plugin qt
156           rm qbittorrent/apprun-hooks/*
157           cp .github/workflows/helper/appimage/export_vars.sh qbittorrent/apprun-hooks/export_vars.sh
158           NO_APPSTREAM=1 \
159             OUTPUT=upload/qbittorrent-CI_Ubuntu_x86_64.AppImage \
160             ./linuxdeploy-x86_64.AppImage --appdir qbittorrent --output appimage
162       - name: Upload build artifacts
163         uses: actions/upload-artifact@v4
164         with:
165           name: qBittorrent-CI_Ubuntu-x64_${{ matrix.qbt_gui }}_libtorrent-${{ matrix.libt_version }}_Qt-${{ matrix.qt_version }}
166           path: upload