@@ -10,7 +10,7 @@ import {
10
10
validatePythonVersionFormatForPyPy ,
11
11
isCacheFeatureAvailable ,
12
12
getVersionInputFromFile ,
13
- getVersionInputFromPlainFile ,
13
+ getVersionsInputFromPlainFile ,
14
14
getVersionInputFromTomlFile ,
15
15
getNextPageUrl ,
16
16
isGhes ,
@@ -24,10 +24,10 @@ jest.mock('@actions/core');
24
24
25
25
describe ( 'validatePythonVersionFormatForPyPy' , ( ) => {
26
26
it . each ( [
27
- [ '3.6 ' , true ] ,
28
- [ '3.7 ' , true ] ,
29
- [ '3.6 .x' , false ] ,
30
- [ '3.7 .x' , false ] ,
27
+ [ '3.12 ' , true ] ,
28
+ [ '3.13 ' , true ] ,
29
+ [ '3.12 .x' , false ] ,
30
+ [ '3.13 .x' , false ] ,
31
31
[ '3.x' , false ] ,
32
32
[ '3' , false ]
33
33
] ) ( '%s -> %s' , ( input , expected ) => {
@@ -95,24 +95,52 @@ const tempDir = path.join(
95
95
) ;
96
96
97
97
describe ( 'Version from file test' , ( ) => {
98
- it . each ( [ getVersionInputFromPlainFile , getVersionInputFromFile ] ) (
98
+ it . each ( [ getVersionsInputFromPlainFile , getVersionInputFromFile ] ) (
99
99
'Version from plain file test' ,
100
100
async _fn => {
101
101
await io . mkdirP ( tempDir ) ;
102
102
const pythonVersionFileName = 'python-version.file' ;
103
103
const pythonVersionFilePath = path . join ( tempDir , pythonVersionFileName ) ;
104
- const pythonVersionFileContent = '3.7 ' ;
104
+ const pythonVersionFileContent = '3.13 ' ;
105
105
fs . writeFileSync ( pythonVersionFilePath , pythonVersionFileContent ) ;
106
106
expect ( _fn ( pythonVersionFilePath ) ) . toEqual ( [ pythonVersionFileContent ] ) ;
107
107
}
108
108
) ;
109
+ it . each ( [ getVersionsInputFromPlainFile , getVersionInputFromFile ] ) (
110
+ 'Versions from multiline plain file test' ,
111
+ async _fn => {
112
+ await io . mkdirP ( tempDir ) ;
113
+ const pythonVersionFileName = 'python-version.file' ;
114
+ const pythonVersionFilePath = path . join ( tempDir , pythonVersionFileName ) ;
115
+ const pythonVersionFileContent = '3.13\r\n3.12' ;
116
+ fs . writeFileSync ( pythonVersionFilePath , pythonVersionFileContent ) ;
117
+ expect ( _fn ( pythonVersionFilePath ) ) . toEqual ( [ '3.13' , '3.12' ] ) ;
118
+ }
119
+ ) ;
120
+ it . each ( [ getVersionsInputFromPlainFile , getVersionInputFromFile ] ) (
121
+ 'Version from complex plain file test' ,
122
+ async _fn => {
123
+ await io . mkdirP ( tempDir ) ;
124
+ const pythonVersionFileName = 'python-version.file' ;
125
+ const pythonVersionFilePath = path . join ( tempDir , pythonVersionFileName ) ;
126
+ const pythonVersionFileContent =
127
+ '3.13/envs/virtualenv\r# 3.12\n3.11\r\n3.10\r\n 3.9 \r\n' ;
128
+ fs . writeFileSync ( pythonVersionFilePath , pythonVersionFileContent ) ;
129
+ expect ( _fn ( pythonVersionFilePath ) ) . toEqual ( [
130
+ '3.13' ,
131
+ '3.11' ,
132
+ '3.10' ,
133
+ '3.9'
134
+ ] ) ;
135
+ }
136
+ ) ;
109
137
it . each ( [ getVersionInputFromTomlFile , getVersionInputFromFile ] ) (
110
138
'Version from standard pyproject.toml test' ,
111
139
async _fn => {
112
140
await io . mkdirP ( tempDir ) ;
113
141
const pythonVersionFileName = 'pyproject.toml' ;
114
142
const pythonVersionFilePath = path . join ( tempDir , pythonVersionFileName ) ;
115
- const pythonVersion = '>=3.7 .0' ;
143
+ const pythonVersion = '>=3.13 .0' ;
116
144
const pythonVersionFileContent = `[project]\nrequires-python = "${ pythonVersion } "` ;
117
145
fs . writeFileSync ( pythonVersionFilePath , pythonVersionFileContent ) ;
118
146
expect ( _fn ( pythonVersionFilePath ) ) . toEqual ( [ pythonVersion ] ) ;
@@ -124,7 +152,7 @@ describe('Version from file test', () => {
124
152
await io . mkdirP ( tempDir ) ;
125
153
const pythonVersionFileName = 'pyproject.toml' ;
126
154
const pythonVersionFilePath = path . join ( tempDir , pythonVersionFileName ) ;
127
- const pythonVersion = '>=3.7 .0' ;
155
+ const pythonVersion = '>=3.13 .0' ;
128
156
const pythonVersionFileContent = `[tool.poetry.dependencies]\npython = "${ pythonVersion } "` ;
129
157
fs . writeFileSync ( pythonVersionFilePath , pythonVersionFileContent ) ;
130
158
expect ( _fn ( pythonVersionFilePath ) ) . toEqual ( [ pythonVersion ] ) ;
@@ -145,9 +173,9 @@ describe('Version from file test', () => {
145
173
async _fn => {
146
174
const toolVersionFileName = '.tool-versions' ;
147
175
const toolVersionFilePath = path . join ( tempDir , toolVersionFileName ) ;
148
- const toolVersionContent = 'python 3.9.10 \nnodejs 16' ;
176
+ const toolVersionContent = 'python 3.13.2 \nnodejs 16' ;
149
177
fs . writeFileSync ( toolVersionFilePath , toolVersionContent ) ;
150
- expect ( _fn ( toolVersionFilePath ) ) . toEqual ( [ '3.9.10 ' ] ) ;
178
+ expect ( _fn ( toolVersionFilePath ) ) . toEqual ( [ '3.13.2 ' ] ) ;
151
179
}
152
180
) ;
153
181
@@ -156,9 +184,9 @@ describe('Version from file test', () => {
156
184
async _fn => {
157
185
const toolVersionFileName = '.tool-versions' ;
158
186
const toolVersionFilePath = path . join ( tempDir , toolVersionFileName ) ;
159
- const toolVersionContent = '# python 3.8 \npython 3.9 ' ;
187
+ const toolVersionContent = '# python 3.13 \npython 3.12 ' ;
160
188
fs . writeFileSync ( toolVersionFilePath , toolVersionContent ) ;
161
- expect ( _fn ( toolVersionFilePath ) ) . toEqual ( [ '3.9 ' ] ) ;
189
+ expect ( _fn ( toolVersionFilePath ) ) . toEqual ( [ '3.12 ' ] ) ;
162
190
}
163
191
) ;
164
192
@@ -167,9 +195,9 @@ describe('Version from file test', () => {
167
195
async _fn => {
168
196
const toolVersionFileName = '.tool-versions' ;
169
197
const toolVersionFilePath = path . join ( tempDir , toolVersionFileName ) ;
170
- const toolVersionContent = ' python 3.10 ' ;
198
+ const toolVersionContent = ' python 3.13 ' ;
171
199
fs . writeFileSync ( toolVersionFilePath , toolVersionContent ) ;
172
- expect ( _fn ( toolVersionFilePath ) ) . toEqual ( [ '3.10 ' ] ) ;
200
+ expect ( _fn ( toolVersionFilePath ) ) . toEqual ( [ '3.13 ' ] ) ;
173
201
}
174
202
) ;
175
203
@@ -178,9 +206,9 @@ describe('Version from file test', () => {
178
206
async _fn => {
179
207
const toolVersionFileName = '.tool-versions' ;
180
208
const toolVersionFilePath = path . join ( tempDir , toolVersionFileName ) ;
181
- const toolVersionContent = 'python v3.9.10 ' ;
209
+ const toolVersionContent = 'python v3.13.2 ' ;
182
210
fs . writeFileSync ( toolVersionFilePath , toolVersionContent ) ;
183
- expect ( _fn ( toolVersionFilePath ) ) . toEqual ( [ '3.9.10 ' ] ) ;
211
+ expect ( _fn ( toolVersionFilePath ) ) . toEqual ( [ '3.13.2 ' ] ) ;
184
212
}
185
213
) ;
186
214
@@ -189,9 +217,9 @@ describe('Version from file test', () => {
189
217
async _fn => {
190
218
const toolVersionFileName = '.tool-versions' ;
191
219
const toolVersionFilePath = path . join ( tempDir , toolVersionFileName ) ;
192
- const toolVersionContent = 'python pypy3.10-7.3.14 ' ;
220
+ const toolVersionContent = 'python pypy3.10-7.3.19 ' ;
193
221
fs . writeFileSync ( toolVersionFilePath , toolVersionContent ) ;
194
- expect ( _fn ( toolVersionFilePath ) ) . toEqual ( [ 'pypy3.10-7.3.14 ' ] ) ;
222
+ expect ( _fn ( toolVersionFilePath ) ) . toEqual ( [ 'pypy3.10-7.3.19 ' ] ) ;
195
223
}
196
224
) ;
197
225