name: Unit Tests

on:
  push:
    branches: [ "*" ]
  pull_request:
    branches: [ "*" ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    - name: Set up Python 3.7
      uses: actions/setup-python@v2
      with:
        python-version: 3.7

    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install -r requirements.txt

    - name: Python Lint
      run: |
        python -m flake8 tests detection_rules --ignore D203 --max-line-length 120

    - name: Python License Check
      run: |
        python -m detection_rules dev license-check
        
    - name: Build release package
      run: |
        python -m detection_rules dev build-release

    - name: Archive production artifacts
      uses: actions/upload-artifact@v2
      with:
        name: release-files
        path: |
          releases

    - name: Unit tests
      run: |
        python -m detection_rules test

