name: engine unit-test

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

jobs:
  engine_unit-test:

    runs-on: ubuntu-latest

    strategy:
      max-parallel: 1
      fail-fast: false
      matrix:
        python-version: ['3.11']

    steps:

    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v4
      with:
        python-version: ${{ matrix.python-version }}

    - name: Get source code for collecting coverage
      uses: actions/checkout@v3

    - name: Install coverage
      run: |
        python -m pip install --upgrade pip
        pip install coverage

    - name: Run unit-tests and collect coverage
      run: |
        coverage run --include=kernel_hardening_checker/engine.py,kernel_hardening_checker/test_engine.py -m unittest -v -b
        coverage xml -i -o coverage_unittest.xml

    - name: Handle coverage
      uses: codecov/codecov-action@v3
      with:
        files: ./coverage_unittest.xml
        flags: engine_unit-test
        name: engine_unit-test_upload
        fail_ci_if_error: true
        verbose: true
