name: test

on:
  pull_request:
    paths:
      - 'keylime/**'
      - 'test/**'
      - 'test-data/**'
  workflow_dispatch:

jobs:
  style-checks:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - uses: actions/setup-python@v3
    - uses: pre-commit/action@v3.0.0
  tpm-tests:
    runs-on: ubuntu-latest
    container:
      image: quay.io/keylime/keylime-ci:latest
      options: --user root --mount type=tmpfs,destination=/var/lib/keylime/,tmpfs-mode=1770
      env:
        KEYLIME_TEST: True
    steps:
    - name: Checkout
      uses: actions/checkout@v2
    - name: Run tests
      run: .ci/test_wrapper.sh
  lint:
    runs-on: ubuntu-latest
    container:
      image: quay.io/keylime/keylime-ci:latest
      options: --user root --mount type=tmpfs,destination=/var/lib/keylime/,tmpfs-mode=1770
      env:
        KEYLIME_TEST: True
    steps:
    - name: Checkout
      uses: actions/checkout@v2
    - name: Install build dependencies
      run: sudo dnf -y install swig
    - name: Install Python dependencies
      run: sudo dnf -y install python3.6 tox python3-pip
    - name: Run lints
      run: tox -vv -e 'pylint,pylint36'
    - name: Run mypy
      run: tox -vv -e 'mypy'
    - name: Run pyright
      run: tox -vv -e 'pyright'
