Skip to content

Commit

Permalink
ci: run only one test in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
bolinocroustibat committed Dec 21, 2024
1 parent 662ae5d commit bcb6e17
Showing 1 changed file with 18 additions and 27 deletions.
45 changes: 18 additions & 27 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- image: redis:alpine
environment:
BASH_ENV: /root/.bashrc
parallelism: 4
parallelism: 2
steps:
- checkout
- run:
Expand Down Expand Up @@ -58,35 +58,26 @@ jobs:
mkdir -p reports/python
source venv/bin/activate
# List of tests that must run serially (one per line for easier maintenance)
SERIAL_TESTS="
udata/tests/dataset/test_dataset_tasks.py
# List of tests to run in parallel (one per line)
PARALLEL_TESTS="
udata/harvest/tests/test_actions.py
"
# Remove leading/trailing whitespace and convert to space-separated list
PARALLEL_TESTS_LIST=$(echo "$PARALLEL_TESTS" | tr -d '\n' | xargs)
if [ "$CIRCLE_NODE_INDEX" = "0" ]; then
# First executor runs the non-parallel safe tests
echo "Running serial tests..."
SERIAL_TEST_FILES=$(echo "$SERIAL_TESTS" | tr -d '\n')
inv test --report --ci --paths "${SERIAL_TEST_FILES}"
fi
# Then run the rest of the tests split across executors
echo "Running parallel tests..."
# Fix: properly construct the find command with exclusions
EXCLUSIONS=""
while read -r test_file; do
if [ -n "$test_file" ]; then
EXCLUSIONS="$EXCLUSIONS ! -path $test_file"
fi
done <<< "$SERIAL_TESTS"
echo "Debug: Find command exclusions: $EXCLUSIONS"
TESTFILES=$(find udata/tests -name "test_*.py" $EXCLUSIONS | circleci tests split --split-by=timings)
if [ -n "$TESTFILES" ]; then
echo "Debug: Running parallel tests on node $CIRCLE_NODE_INDEX:"
echo "$TESTFILES"
inv test --report --ci --paths "${TESTFILES}"
echo "Running all tests except parallel ones..."
# Create a temporary file with all test files
find . -name "test_*.py" > all_tests.txt
# Remove parallel tests from the list
for test in $PARALLEL_TESTS_LIST; do
sed -i "\:$test:d" all_tests.txt
done
# Run remaining tests - all at once instead of trying to pass them individually
inv test --report --ci
else
echo "Running parallel tests: $PARALLEL_TESTS_LIST"
inv test --report --ci --paths "$PARALLEL_TESTS_LIST"
fi
- store_test_results:
path: reports/python
Expand Down

0 comments on commit bcb6e17

Please sign in to comment.