name: build
on:
  pull_request_target:
  push:
    branches:
      - master
      - 'release/**'
jobs:
  ubuntu2404:
    name: ubuntu_24.04
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@v3
        with:
          ref: ${{ github.event.pull_request.head.sha }}

      - uses: awalsh128/cache-apt-pkgs-action@latest
        with:
          packages: cmake debhelper-compat erofs-utils erofsfuse intltool libcli11-dev libcurl4-openssl-dev libdeflate-dev libelf-dev libexpected-dev libfuse3-dev libglib2.0-dev libgmock-dev libgtest-dev liblz4-dev liblzma-dev libostree-dev libpcre2-dev libselinux1-dev libssl-dev libsystemd-dev libyaml-cpp-dev libzstd-dev nlohmann-json3-dev pkg-config qt6-base-dev qt6-base-private-dev zlib1g-dev
          version: 1.0

      - name: Build
        run: |
          mkdir build
          cd build
          cmake -DCMAKE_BUILD_TYPE=Release \
            -DCPM_LOCAL_PACKAGES_ONLY=ON \
            -DBUILD_SHARED_LIBS=OFF \
            ..

          make -j$(nproc)
      - name: Run tests
        run: |
          ./build/libs/linglong/tests/ll-tests/ll-tests

  ubuntu2204:
    name: ubuntu_22.04
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@v3
        with:
          ref: ${{ github.event.pull_request.head.sha }}

      - uses: awalsh128/cache-apt-pkgs-action@latest
        with:
          packages: cmake debhelper-compat erofs-utils erofsfuse intltool libcli11-dev libcurl4-openssl-dev libdeflate-dev libelf-dev libexpected-dev libfuse3-dev libglib2.0-dev libgmock-dev libgtest-dev liblz4-dev liblzma-dev libostree-dev libpcre2-dev libselinux1-dev libssl-dev libsystemd-dev libyaml-cpp-dev libzstd-dev nlohmann-json3-dev pkg-config qtbase5-dev qtbase5-private-dev systemd zlib1g-dev
          version: 1.0

      - name: Build
        run: |
          mkdir build
          cd build
          cmake -DCMAKE_BUILD_TYPE=Release \
            -DCPM_LOCAL_PACKAGES_ONLY=ON \
            -DBUILD_SHARED_LIBS=OFF \
            -DENABLE_TESTING=OFF \
            ..

          make -j$(nproc)