name: "Code coverage"

on:
  push:
    branches: [ main, actions-test ]
  pull_request:
    branches: [ main, actions-test ]
  schedule:
    - cron: '0 7 * * 2'

jobs:
  analyze:
    runs-on: ubuntu-latest

    env:
      COVERALLS_REPO_TOKEN: "${{ secrets.COVERALLS_REPO_TOKEN }}"

    steps:
    - name: Repository checkout
      uses: actions/checkout@v2

    - name: Before_install
      run: |
        lsb_release -a
        uname -a
        whoami
        tty || echo
        pwd

    - name: Install dependencies via apt-get
      run: |
        sudo add-apt-repository ppa:ubuntu-toolchain-r/test
        sudo apt-get update
        sudo apt-get -y install \
          ca-certificates \
          gcc \
          g++ \
          gpm \
          libgpm-dev \
          libcppunit-dev \
          autoconf-archive 

    - name: Download coderalls
      run: pip install --user cpp-coveralls

    - name: Download codecov
      run: sudo pip install codecov

    - name: Build with with gcov
      run: script -e -c "./build.sh coverage"

    - name: Coveralls
      run: coveralls --gcov-options '\-lp' -e debian -e doc -e icon -e logo -e m4 -e scripts -e examples

    - name: Codecov
      run: bash <(curl -s https://codecov.io/bash)

