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