Skip to content

Commit

Permalink
💚(circleci) count available cpu cores
Browse files Browse the repository at this point in the history
CircleCI has recently updated its OS and this leads to some issue
 related to concurrency with pylint. But a workaround exists to count
available cpu cores. We take opportunity to also use this value in our
test-front job.

https://discuss.circleci.com/t/docker-executor-infrastructure-upgrade/52282/11
  • Loading branch information
jbpenrath committed Nov 25, 2024
1 parent ea23fe7 commit 583be86
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ aliases:
command: |
sudo apt-get update
sudo apt-get install -y libcairo2-dev
- &count_cpus
run:
name: Count the number of available cpu cores
command: echo "export NB_CPUS=$(cat /proc/cpuinfo | grep processor | wc -l)" >> $BASH_ENV

jobs:
# Git jobs
Expand Down Expand Up @@ -210,6 +215,7 @@ jobs:
working_directory: ~/fun
steps:
- checkout
- *count_cpus
- restore_cache:
keys:
- v2-back-dependencies-{{ .Revision }}
Expand All @@ -224,7 +230,7 @@ jobs:
command: ~/.local/bin/black . --check
- run:
name: Lint code with pylint
command: ~/.local/bin/pylint src/richie/apps src/richie/plugins sandbox tests
command: ~/.local/bin/pylint -j "${NB_CPUS}" src/richie/apps src/richie/plugins sandbox tests
- run:
name: Lint code with bandit
command: ~/.local/bin/bandit -qr src/richie/apps src/richie/plugins sandbox
Expand Down Expand Up @@ -804,14 +810,15 @@ jobs:
steps:
- *checkout_fun
- *restore_node_modules
- *count_cpus
- run:
name: Prepare test reporting
command: |
yarn add --dev jest-junit
mkdir -p ./reports/jest
- run:
name: Run tests
command: JEST_JUNIT_OUTPUT_DIR=./reports/jest yarn test -w 3 --shard "$(($CIRCLE_NODE_INDEX + 1))/$CIRCLE_NODE_TOTAL" --reporters=default --reporters=jest-junit
command: JEST_JUNIT_OUTPUT_DIR=./reports/jest yarn test -w "${NB_CPUS}" --shard "$(($CIRCLE_NODE_INDEX + 1))/$CIRCLE_NODE_TOTAL" --reporters=default --reporters=jest-junit
- store_test_results:
path: ./reports/jest/

Expand Down

0 comments on commit 583be86

Please sign in to comment.