name: CI

on:
  - pull_request
  - push

jobs:
  tests:
    runs-on: ubuntu-20.04

    steps:
    - uses: actions/checkout@v2
    - name: Dependencies
      run: |
        sudo apt-get update -y
        sudo apt-get install -y --no-install-recommends clang git make pkg-config libgnutls28-dev libgcrypt20-dev libglib2.0-dev prosody gcovr

    - name: build bitlbee
      run: |
        ./configure \
           # --asan=1
           # --events=glib \
           # --ssl=gnutls \
           # --doc=0 \
           # --jabber=0 \
           # --msn=0 \
           # --oscar=0 \
           # --twitter=0 \
           # --yahoo=0

        cat ./.tests/gcovflags >> Makefile.settings
        make
        sudo make install
        sudo BITLBEE_DEBUG=1 bitlbee -Dnv 2> ./debuglog &

    - name: jabber test
      run: |
        sudo ./.tests/setup.sh
        python3 ./.tests/test1.py

    - name: debug output
      if: ${{ always() }}
      run: |
        less ./debuglog
        if cat ./debuglog | grep -i -q error; then exit 1; fi

    - name: code coverage
      if: ${{ always() }}
      run: |
        gcovr -r .
