1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
version: 2.1
no-backports: &no-backports
name: Skip any branches called cherry-pick
command: |
if [[ "${CIRCLE_BRANCH}" == *"cherry-pick"* || "${CIRCLE_BRANCH}" == *"backport"* ]]; then
circleci step halt
fi
skip-check: &skip-check
name: Check for [ci skip]
command: bash .circleci/early_exit.sh
merge-check: &merge-check
name: Check if we need to merge upstream main
command: |
if [[ -n "${CIRCLE_PR_NUMBER}" ]]; then
git fetch origin --tags
git fetch origin +refs/pull/$CIRCLE_PR_NUMBER/merge:pr/$CIRCLE_PR_NUMBER/merge
git checkout -qf pr/$CIRCLE_PR_NUMBER/merge
fi
apt-run: &apt-install
name: Install apt packages
command: |
sudo apt update
sudo apt install -y libopenjp2-7
jobs:
figure:
parameters:
jobname:
type: string
docker:
- image: cimg/python:3.12
environment:
TOXENV=<< parameters.jobname >>
steps:
- run: *no-backports
- checkout
- run: *skip-check
- run: *merge-check
- run: *apt-install
- run: pip install --user -U tox tox-pypi-filter
- run: tox -v
- run:
name: Running codecov
command: bash -e .circleci/codecov_upload.sh -f ".tmp/${TOXENV}/coverage.xml"
- store_artifacts:
path: .tmp/<< parameters.jobname >>/figure_test_images
- run:
name: "Image comparison page is available at: "
command: echo "${CIRCLE_BUILD_URL}/artifacts/${CIRCLE_NODE_INDEX}/.tmp/${TOXENV}/figure_test_images/fig_comparison.html"
deploy-reference-images:
parameters:
jobname:
type: string
docker:
- image: cimg/python:3.12
environment:
TOXENV: << parameters.jobname >>
GIT_SSH_COMMAND: ssh -i ~/.ssh/id_rsa_7b8fc81c13a3b446ec9aa50d3f626978
steps:
- checkout
- run: *skip-check
- run: *merge-check
- run: *apt-install
# Clear out all the ssh keys so that it always uses the write deploy key
- run: ssh-add -D
# Add private key for deploying to the figure tests repo
- add_ssh_keys:
fingerprints: "7b:8f:c8:1c:13:a3:b4:46:ec:9a:a5:0d:3f:62:69:78"
- run: ssh-keyscan github.com >> ~/.ssh/known_hosts
- run: git config --global user.email "sunpy@circleci" && git config --global user.name "SunPy Circle CI"
- run: git clone git@github.com:sunpy/sunpy-figure-tests.git --depth 1 -b sunpy-${CIRCLE_BRANCH} ~/sunpy-figure-tests/
# Generate Reference images
- run: pip install --user -U tox tox-pypi-filter
- run: rm -rf /home/circleci/sunpy-figure-tests/figures/$TOXENV/*
- run: tox -v -- --mpl-generate-path=/home/circleci/sunpy-figure-tests/figures/$TOXENV | tee toxlog
- run: |
hashlib=$(grep "^figure_hashes.*\.json$" toxlog)
cp ./sunpy/tests/$hashlib /home/circleci/sunpy-figure-tests/figures/$TOXENV/
- run: |
cd ~/sunpy-figure-tests/
git pull
git status
git add .
git commit -m "Update reference figures from ${CIRCLE_BRANCH}" || echo "No changes to reference images to deploy"
git push
workflows:
version: 2
figure-tests:
jobs:
- figure:
name: << matrix.jobname >>
matrix:
parameters:
jobname:
- "py312-figure"
- "py312-figure-devdeps"
- deploy-reference-images:
name: baseline-<< matrix.jobname >>
matrix:
parameters:
jobname:
- "py312-figure"
- "py312-figure-devdeps"
requires:
- << matrix.jobname >>
filters:
branches:
only:
- main
|