name: Build

on:
  push:
    branches:
      - main
    tags:
      - 'v*'
  pull_request:

jobs:
  Build:
    name: Build
    runs-on: ubuntu-latest
    env:
      QT_VERSION: 6.7.3
      PATH: $HOME/.cargo/bin:$PATH
    steps:
      - uses: actions/checkout@v6

      - name: Install Rust
        run: |
          curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

      - name: Install apt packages
        run: |
          apt update -y
          apt install -y \
            build-essential \
            cmake \
            curl \
            libgl1-mesa-dev \
            python3 \
            python3-pip

      - name: Install aqtinstall
        run: |
          python3 -m pip install aqtinstall

      - name: Install Qt
        run: |
          aqt install-qt linux desktop $QT_VERSION linux_gcc_64

      - name: Build clide
        env:
          QMAKE: ${{ env.CI_WORKSPACE }}/${{ env.QT_VERSION }}/gcc_64/bin/qmake
        run: |
          . "$HOME/.cargo/env"
          cargo b --release

      - name: Test libclide
        run: |
          . "$HOME/.cargo/env"
          cargo test -p libclide

      - name: Test clide
        run: |
          . "$HOME/.cargo/env"
          cargo test
