-
Notifications
You must be signed in to change notification settings - Fork 7
133 lines (120 loc) · 4.45 KB
/
tests-with-pydebug.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
name: Tests with PyDebug
on:
push:
branches:
- main
pull_request:
paths:
- setup.py
- setup.cfg
- pyproject.toml
- MANIFEST.in
- CMakeLists.txt
- include/**
- src/**
- tests/**
- optree/**
- .github/workflows/tests-with-pydebug.yml
# Allow to trigger the workflow manually
workflow_dispatch:
permissions:
contents: read
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
OPTREE_CXX_WERROR: "ON"
jobs:
test:
name: Test for Python ${{ matrix.python-version }}${{ matrix.python-abiflags }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
python-abiflags: ["d", "td"]
exclude:
- python-version: "3.7"
python-abiflags: "td"
- python-version: "3.8"
python-abiflags: "td"
- python-version: "3.9"
python-abiflags: "td"
- python-version: "3.10"
python-abiflags: "td"
- python-version: "3.11"
python-abiflags: "td"
- python-version: "3.12"
python-abiflags: "td"
- os: windows-latest # pyenv-win does not support Python 3.13t yet
python-version: "3.13"
python-abiflags: "td"
fail-fast: false
timeout-minutes: 90
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up pyenv
if: runner.os != 'Windows'
run: |
export PYENV_ROOT="${HOME}/.pyenv"
git clone https://github.com/pyenv/pyenv.git "${PYENV_ROOT}"
echo "PYENV_ROOT=${PYENV_ROOT}" >> "${GITHUB_ENV}"
echo "PATH=${PYENV_ROOT}/bin:${PYENV_ROOT}/shims:${PATH}" >> "${GITHUB_ENV}"
- name: Set up pyenv
if: runner.os == 'Windows'
shell: pwsh
run: |
$Env:PYENV_ROOT = "$Env:USERPROFILE\.pyenv"
git clone https://github.com/pyenv-win/pyenv-win.git "$Env:PYENV_ROOT"
Write-Output "PYENV_ROOT=$Env:PYENV_ROOT" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
Write-Output "PATH=$Env:PYENV_ROOT\pyenv-win\bin;$Env:PYENV_ROOT\pyenv-win\shims;$Env:PATH" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
- name: Determine Python version
shell: bash
run: |
pyenv install --list
if [[ "${{ matrix.python-abiflags }}" == *t* ]]; then
PYTHON_VERSION="$(
pyenv install --list | tr -d ' ' | grep -E "^${{ matrix.python-version }}" |
grep -vF '-' | grep -E '[0-9]t$' | sort -rV | head -n 1
)"
elif ! PYTHON_VERSION="$(pyenv latest --known "${{ matrix.python-version }}")"; then
PYTHON_VERSION="$(
pyenv install --list | tr -d ' ' | grep -E "^${{ matrix.python-version }}" |
grep -vF '-' | grep -E '[0-9]$' | sort -rV | head -n 1
)"
fi
echo "Using Python version: ${PYTHON_VERSION}"
echo "PYTHON_VERSION=${PYTHON_VERSION}" >> "${GITHUB_ENV}"
- uses: actions/cache@v4
id: python-cache
with:
path: ${{ env.PYENV_ROOT }}
key: ${{ runner.os }}-${{ matrix.python-version }}${{ matrix.python-abiflags }}-${{ env.PYTHON_VERSION }}
- name: Set up Python
if: steps.python-cache.outputs.cache-hit != 'true'
shell: bash
run: |
PYENV_INSTALL_ARGS=()
if [[ "${{ runner.os }}" != 'Windows' ]]; then
if [[ "${{ matrix.python-abiflags }}" == *d* ]]; then
PYENV_INSTALL_ARGS+=("--debug")
fi
else
if [[ "${{ matrix.python-abiflags }}" == *d* ]]; then
PYENV_INSTALL_ARGS+=("--dev")
fi
fi
pyenv install ${{ env.PYTHON_VERSION }} "${PYENV_INSTALL_ARGS[@]}"
pyenv global ${{ env.PYTHON_VERSION }}
- name: Upgrade pip
run: |
python --version
python -c 'from pprint import pprint; import sysconfig; pprint(sysconfig.get_config_vars())'
python -m pip install --upgrade pip setuptools wheel
- name: Install OpTree
run: |
python -m pip install -vvv --editable '.[test]'
- name: Test with pytest
run: |
make test PYTESTOPTS="--exitfirst"