-
Notifications
You must be signed in to change notification settings - Fork 4
/
.cirrus.yml
224 lines (209 loc) · 8.01 KB
/
.cirrus.yml
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
---
# Default values to be merged into tasks:
auto_cancellation: false
env:
PATH: ${HOME}/.local/bin:${PATH}
# ^ add user paths
PIP_CACHE: ${HOME}/.cache/pip
PRE_COMMIT_HOME: ${HOME}/.cache/pre-commit
LC_ALL: C.UTF-8
LANG: C.UTF-8
COVERAGE: NO
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}
# This template is used in most of the tasks
.regular_task_template: ®ULAR_TASK_TEMPLATE
tox_install_script:
- python -m pip install --upgrade pip setuptools tox pre-commit
prepare_script: &prepare
# This script is also used in Windows, so the shell is not POSIX
- git config --global user.email "[email protected]"
- git config --global user.name "Your Name"
clean_workspace_script:
# Avoid information carried from one run to the other
- rm -rf .coverage junit-*.xml .tox
# The following scripts are also used in Windows, be aware the shell is not POSIX
build_script: &build
- python -m tox -e build # Ensure PEP517-style build works
test_script: &test
- python -m tox -- -rfEx --durations 10 --color yes --junit-xml junit-test.xml
# ^ tox is better if invoked as a module on Windows/OSX
always: &upload-junit
upload_junit_artifacts:
path: junit-*.xml
format: junit
type: text/xml
pip_cache: &pip-cache
folder: $PIP_CACHE
pre_commit_cache: &pre-commit-cache
folder: $PRE_COMMIT_HOME
fingerprint_script:
- echo $CIRRUS_OS
- python --version
- pre-commit --version
- cat .pre-commit-config.yaml
# 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
# ---- Task definitions ----
typecheck_task:
name: typecheck (Linux - 3.10)
clone_script: *clone
container: {image: "python:3.10-bullseye"} # most recent => better type support
pip_cache: *pip-cache
mypy_cache:
folder: .mypy_cache
tox_install_script:
- python -m pip install --upgrade pip setuptools tox
prepare_script: *prepare
clean_workspace_script:
- rm -rf junit-*.xml
typecheck_script:
- python -m tox -e typecheck -- src --junit-xml junit-type.xml
always: *upload-junit
linux_mac_task:
# Use custom cloning since otherwise git tags are missing
clone_script: *clone
matrix:
- name: test (Linux - 3.6)
container: {image: "python:3.6-bullseye"}
allow_failures: true # EoL
- name: test (Linux - 3.7)
container: {image: "python:3.7-bullseye"}
- name: test (Linux - 3.8)
container: {image: "python:3.8-bullseye"}
- name: test (Linux - 3.9)
container: {image: "python:3.9-bullseye"}
- name: test (Linux - 3.10)
container: {image: "python:3.10-bullseye"}
- name: test (Linux - 3.11)
container: {image: "python:3.11-rc-bullseye"}
allow_failures: true # Experimental
- name: test (Linux - Anaconda)
container: {image: "continuumio/anaconda3:2021.11"}
env:
USING_CONDA: true
extra_install_script:
- conda install -y -c conda-forge virtualenv build setuptools setuptools-scm pip tox
- name: test (OS X)
macos_instance: {image: "big-sur-xcode"}
env:
PYTHON_VERSION: 3.9
# ^ update when the default version of python in homebrew changes
PATH: "${HOME}/.local/bin:${HOME}/Library/Python/${PYTHON_VERSION}/bin:/usr/local/opt/python/libexec/bin:${PATH}"
# ^ add user and homebrew paths
PIP_CACHE: "${HOME}/Library/Caches/pip"
brew_cache:
folder: "$HOME/Library/Caches/Homebrew"
install_script:
- brew install python
- brew cleanup
<<: *REGULAR_TASK_TEMPLATE
windows_task:
name: test (Windows)
tools_cache:
folder: 'C:\tools'
fingerprint_script:
- ps: echo "$env:CIRRUS_OS - nuget v6.0.0 - git 2.34.1"
populate_script:
- ps: (mkdir 'C:\tools')
# ^ use parentheses to suppress errors
- ps: Invoke-WebRequest -OutFile 'C:\tools\nuget.exe' 'https://dist.nuget.org/win-x86-commandline/v6.0.0/nuget.exe'
- ps: nuget install GitForWindows -Version 2.34.1 -NonInteractive -OutputDirectory C:\tools
workaround_git_script:
- git config --system core.longpaths true # Fix for windows git checkout problems
clone_script:
# Use custom cloning since otherwise git tags are missing
CMD.exe /C ECHO ON &
IF NOT DEFINED CIRRUS_PR (
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%
)
windows_container:
image: "python:3.8-windowsservercore"
os_version: 2019
env:
# Single quotes are used bellow to escape Windows backslash and % (YAML restrictions).
PYTHON_HOME: 'C:\Python'
PYTHON_APPDATA: '%APPDATA%\Python\Python38'
# ^ update when python version changes
GIT_HOME: 'C:\tools\GitForWindows.2.34.1\tools'
# ^ update when git version changes
HOME: '%USERPROFILE%'
USERNAME: ContainerAdministrator
# ^ ensure USERNAME is set in Windows, so the getpass module doesn't raise exceptions
PATH: '%HOME%\.local\bin\;%PYTHON_APPDATA%\Scripts\;%PYTHON_HOME%\;%PYTHON_HOME%\Scripts\;C:\tools\;%GIT_HOME%\cmd\;%GIT_HOME%\usr\bin\;%PATH%'
# ^ add user paths
PIP_CACHE: '%LocalAppData%\pip\Cache'
PIP_TRUSTED_HOST: 'pypi.org pypi.python.org files.pythonhosted.org'
PIP_CONFIG_FILE: '%AppData%\pip\pip.ini'
PRE_COMMIT_HOME: '%USERPROFILE%\.cache\pre-commit'
COVERAGE: 'NO'
pip_cache:
folder: '%PIP_CACHE%'
pre_commit_cache:
folder: '%PRE_COMMIT_HOME%'
install_script:
# Activate long file paths to avoid some errors
- REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem" /v LongPathsEnabled /t REG_DWORD /d 1 /f
# Set Windows encoding to UTF-8
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Command Processor" /v Autorun /t REG_SZ /d "@chcp 65001>nul" /f
- python -m ensurepip
- python -m pip install --upgrade --user pip setuptools certifi tox pre-commit
prepare_script: *prepare
clean_workspace_script:
# Avoid information carried from one run to the other
# CMD is not capable of globbing, so we have to use PowerShell
- ps: (rm -Recurse -Force -ErrorAction SilentlyContinue .tox,junit-*.xml)
build_script: *build
test_script: *test
always: *upload-junit
coverage_task:
name: coverage (Linux - 3.8)
clone_script: *clone
container: {image: "python:3.8-bullseye"}
env:
COVERAGE: yes
depends_on:
- test (Linux - 3.7)
- test (Linux - 3.8)
- test (Linux - 3.9)
- test (Linux - 3.10)
- test (Linux - Anaconda)
- test (OS X)
pip_install_script:
pip install --user --upgrade coverage coveralls pre-commit
precommit_script:
- pre-commit install
- pre-commit run --all-files
<<: *REGULAR_TASK_TEMPLATE
coverage_script:
- coveralls
linkcheck_task:
name: linkcheck (Linux - 3.9)
# only_if: $CIRRUS_BRANCH == 'master'
allow_failures: true
clone_script: *clone
container: {image: "python:3.9-buster"}
depends_on:
- test (Linux - 3.8)
pip_cache: *pip-cache
tox_install_script:
- python -m pip install --upgrade pip setuptools tox
prepare_script: *prepare
linkcheck_script:
- python -m tox -e linkcheck -- -q