diff --git a/.circleci/config.yml b/.circleci/config.yml index 4235b39f864..458db3c69ea 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -303,6 +303,7 @@ jobs: - run: name: Compare pixels command: .circleci/test.sh test-image ; find build -maxdepth 1 -type f -delete + - image-diff-message - store_artifacts: path: build destination: / @@ -317,6 +318,7 @@ jobs: - run: name: Compare pixels command: .circleci/test.sh test-image-virtual-webgl ; find build -maxdepth 1 -type f -delete + - image-diff-message - store_artifacts: path: build destination: / @@ -331,6 +333,7 @@ jobs: - run: name: Compare pixels command: .circleci/test.sh test-image ; find build -maxdepth 1 -type f -delete + - image-diff-message - store_artifacts: path: build destination: / @@ -345,6 +348,7 @@ jobs: - run: name: Compare pixels of mathjax v3 baselines command: .circleci/test.sh test-image-mathjax3 + - image-diff-message - store_artifacts: path: build destination: / @@ -515,6 +519,16 @@ jobs: - store_artifacts: path: topojson.tar +commands: + image-diff-message: + steps: + - run: + name: IMAGE DIFF DETECTED - SEE NOTE BELOW + when: on_fail + command: | + 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." + echo "Add the new images to 'test/image/baselines/' and commit them to this pull request." + workflows: version: 2 build-and-test: diff --git a/tasks/circleci_image_artifact_download.sh b/tasks/circleci_image_artifact_download.sh new file mode 100755 index 00000000000..a58d29e5e9e --- /dev/null +++ b/tasks/circleci_image_artifact_download.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +# Usage: $ ./circleci_image_artifact_download.sh JOB_NUMBER DEST_DIR + +# The job number is shown on the job page in the navigation breadcrumbs under 'Job': +# ... Job +# ... > test-baselines (123456) +# It's also shown in the URL: '.../jobs/123456/...' + +set -euo pipefail + +# Arguments +JOB_NUMBER="${1:-}" +DEST_DIR="${2:-.}" + +# Check if job number is provided +if [[ -z "$JOB_NUMBER" ]]; then + echo "CircleCI job number required. Usage: $0 [destination-directory]" + exit 1 +fi + +mkdir -p "$DEST_DIR" +cd "$DEST_DIR" + +# Get list of artifact URLs (filtering for .png files not containing 'diff') +artifact_urls=$(curl https://circleci.com/api/v2/project/github/plotly/plotly.js/$JOB_NUMBER/artifacts \ + | grep -oE "https.*png" \ + | grep -v "diff") + +# Download each artifact +echo "$artifact_urls" | while read -r url; do + echo "Downloading $url..." + curl -s -L -O "$url" +done + +echo "✅ All PNG artifacts saved to: $DEST_DIR"