From 84909f381d6186ae97548d414cbbf2a2bf20af07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rebollo=20P=C3=A9rez?= Date: Tue, 21 Feb 2023 10:26:03 +0000 Subject: [PATCH] feat(): include tests collection action --- .../workflows/pytest_tests_collection.yaml | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/pytest_tests_collection.yaml 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] }}