diff --git a/.github/workflows/pytest_tests_collection.yaml b/.github/workflows/pytest_tests_collection.yaml new file mode 100644 index 0000000000..77ba7e08c2 --- /dev/null +++ b/.github/workflows/pytest_tests_collection.yaml @@ -0,0 +1,53 @@ +name: Tests collection + +on: + pull_request: + paths: + - tests/** + +jobs: + matrix_prep: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v14.6 + + - id: set-matrix + run: | + files_changed="${{ steps.changed-files.outputs.all_changed_files }}" + DIRECTORIES=$(echo $files_changed | tr ' ' '\n' | grep ^tests | grep -v pytest.ini | cut -d/ -f2 | uniq | tr -d ' ') + echo "matrix={\"include\":$(echo $DIRECTORIES)}" >> $GITHUB_OUTPUT + + + run-pytest: + strategy: + matrix: + directory: ${{(needs.matrix_prep.outputs.matrix)}} + + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Install dependencies + run: pip install -r requirements.txt + + - name: Install dependencies + run: python3 setup install + working-directory: deps/wazuh_testing + + - name: Run pytest + run: | + pytest --collect-only tests/${{ matrix.directory[1] }}