Skip to content

Commit

Permalink
feat(): include tests collection action
Browse files Browse the repository at this point in the history
  • Loading branch information
Rebits authored and juliamagan committed Sep 7, 2023
1 parent 29933f6 commit dad023b
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 3 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/pytest_tests_collection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Tests collection

on:
pull_request:
paths:
- tests/**

jobs:
setup:
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/[email protected]

- 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 ' ')
output='matrix=['
dir_list=''
for dir in $DIRECTORIES; do
dir_list="$dir_list\"$dir\","
done
dir_list=${dir_list[@]::-1}
output="$output""$dir_list"' ]'
echo "$output" >> $GITHUB_OUTPUT
- name: Show matrix
run: echo ${{ steps.set-matrix.outputs.matrix }}

run-pytest:
name: Tests Collection
needs: setup
strategy:
matrix:
value: ${{ fromJson(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.py install
working-directory: deps/wazuh_testing

- name: Run pytest
run: |
pytest --collect-only tests/${{ matrix.value }}
9 changes: 6 additions & 3 deletions deps/wazuh_testing/wazuh_testing/tools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,12 @@ def get_random_string(string_length, digits=True):


def get_version():
f = open('../../version.json')
data = json.load(f)
version = data['version']
try:
f = open('../../version.json')
data = json.load(f)
version = data['version']
except Exception:
version = 'N/A'
return version


Expand Down
1 change: 1 addition & 0 deletions f
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
matrix=integration performance

0 comments on commit dad023b

Please sign in to comment.