name: Meson

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

  workflow_dispatch:

jobs:
  linux:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Install requirements
        run: |
          sudo apt-get update
          sudo apt-get upgrade
          sudo apt-get install -y meson docbook-xml docbook-xsl xsltproc libjson-c-dev libglib2.0-dev libgirepository1.0-dev libsystemd-dev python3-systemd python3-pyudev python3-lxml
          python3 -m pip install --upgrade pip wheel
          python3 -m pip install --upgrade dasbus pylint pyflakes PyGObject
          python3 -m pip install --upgrade vermin
          python3 -m pip install --upgrade pyfakefs

      - uses: BSFishy/meson-build@v1.0.3
        with:
          action: test
          directory: .build
          setup-options: -Dman=true -Dhtml=true
          options: --print-errorlogs --suite nvme-stas

      - name: Generate coverage report
        run: |
          python3 -m pip install pytest
          python3 -m pip install pytest-cov
          PYTHONPATH=.build:.build/subprojects/libnvme:/usr/lib/python3/dist-packages/ pytest --cov=./staslib --cov-report=xml test/test-*.py

      - uses: codecov/codecov-action@v3
        with:
          fail_ci_if_error: false