-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refac(#3969): tests collection action
- Loading branch information
Showing
1 changed file
with
20 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,53 +11,35 @@ jobs: | |
outputs: | ||
matrix: ${{ steps.set-matrix.outputs.matrix }} | ||
steps: | ||
- 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: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Get changed files | ||
id: changed-files | ||
uses: tj-actions/[email protected] | ||
|
||
- id: set-matrix | ||
- name: Get tests modules changed | ||
id: set-changed-modules | ||
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='' | ||
echo "::set-output name=matrix::${DIRECTORIES}" | ||
for dir in $DIRECTORIES; do | ||
dir_list="$dir_list\"$dir\"," | ||
- name: Collect tests | ||
run: | | ||
for directory in ${{ steps.set-changed-modules.outputs.matrix }}; do | ||
pytest --collect-only tests/${{ matrix.value }} | ||
done | ||
dir_list=${dir_list[@]::-1} | ||
output="$output""$dir_list"' ]' | ||
echo "$output" >> $GITHUB_ENV | ||
- name: Show matrix | ||
run: echo ${{ steps.set-matrix.outputs.matrix }} | ||
|
||
run-pytest: | ||
name: Tests Collection | ||
needs: setup | ||
strategy: | ||
matrix: | ||
value: ${{ needs.setup.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 }} |