Skip to content

Commit

Permalink
ci: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bolinocroustibat committed Dec 21, 2024
1 parent 0f76213 commit 4e7cab2
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,32 @@ jobs:
mkdir -p reports/python
source venv/bin/activate
# List of longer-running tests to execute in parallel (one per line)
# List of longer-running tests to execute in parallel
PARALLEL_TESTS=(
"udata/harvest/tests/test_actions.py"
"udata/tests/api/test_activities_api.py"
"udata/tests/api/test_datasets_api.py"
"udata/tests/api/test_organizations_api.py"
"udata/tests/api/test_reports_api.py"
"udata/tests/apiv2/test_swagger.py"
"udata/tests/api/test_transfer_api.py"
"udata/tests/forms/test_form_field.py"
)
# Convert array to string with | as separator for grep
PARALLEL_PATTERN=$(printf "%s|" "${PARALLEL_TESTS[@]}" | sed 's/|$//')
if [ "$CIRCLE_NODE_INDEX" = "0" ]; then
echo "=== EXECUTOR 0: Running all tests except these parallel ones: ==="
printf '%s\n' "${PARALLEL_TESTS[@]}"
echo "=================================================="
# Create a list of all test files except the parallel ones
find . -name "test_*.py" > all_tests.txt
for test in "${PARALLEL_TESTS[@]}"; do
sed -i "\:${test}:d" all_tests.txt
done
# Run the filtered tests
inv test --report --ci --paths $(cat all_tests.txt)
# Run pytest to collect all tests, then filter out parallel ones
python -m pytest --collect-only -q | grep "\.py" | grep -vE "$PARALLEL_PATTERN" > serial_tests.txt
echo "Tests to run in serial:"
cat serial_tests.txt
inv test --report --ci
else
echo "=== EXECUTOR 1: Running these parallel tests: ==="
echo "=== EXECUTOR 1: Running parallel tests: ==="
printf '%s\n' "${PARALLEL_TESTS[@]}"
echo "=================================================="
inv test --report --ci --paths "${PARALLEL_TESTS[@]}"
Expand Down

0 comments on commit 4e7cab2

Please sign in to comment.