Skip to content

Commit 56cc922

Browse files
committed
chore: revert to parallalism for windows
1 parent 55f7cc4 commit 56cc922

File tree

2 files changed

+37
-25
lines changed

2 files changed

+37
-25
lines changed

.circleci/cache-python-docker.sh

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ set -e
33

44
# Script to manage Docker image caching on Windows CircleCI
55
# Usage: ./cache-python-docker.sh [load|save|pull]
6+
#
7+
# Uses environment variable DOCKER_IMAGE_WAS_CACHED to track state across CircleCI steps:
8+
# - true: Image was already present (loaded from cache or previously pulled)
9+
# - false: Image was newly pulled in this run and should be saved to cache
610

711
CACHE_DIR="/c/docker-cache"
812
PYTHON_IMAGE="python@sha256:1f92d35b567363820d0f2f37c7ccf2c1543e2d852cea01edb027039e6aef25e6"
913
PYTHON_IMAGE_FILE="python-3.9.0.tar"
10-
STATE_FILE="/tmp/.docker-cache-state"
1114

1215
# Function to check if image exists
1316
image_exists() {
@@ -35,20 +38,33 @@ case "$1" in
3538
# Track if image was already present
3639
if image_exists "$PYTHON_IMAGE"; then
3740
echo "Python image already exists locally"
38-
echo "already_present" > "$STATE_FILE"
41+
# Set environment variable for CircleCI (persists across steps)
42+
if [ -n "$BASH_ENV" ]; then
43+
echo "export DOCKER_IMAGE_WAS_CACHED=true" >> $BASH_ENV
44+
fi
45+
export DOCKER_IMAGE_WAS_CACHED=true
3946
else
4047
echo "Python image not found locally, pulling from registry..."
4148
docker pull "$PYTHON_IMAGE"
4249
echo "Python image pulled successfully"
43-
echo "newly_pulled" > "$STATE_FILE"
50+
# Set environment variable for CircleCI (persists across steps)
51+
if [ -n "$BASH_ENV" ]; then
52+
echo "export DOCKER_IMAGE_WAS_CACHED=false" >> $BASH_ENV
53+
fi
54+
export DOCKER_IMAGE_WAS_CACHED=false
4455
fi
4556
;;
4657

4758
save)
4859
echo "=== Saving Docker images to cache ==="
4960

61+
# Source BASH_ENV to get environment variables from previous steps
62+
if [ -n "$BASH_ENV" ] && [ -f "$BASH_ENV" ]; then
63+
source $BASH_ENV
64+
fi
65+
5066
# Check if we should save (only if we pulled it this run)
51-
if [ -f "$STATE_FILE" ] && [ "$(cat $STATE_FILE)" = "newly_pulled" ]; then
67+
if [ "$DOCKER_IMAGE_WAS_CACHED" = "false" ]; then
5268
mkdir -p "$CACHE_DIR"
5369

5470
if image_exists "$PYTHON_IMAGE"; then
@@ -63,11 +79,8 @@ case "$1" in
6379
exit 1
6480
fi
6581
else
66-
echo "Python image was already cached, skipping save"
82+
echo "Python image was already cached (DOCKER_IMAGE_WAS_CACHED=$DOCKER_IMAGE_WAS_CACHED), skipping save"
6783
fi
68-
69-
# Clean up state file
70-
rm -f "$STATE_FILE"
7184
;;
7285

7386
*)

.circleci/config.yml

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ windows_medium: &windows_medium
5656
name: win/server-2022
5757
shell: bash.exe
5858
size: medium
59+
version: "2023.05.1"
5960
parameters:
6061
node_version:
6162
type: string
@@ -181,7 +182,8 @@ jobs:
181182
path: test-logs.txt
182183
destination: test-logs
183184
test_jest_windows_with_docker:
184-
<<: *windows_big
185+
<<: *windows_medium
186+
parallelism: 2 # Run tests across 2 containers
185187
steps:
186188
- checkout
187189
- install_node_npm:
@@ -198,6 +200,7 @@ jobs:
198200
- save_cache:
199201
key: v1-win-dependencies-{{ checksum "package.json" }}
200202
paths:
203+
- node_modules
201204
- .npm-cache
202205

203206
- run: docker version
@@ -222,7 +225,8 @@ jobs:
222225
- run:
223226
name: Run Windows tests in parallel
224227
command: |
225-
npm run test-jest-windows
228+
TEST=$(circleci tests glob "test/windows/**/*.spec.ts" | circleci tests split --split-by=timings | sed 's#\\\\#/#g')
229+
npm run test-jest-windows -- $TEST --reporters=default --reporters=jest-junit
226230
environment:
227231
JEST_JUNIT_OUTPUT_DIR: './reports/junit'
228232
JEST_JUNIT_ADD_FILE_ATTRIBUTE: 'true' # We need this to make --split-by=timings work
@@ -240,7 +244,8 @@ jobs:
240244
paths:
241245
- C:\docker-cache
242246
test_jest_windows_no_docker:
243-
<<: *windows_big
247+
<<: *windows_medium
248+
parallelism: 2 # Run tests across 2 containers
244249
steps:
245250
- checkout
246251
- install_node_npm:
@@ -257,6 +262,7 @@ jobs:
257262
- save_cache:
258263
key: v1-win-dependencies-{{ checksum "package.json" }}
259264
paths:
265+
- node_modules
260266
- .npm-cache
261267
# make docker appear to be broken.
262268
- run: "function docker() { return 1; }"
@@ -266,15 +272,8 @@ jobs:
266272
- run:
267273
name: Run Windows tests in parallel
268274
command: |
269-
echo "====Before===="
270-
ls ${TMPDIR:-/tmp}
271-
echo "==============="
272-
273-
npm run test-jest-windows
274-
275-
echo "====After===="
276-
ls ${TMPDIR:-/tmp}
277-
echo "==============="
275+
TEST=$(circleci tests glob "test/windows/**/*.spec.ts" | circleci tests split --split-by=timings | sed 's#\\\\#/#g')
276+
npm run test-jest-windows -- $TEST --reporters=default --reporters=jest-junit
278277
environment:
279278
JEST_JUNIT_OUTPUT_DIR: './reports/junit'
280279
JEST_JUNIT_ADD_FILE_ATTRIBUTE: 'true' # We need this to make --split-by=timings work
@@ -298,13 +297,13 @@ jobs:
298297
echo $CLI_COMMIT_HASH >> /tmp/cli-version
299298
- restore_cache:
300299
keys:
301-
- v1-cli-repo-g-{{ checksum "/tmp/cli-version" }}
302-
- v1-cli-repo-g-
300+
- v1-cli-repo-{{ checksum "/tmp/cli-version" }}
301+
- v1-cli-repo-
303302
- run:
304303
name: Build Snyk CLI with latest changes
305304
command: ./.circleci/build-cli.sh
306305
- save_cache:
307-
key: v1-cli-repo-g-{{ checksum "/tmp/cli-version" }}
306+
key: v1-cli-repo-{{ checksum "/tmp/cli-version" }}
308307
paths:
309308
- ~/cli
310309
build_and_test_latest_go_binary:
@@ -384,8 +383,8 @@ workflows:
384383
- nodejs-install
385384
- snyk-bot-slack
386385
node_version: *windows_node_version
387-
requires:
388-
- Install, Lint, and Build
386+
# requires:
387+
# - Install, Lint, and Build
389388
post-steps:
390389
- *slack-fail-notify
391390
- build_cli:

0 commit comments

Comments
 (0)