name: build & tests

on:
  push:
    branches: [ development, master ]
  pull_request:
    branches: [ development, master ]

env:
  BUILD_TYPE: Release

jobs:
  run-tests:
    
    runs-on: ubuntu-latest
    
    container:
      image: archlinux:latest
      volumes:
        - ${{ github.workspace }}:/repo
      options: -w /repo

    steps:
    - uses: actions/checkout@v3

    - name: create build environment
      run: pacman -Sy --noconfirm base-devel cmake extra-cmake-modules python util-linux-libs xorg-server-xvfb
    
    - name: install dependencies
      run: pacman -S --noconfirm plasma-workspace ksysguard
    
    - name: configure cmake
      run: cmake -B build -DKDE_INSTALL_USE_QT_SYS_PATHS=ON -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_FUTURE=ON -DBUILD_TESTING=ON sources
    
    - name: build
      working-directory: /repo/build
      run: make
    
    - name: test
      working-directory: /repo/build
      run: xvfb-run -a make test
