WebUI: Apply box-sizing reset
[qBittorrent.git] / .github / workflows / ci_ubuntu.yaml
blob7f22c4803bf404aec72dcdac86e1dae09987077b
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.10", "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: ${{ github.ref == 'refs/heads/master' }}
45           update_packager_index: false
46           ccache_options: |
47             max_size=2G
49       - name: Install boost
50         env:
51           BOOST_MAJOR_VERSION: "1"
52           BOOST_MINOR_VERSION: "76"
53           BOOST_PATCH_VERSION: "0"
54         run: |
55           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"
56           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"
57           set +e
58           curl -L -o "${{ runner.temp }}/boost.tar.gz" "$boost_url"
59           tar -xf "${{ runner.temp }}/boost.tar.gz" -C "${{ github.workspace }}/.."; _exitCode="$?"
60           if [ "$_exitCode" -ne "0" ]; then
61             curl -L -o "${{ runner.temp }}/boost.tar.gz" "$boost_url2"
62             tar -xf "${{ runner.temp }}/boost.tar.gz" -C "${{ github.workspace }}/.."; _exitCode="$?"
63           fi
64           mv "${{ github.workspace }}/.."/boost_* "${{ env.boost_path }}"
66       - name: Install Qt
67         uses: jurplel/install-qt-action@v4
68         with:
69           version: ${{ matrix.qt_version }}
70           archives: icu qtbase qtdeclarative qtsvg qttools
71           cache: true
73       - name: Install libtorrent
74         run: |
75           git clone \
76             --branch v${{ matrix.libt_version }} \
77             --depth 1 \
78             --recurse-submodules \
79             https://github.com/arvidn/libtorrent.git \
80             ${{ env.libtorrent_path }}
81           cd ${{ env.libtorrent_path }}
82           CXXFLAGS="$CXXFLAGS ${{ env.harden_flags }}" \
83           cmake \
84             -B build \
85             -G "Ninja" \
86             -DBUILD_SHARED_LIBS=OFF \
87             -DCMAKE_BUILD_TYPE=RelWithDebInfo \
88             -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
89             -DBOOST_ROOT="${{ env.boost_path }}" \
90             -Ddeprecated-functions=OFF
91           cmake --build build
92           sudo cmake --install build
94       # to avoid scanning 3rdparty codebases, initialize it just before building qbt
95       - name: Initialize CodeQL
96         uses: github/codeql-action/init@v3
97         if: startsWith(matrix.libt_version, 2) && (matrix.qbt_gui == 'GUI=ON')
98         with:
99           config-file: ./.github/workflows/helper/codeql/cpp.yaml
100           languages: cpp
102       - name: Build qBittorrent
103         run: |
104           CXXFLAGS="$CXXFLAGS ${{ env.harden_flags }} -DQT_FORCE_ASSERTS -Werror" \
105           LDFLAGS="$LDFLAGS -gz" \
106           cmake \
107             -B build \
108             -G "Ninja" \
109             -DCMAKE_BUILD_TYPE=RelWithDebInfo \
110             -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
111             -DBOOST_ROOT="${{ env.boost_path }}" \
112             -DCMAKE_INSTALL_PREFIX="/usr" \
113             -DTESTING=ON \
114             -DVERBOSE_CONFIGURE=ON \
115             -D${{ matrix.qbt_gui }}
116           cmake --build build --target qbt_update_translations
117           cmake --build build
118           cmake --build build --target check
119           DESTDIR="qbittorrent" cmake --install build
121       - name: Run CodeQL analysis
122         uses: github/codeql-action/analyze@v3
123         if: startsWith(matrix.libt_version, 2) && (matrix.qbt_gui == 'GUI=ON')
124         with:
125           category: ${{ github.base_ref || github.ref_name }}
127       - name: Prepare build artifacts
128         run: |
129           mkdir upload
130           mkdir upload/cmake
131           cp build/compile_commands.json upload/cmake
132           mkdir upload/cmake/libtorrent
133           cp ${{ env.libtorrent_path }}/build/compile_commands.json upload/cmake/libtorrent
135       - name: Install AppImage
136         run: |
137           sudo apt install libfuse2
138           curl \
139             -L \
140             -Z \
141             -O https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-static-x86_64.AppImage \
142             -O https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-static-x86_64.AppImage \
143             -O https://github.com/linuxdeploy/linuxdeploy-plugin-appimage/releases/download/continuous/linuxdeploy-plugin-appimage-x86_64.AppImage
144           chmod +x \
145             linuxdeploy-static-x86_64.AppImage \
146             linuxdeploy-plugin-qt-static-x86_64.AppImage \
147             linuxdeploy-plugin-appimage-x86_64.AppImage
149       - name: Prepare files for AppImage
150         if: matrix.qbt_gui == 'GUI=OFF'
151         run: |
152           mkdir -p qbittorrent/usr/share/applications
153           cp .github/workflows/helper/appimage/org.qbittorrent.qBittorrent.desktop qbittorrent/usr/share/applications/org.qbittorrent.qBittorrent.desktop
154           mkdir -p qbittorrent/usr/share/icons/hicolor/scalable/apps
155           cp dist/unix/menuicons/scalable/apps/qbittorrent.svg qbittorrent/usr/share/icons/hicolor/scalable/apps/qbittorrent.svg
157       - name: Package AppImage
158         run: |
159           ./linuxdeploy-static-x86_64.AppImage --appdir qbittorrent --plugin qt
160           rm qbittorrent/apprun-hooks/*
161           cp .github/workflows/helper/appimage/export_vars.sh qbittorrent/apprun-hooks/export_vars.sh
162           NO_APPSTREAM=1 \
163             OUTPUT=upload/qbittorrent-CI_Ubuntu_x86_64.AppImage \
164             ./linuxdeploy-static-x86_64.AppImage --appdir qbittorrent --output appimage
166       - name: Upload build artifacts
167         uses: actions/upload-artifact@v4
168         with:
169           name: qBittorrent-CI_Ubuntu-x64_${{ matrix.qbt_gui }}_libtorrent-${{ matrix.libt_version }}_Qt-${{ matrix.qt_version }}
170           path: upload