Skip to content

Commit 6e7b128

Browse files
authored
Merge pull request #7596 from plotly/cam/add-circleci-image-download-script
ci: Add CircleCI image download script
2 parents 80c7c7d + a72ade5 commit 6e7b128

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

.circleci/config.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ jobs:
303303
- run:
304304
name: Compare pixels
305305
command: .circleci/test.sh test-image ; find build -maxdepth 1 -type f -delete
306+
- image-diff-message
306307
- store_artifacts:
307308
path: build
308309
destination: /
@@ -317,6 +318,7 @@ jobs:
317318
- run:
318319
name: Compare pixels
319320
command: .circleci/test.sh test-image-virtual-webgl ; find build -maxdepth 1 -type f -delete
321+
- image-diff-message
320322
- store_artifacts:
321323
path: build
322324
destination: /
@@ -331,6 +333,7 @@ jobs:
331333
- run:
332334
name: Compare pixels
333335
command: .circleci/test.sh test-image ; find build -maxdepth 1 -type f -delete
336+
- image-diff-message
334337
- store_artifacts:
335338
path: build
336339
destination: /
@@ -345,6 +348,7 @@ jobs:
345348
- run:
346349
name: Compare pixels of mathjax v3 baselines
347350
command: .circleci/test.sh test-image-mathjax3
351+
- image-diff-message
348352
- store_artifacts:
349353
path: build
350354
destination: /
@@ -515,6 +519,16 @@ jobs:
515519
- store_artifacts:
516520
path: topojson.tar
517521

522+
commands:
523+
image-diff-message:
524+
steps:
525+
- run:
526+
name: IMAGE DIFF DETECTED - SEE NOTE BELOW
527+
when: on_fail
528+
command: |
529+
echo "Image Diff Detected: baseline images may need to be updated. Run 'tasks/circleci_image_artifact_download.sh' to download the baseline images generated by this job."
530+
echo "Add the new images to 'test/image/baselines/' and commit them to this pull request."
531+
518532
workflows:
519533
version: 2
520534
build-and-test:
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bash
2+
3+
# Usage: $ ./circleci_image_artifact_download.sh JOB_NUMBER DEST_DIR
4+
5+
# The job number is shown on the job page in the navigation breadcrumbs under 'Job':
6+
# ... Job
7+
# ... > test-baselines (123456)
8+
# It's also shown in the URL: '.../jobs/123456/...'
9+
10+
set -euo pipefail
11+
12+
# Arguments
13+
JOB_NUMBER="${1:-}"
14+
DEST_DIR="${2:-.}"
15+
16+
# Check if job number is provided
17+
if [[ -z "$JOB_NUMBER" ]]; then
18+
echo "CircleCI job number required. Usage: $0 <job-number> [destination-directory]"
19+
exit 1
20+
fi
21+
22+
mkdir -p "$DEST_DIR"
23+
cd "$DEST_DIR"
24+
25+
# Get list of artifact URLs (filtering for .png files not containing 'diff')
26+
artifact_urls=$(curl https://circleci.com/api/v2/project/github/plotly/plotly.js/$JOB_NUMBER/artifacts \
27+
| grep -oE "https.*png" \
28+
| grep -v "diff")
29+
30+
# Download each artifact
31+
echo "$artifact_urls" | while read -r url; do
32+
echo "Downloading $url..."
33+
curl -s -L -O "$url"
34+
done
35+
36+
echo "✅ All PNG artifacts saved to: $DEST_DIR"

0 commit comments

Comments
 (0)