Repository navigation
186 lines (174 loc) · 8.06 KB
/
Copy pathfree-threaded-python.yml
File metadata and controls
186 lines (174 loc) · 8.06 KB
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
name: Free-threaded Python
# Builds the Device Detection and IP Intelligence on-premise packages on the
# free-threaded builds of Python and runs their tests there, with the free
# Lite data files. Those come from the one shared copy that common-ci's
# Nightly Shared Assets workflow downloads each day, as every other
# workflow's tests do, restored by common-ci's fetch-assets action. No job
# downloads them from the links in the data submodule.
# ci/free-threaded-python.Tests.ps1 checks this. The native modules do not declare that they run without
# the GIL, so Python turns the GIL back on when it loads them.
# tests/test_free_threaded.py in each package checks that it does, and is
# skipped on every other build of Python.
on:
pull_request:
paths:
- 'device-detection/fiftyone_devicedetection_onpremise/**'
- 'ip-intelligence/fiftyone_ipintelligence_onpremise/**'
- 'pipeline/fiftyone_pipeline_core/**'
- 'pipeline/fiftyone_pipeline_engines/**'
- 'pipeline/fiftyone_pipeline_engines_fiftyone/**'
- 'cxx'
- '.github/workflows/free-threaded-python.yml'
push:
branches:
- main
- rc
paths:
- 'device-detection/fiftyone_devicedetection_onpremise/**'
- 'ip-intelligence/fiftyone_ipintelligence_onpremise/**'
- 'pipeline/fiftyone_pipeline_core/**'
- 'pipeline/fiftyone_pipeline_engines/**'
- 'pipeline/fiftyone_pipeline_engines_fiftyone/**'
- 'cxx'
- '.github/workflows/free-threaded-python.yml'
workflow_dispatch:
permissions:
contents: read
# Every warning in the native build is an error in this workflow's builds, as
# in every build 51Degrees runs. setup.py reads the variable in
# warnings_are_errors().
env:
_51DEGREES_WARNINGS_AS_ERRORS: 'true'
jobs:
free-threaded:
name: Python ${{ matrix.python }} on ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
python: '3.13t'
- os: ubuntu-latest
python: '3.14t'
- os: windows-latest
python: '3.14t'
runs-on: ${{ matrix.os }}
defaults:
run:
shell: pwsh
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
# The native source is the cxx submodule, and the data files are
# linked from its own data submodule.
submodules: recursive
# The package versions written below come from the release tags.
fetch-depth: 0
# ci/write-package-versions.ps1 works out the versions with common-ci's
# release plan.
- name: Checkout common-ci
uses: actions/checkout@v4
with:
repository: 51Degrees/common-ci
ref: main
path: .common-ci
persist-credentials: false
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Check the build is free-threaded
run: |
python -c "import sys, sysconfig; print(sys.version); assert sysconfig.get_config_var('Py_GIL_DISABLED') == 1, 'not a free-threaded build'; assert not sys._is_gil_enabled(), 'the GIL is on at start'"
- name: Install the packages the tests use
env:
_51DEGREES_COMMON_CI_DIR: ${{ github.workspace }}/.common-ci
run: |
# A pip install that fails stops the step here, rather than
# leaving the tests to fail on a missing module.
$PSNativeCommandUseErrorActionPreference = $true
python -m pip install --upgrade pip
python -m pip install pytest flask flask-unittest json5 ruamel.yaml Cython setuptools
# A package installed from this checkout is 0.0.0 without the
# version.txt this writes, which is below the versions the packages
# here require of each other, so pip would refuse them.
./ci/write-package-versions.ps1
# The pipeline packages come from this checkout, as the tests run
# with the pipeline code they are released with.
python -m pip install `
-e pipeline/fiftyone_pipeline_core `
-e pipeline/fiftyone_pipeline_engines `
-e pipeline/fiftyone_pipeline_engines_fiftyone `
-e pipeline/fiftyone_pipeline_cloudrequestengine `
-e device-detection/fiftyone_devicedetection_shared `
-e device-detection/fiftyone_devicedetection_cloud `
-e ip-intelligence/fiftyone_ipintelligence_shared
# These two require the on-premise package by name, which the
# tests read from its source folder instead.
python -m pip install --no-deps `
-e device-detection/fiftyone_devicedetection `
-e device-detection/fiftyone_devicedetection_examples
# The free files need no key. A file the shared copy lacks fails the
# step, and nothing downloads it here.
- name: Restore the free data files
uses: 51Degrees/common-ci/actions/fetch-assets@main
with:
assets: |
51Degrees-LiteV4.1.hash
20000 Evidence Records.yml
51Degrees-IPIV4AsnIpiV41.ipi
51Degrees-LiteIpiV41.ipi
# Copies, not links, so the Windows job needs no right to make links.
- name: Put the free data files where the tests look for them
run: |
$dd = 'cxx/data/device-detection'
$ipi = 'cxx/data/ip-intelligence'
New-Item -ItemType Directory -Force -Path $dd, $ipi, ip-intelligence/assets | Out-Null
Copy-Item -LiteralPath 'assets/51Degrees-LiteV4.1.hash' -Destination $dd
Copy-Item -LiteralPath 'assets/20000 Evidence Records.yml' -Destination $dd
Copy-Item -LiteralPath 'assets/51Degrees-IPIV4AsnIpiV41.ipi' -Destination $ipi
# The data repository saves the Lite IP Intelligence file as
# 51Degrees-LiteV41.ipi, and the tests also look for it under the
# name the assets give it.
Copy-Item -LiteralPath 'assets/51Degrees-LiteIpiV41.ipi' -Destination "$ipi/51Degrees-LiteV41.ipi"
Copy-Item -LiteralPath 'assets/51Degrees-LiteIpiV41.ipi' -Destination ip-intelligence/assets
- name: Build the native modules
run: |
if ($IsWindows) {
# A short temporary path, for the MSVC path length limit.
$env:TEMP = New-Item -ItemType Directory -Force -Path 'C:\tmp'
$env:TMP = $env:TEMP
}
foreach ($package in 'device-detection/fiftyone_devicedetection_onpremise', 'ip-intelligence/fiftyone_ipintelligence_onpremise') {
Push-Location $package
python setup.py build_clib build_ext --inplace
if ($LASTEXITCODE) { exit $LASTEXITCODE }
Pop-Location
}
# The tests start with the GIL on, as the package's readme says to,
# because Python warns when it turns the GIL on to load a native module
# and every warning fails the tests. tests/test_free_threaded.py loads
# each module in a new interpreter without PYTHON_GIL, and checks that
# Python turns the GIL on and gives that warning.
- name: Run the tests
env:
PYTHON_GIL: '1'
run: |
# The data file variables name the files restored above, before
# any test changes folder.
$env:_51DEGREES_DD_PATH = (Resolve-Path cxx/data/device-detection/51Degrees-LiteV4.1.hash).Path
$env:_51DEGREES_IPI_PATH = (Resolve-Path cxx/data/ip-intelligence/51Degrees-LiteV41.ipi).Path
$failed = $false
foreach ($package in 'device-detection/fiftyone_devicedetection_onpremise', 'ip-intelligence/fiftyone_ipintelligence_onpremise') {
Write-Host "::group::$package"
Push-Location $package
$env:PYTHONPATH = Join-Path $PWD 'src'
# -rs lists any test that skipped, and none should here.
python -m pytest -rs tests
if ($LASTEXITCODE) { $failed = $true }
Pop-Location
Write-Host '::endgroup::'
}
if ($failed) { exit 1 }