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 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
|
---
# ---- Default values to be merged into tasks ----
env:
LC_ALL: C.UTF-8
LANG: C.UTF-8
PIP_CACHE_DIR: ${CIRRUS_WORKING_DIR}/.cache/pip
PRE_COMMIT_HOME: ${CIRRUS_WORKING_DIR}/.cache/pre-commit
CIRRUS_ARTIFACT_URL: https://api.cirrus-ci.com/v1/artifact/build/${CIRRUS_BUILD_ID}
# Coveralls configuration
CI_NAME: cirrus-ci
CI_BRANCH: ${CIRRUS_BRANCH}
CI_PULL_REQUEST: ${CIRRUS_PR}
CI_BUILD_NUMBER: ${CIRRUS_BUILD_ID}
CI_BUILD_URL: https://cirrus-ci.com/build/${CIRRUS_BUILD_ID}
COVERALLS_PARALLEL: "true"
COVERALLS_FLAG_NAME: ${CIRRUS_TASK_NAME}
# Project-specific
VALIDATE_PYPROJECT_CACHE_REMOTE: tests/.cache
# ---- Templates ----
.task_template: &task-template
debug_information_script:
- echo "$(which python) -- $(python -VV)"
- echo "$(which pip) -- $(pip -VV)"
- python -c 'import os, sys; print(os.name, sys.platform, getattr(sys, "abiflags", None))'
prepare_script: # avoid git failing with setuptools-scm
- git config --global user.email "you@example.com"
- git config --global user.name "Your Name"
pip_cache:
folder: "${CIRRUS_WORKING_DIR}/.cache/pip"
fingerprint_script: echo "${CIRRUS_OS}-${CIRRUS_TASK_NAME}"
reupload_on_changes: true
pre_commit_cache:
folder: "${CIRRUS_WORKING_DIR}/.cache/pre-commit"
fingerprint_script: echo "${CIRRUS_OS}-${CIRRUS_TASK_NAME}" | cat - .pre-commit-config.yaml
reupload_on_changes: true
.test_template: &test-template
# Requires pip, tox, and pipx to be installed via OS/pip
alias: test
depends_on: [build]
<<: *task-template
test_files_cache:
folder: ${VALIDATE_PYPROJECT_CACHE_REMOTE}
fingerprint_script: echo $CIRRUS_BUILD_ID
populate_script: python tools/cache_urls_for_tests.py
reupload_on_changes: true
download_artifact_script: &download-artifact
- curl -L -O ${CIRRUS_ARTIFACT_URL}/build/upload/dist.tar.gz
- tar xzf dist.tar.gz
- rm dist.tar.gz
test_script: >
tox --installpkg dist/*.whl --
-n 5 --randomly-seed=42 -rfEx --durations 10 --color yes
submit_coverage_script:
- pipx run coverage xml -o coverage.xml
- pipx run 'coveralls<4' --submit coverage.xml
# ^-- https://github.com/TheKevJames/coveralls-python/issues/434
# Deep clone script for POSIX environments (required for setuptools-scm)
.clone_script: &clone |
if [ -z "$CIRRUS_PR" ]; then
git clone --recursive --branch=$CIRRUS_BRANCH https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git $CIRRUS_WORKING_DIR
git reset --hard $CIRRUS_CHANGE_IN_REPO
else
git clone --recursive https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git $CIRRUS_WORKING_DIR
git fetch origin pull/$CIRRUS_PR/head:pull/$CIRRUS_PR
git reset --hard $CIRRUS_CHANGE_IN_REPO
fi
# ---- CI Pipeline ----
build_task:
name: build and check (Linux - 3.11)
alias: build
container: {image: "python:3.11-bullseye"}
clone_script: *clone
<<: *task-template
install_script: pip install tox tox-uv
build_script:
- tox -e clean,lint,typecheck,build
- tar czf dist.tar.gz dist
upload_artifacts:
path: dist.tar.gz
linux_task:
matrix:
- name: test (Linux - 3.8)
container: {image: "python:3.8-bookworm"}
- name: test (Linux - 3.10)
container: {image: "python:3.10-bookworm"}
skip: $BRANCH !=~ "^(main|master)$"
- name: test (Linux - 3.11)
container: {image: "python:3.11-bookworm"}
skip: $BRANCH !=~ "^(main|master)$"
- name: test (Linux - 3.12)
container: {image: "python:3.12-bookworm"}
- name: test (Linux - 3.13)
container: {image: "python:3.13-rc-bookworm"}
allow_failures: true # RC
install_script:
- python -m pip install --upgrade pip tox tox-uv pipx
<<: *test-template
alias: base-test
mamba_task:
name: test (Linux - mambaforge)
container: {image: "condaforge/mambaforge"}
install_script: # Overwrite template
- mamba install -y pip pipx tox curl
<<: *test-template
depends_on: [base-test]
macos_task:
name: test (macOS - brew)
macos_instance:
image: ghcr.io/cirruslabs/macos-runner:sonoma
env:
PATH: "/opt/homebrew/opt/python/libexec/bin:${PATH}"
brew_cache: {folder: "$HOME/Library/Caches/Homebrew"}
install_script: brew install python tox pipx
<<: *test-template
depends_on: [build, base-test]
freebsd_task:
name: test (freebsd - 3.11)
freebsd_instance: {image_family: freebsd-14-2}
install_script:
- pkg remove -y python lang/python
- pkg install -y git python311 py311-pip py311-gdbm py311-sqlite3 py311-tox py311-tomli py311-pipx
- ln -s /usr/local/bin/python3.11 /usr/local/bin/python
<<: *test-template
depends_on: [build, base-test]
windows_task:
name: test (Windows - 3.12.5)
windows_container:
image: "cirrusci/windowsservercore:2019"
os_version: 2019
env:
CIRRUS_SHELL: bash
PATH: /c/Python312:/c/Python312/Scripts:/c/tools:${PATH}
install_script:
# Activate long file paths to avoid some errors
- ps: New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
- choco install -y --no-progress python3 --version=3.12.5 --params "/NoLockdown"
- choco install -y --no-progress curl
- pip install --upgrade certifi
- python -m pip install -U pip tox tox-uv pipx
<<: *test-template
depends_on: [build, base-test]
finalize_task:
container: {image: "python:3.10-bullseye"}
depends_on: [test]
<<: *task-template
install_script: pip install 'coveralls<4'
# ^-- https://github.com/TheKevJames/coveralls-python/issues/434
finalize_coverage_script: coveralls --finish
linkcheck_task:
name: linkcheck (Linux - 3.10)
only_if: $BRANCH =~ "^(main|master)$"
container: {image: "python:3.10-bullseye"}
depends_on: [finalize]
allow_failures: true
<<: *task-template
install_script: pip install tox tox-uv
download_artifact_script: *download-artifact
linkcheck_script: tox --installpkg dist/*.whl -e linkcheck -- -q
# # The following task is already covered by a GitHub Action,
# # (commented to avoid errors when publishing duplicated packages to PyPI)
# publish_task:
# name: publish (Linux - 3.10)
# container: {image: "python:3.10-bullseye"}
# depends_on: [build, base-test, test]
# only_if: $CIRRUS_TAG =~ 'v\d.*' && $CIRRUS_USER_PERMISSION == "admin"
# <<: *task-template
# env:
# TWINE_REPOSITORY: pypi
# TWINE_USERNAME: __token__
# TWINE_PASSWORD: $PYPI_TOKEN
# # See: https://cirrus-ci.org/guide/writing-tasks/#encrypted-variables
# install_script: pip install tox
# download_artifact_script: *download-artifact
# publish_script:
# - ls dist/*
# - tox -e publish
|